-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
421 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Root from './label.svelte'; | ||
|
||
export { | ||
Root, | ||
// | ||
Root as Label | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script lang="ts"> | ||
import { Label as LabelPrimitive } from 'bits-ui'; | ||
import { cn } from '$lib/utils.js'; | ||
let { | ||
ref = $bindable(null), | ||
class: className, | ||
...restProps | ||
}: LabelPrimitive.RootProps = $props(); | ||
</script> | ||
|
||
<LabelPrimitive.Root | ||
bind:ref | ||
class={cn( | ||
'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70', | ||
className | ||
)} | ||
{...restProps} | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Popover as PopoverPrimitive } from 'bits-ui'; | ||
import Content from './popover-content.svelte'; | ||
const Root = PopoverPrimitive.Root; | ||
const Trigger = PopoverPrimitive.Trigger; | ||
const Close = PopoverPrimitive.Close; | ||
|
||
export { | ||
Root, | ||
Content, | ||
Trigger, | ||
Close, | ||
// | ||
Root as Popover, | ||
Content as PopoverContent, | ||
Trigger as PopoverTrigger, | ||
Close as PopoverClose | ||
}; |
28 changes: 28 additions & 0 deletions
28
sites/docs/src/lib/components/ui/popover/popover-content.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script lang="ts"> | ||
import { cn } from '$lib/utils.js'; | ||
import { Popover as PopoverPrimitive } from 'bits-ui'; | ||
let { | ||
ref = $bindable(null), | ||
class: className, | ||
sideOffset = 4, | ||
align = 'center', | ||
portalProps, | ||
...restProps | ||
}: PopoverPrimitive.ContentProps & { | ||
portalProps?: PopoverPrimitive.PortalProps; | ||
} = $props(); | ||
</script> | ||
|
||
<PopoverPrimitive.Portal {...portalProps}> | ||
<PopoverPrimitive.Content | ||
bind:ref | ||
{sideOffset} | ||
{align} | ||
class={cn( | ||
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 rounded-md border p-4 shadow-md outline-none', | ||
className | ||
)} | ||
{...restProps} | ||
/> | ||
</PopoverPrimitive.Portal> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { error } from '@sveltejs/kit'; | ||
import { makeBadge } from 'badge-maker'; | ||
|
||
export const GET = async ({ params }) => { | ||
let state = params.state; | ||
|
||
if (state.endsWith('.svg')) state = state.slice(0, state.length - 4); | ||
|
||
if (!['passing', 'failing'].includes(state)); | ||
|
||
const svg = makeBadge({ | ||
label: 'jsrepo', | ||
labelColor: '#f7df1e', | ||
color: state === 'failing' ? '#ff0000' : '', | ||
message: `build ${state}` | ||
}); | ||
|
||
return new Response(svg, { | ||
headers: { | ||
'Content-Type': 'image/svg+xml' | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { getProviderState, getProviderToken } from '$lib/ts/registry'; | ||
import { error } from '@sveltejs/kit'; | ||
import { fetchManifest, selectProvider } from 'jsrepo'; | ||
import { makeBadge } from 'badge-maker'; | ||
|
||
export const GET = async ({ url }) => { | ||
const registryUrl = url.searchParams.get('url'); | ||
|
||
if (registryUrl == null) throw error(400, 'Expected `url` search param'); | ||
|
||
const provider = selectProvider(registryUrl); | ||
|
||
if (!provider) throw error(400, 'Invalid registry url'); | ||
|
||
const state = await getProviderState(registryUrl, provider, { cache: true }); | ||
|
||
const manifest = (await fetchManifest(state, { token: getProviderToken(state.provider) })).match( | ||
(v) => v, | ||
(err) => { | ||
throw error(400, `Error fetching manifest: ${err}`); | ||
} | ||
); | ||
|
||
const svg = makeBadge({ | ||
label: 'jsrepo', | ||
labelColor: '#f7df1e', | ||
message: `${manifest.categories.flatMap((c) => c.blocks).length} blocks` | ||
}); | ||
|
||
return new Response(svg, { | ||
headers: { | ||
'Content-Type': 'image/svg+xml' | ||
} | ||
}); | ||
}; |
35 changes: 35 additions & 0 deletions
35
sites/docs/src/routes/badges/registry/categories/+server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { getProviderState, getProviderToken } from '$lib/ts/registry'; | ||
import { error } from '@sveltejs/kit'; | ||
import { fetchManifest, selectProvider } from 'jsrepo'; | ||
import { makeBadge } from 'badge-maker'; | ||
|
||
export const GET = async ({ url }) => { | ||
const registryUrl = url.searchParams.get('url'); | ||
|
||
if (registryUrl == null) throw error(400, 'Expected `url` search param'); | ||
|
||
const provider = selectProvider(registryUrl); | ||
|
||
if (!provider) throw error(400, 'Invalid registry url'); | ||
|
||
const state = await getProviderState(registryUrl, provider, { cache: true }); | ||
|
||
const manifest = (await fetchManifest(state, { token: getProviderToken(state.provider) })).match( | ||
(v) => v, | ||
(err) => { | ||
throw error(400, `Error fetching manifest: ${err}`); | ||
} | ||
); | ||
|
||
const svg = makeBadge({ | ||
label: 'jsrepo', | ||
labelColor: '#f7df1e', | ||
message: `${manifest.categories.length} categories` | ||
}); | ||
|
||
return new Response(svg, { | ||
headers: { | ||
'Content-Type': 'image/svg+xml' | ||
} | ||
}); | ||
}; |
Oops, something went wrong.