mirror of
https://github.com/pheralb/svgl.git
synced 2024-12-05 05:42:35 +08:00
📦 Add tabs UI component
This commit is contained in:
parent
806452bffa
commit
759a57468f
18
src/ui/tabs/index.ts
Normal file
18
src/ui/tabs/index.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Tabs as TabsPrimitive } from 'bits-ui';
|
||||
import Content from './tabs-content.svelte';
|
||||
import List from './tabs-list.svelte';
|
||||
import Trigger from './tabs-trigger.svelte';
|
||||
|
||||
const Root = TabsPrimitive.Root;
|
||||
|
||||
export {
|
||||
Root,
|
||||
Content,
|
||||
List,
|
||||
Trigger,
|
||||
//
|
||||
Root as Tabs,
|
||||
Content as TabsContent,
|
||||
List as TabsList,
|
||||
Trigger as TabsTrigger
|
||||
};
|
21
src/ui/tabs/tabs-content.svelte
Normal file
21
src/ui/tabs/tabs-content.svelte
Normal file
@ -0,0 +1,21 @@
|
||||
<script lang="ts">
|
||||
import { Tabs as TabsPrimitive } from 'bits-ui';
|
||||
import { cn } from '@/utils/cn';
|
||||
|
||||
type $$Props = TabsPrimitive.ContentProps;
|
||||
|
||||
let className: $$Props['class'] = undefined;
|
||||
export let value: $$Props['value'];
|
||||
export { className as class };
|
||||
</script>
|
||||
|
||||
<TabsPrimitive.Content
|
||||
class={cn(
|
||||
'focus-visible:ring-ring mt-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
|
||||
className
|
||||
)}
|
||||
{value}
|
||||
{...$$restProps}
|
||||
>
|
||||
<slot />
|
||||
</TabsPrimitive.Content>
|
16
src/ui/tabs/tabs-list.svelte
Normal file
16
src/ui/tabs/tabs-list.svelte
Normal file
@ -0,0 +1,16 @@
|
||||
<script lang="ts">
|
||||
import { Tabs as TabsPrimitive } from 'bits-ui';
|
||||
import { cn } from '@/utils/cn';
|
||||
|
||||
type $$Props = TabsPrimitive.ListProps;
|
||||
|
||||
let className: $$Props['class'] = undefined;
|
||||
export { className as class };
|
||||
</script>
|
||||
|
||||
<TabsPrimitive.List
|
||||
class={cn('inline-flex h-9 items-center justify-center space-x-1 rounded-lg', className)}
|
||||
{...$$restProps}
|
||||
>
|
||||
<slot />
|
||||
</TabsPrimitive.List>
|
25
src/ui/tabs/tabs-trigger.svelte
Normal file
25
src/ui/tabs/tabs-trigger.svelte
Normal file
@ -0,0 +1,25 @@
|
||||
<script lang="ts">
|
||||
import { Tabs as TabsPrimitive } from 'bits-ui';
|
||||
import { cn } from '@/utils/cn';
|
||||
|
||||
type $$Props = TabsPrimitive.TriggerProps;
|
||||
type $$Events = TabsPrimitive.TriggerEvents;
|
||||
|
||||
let className: $$Props['class'] = undefined;
|
||||
export let value: $$Props['value'];
|
||||
export { className as class };
|
||||
</script>
|
||||
|
||||
<TabsPrimitive.Trigger
|
||||
class={cn(
|
||||
'inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium text-neutral-500 transition-all hover:bg-neutral-300/40 hover:text-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-200 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-neutral-300/40 data-[state=active]:text-black data-[state=active]:shadow dark:text-neutral-400 dark:hover:bg-neutral-800/40 dark:hover:text-white dark:focus-visible:ring-neutral-800 dark:data-[state=active]:bg-neutral-800/40 dark:data-[state=active]:text-white',
|
||||
className
|
||||
)}
|
||||
{value}
|
||||
{...$$restProps}
|
||||
on:click
|
||||
on:keydown
|
||||
on:focus
|
||||
>
|
||||
<slot />
|
||||
</TabsPrimitive.Trigger>
|
Loading…
Reference in New Issue
Block a user