-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* component: Context Menu * meh * more * more --------- Co-authored-by: Davis SHYAKA <87414827+davis-shyaka@users.noreply.github.com>
- Loading branch information
1 parent
a35938e
commit 11c72e1
Showing
26 changed files
with
581 additions
and
5 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
35 changes: 35 additions & 0 deletions
35
src/lib/components/ui/context-menu/context-menu-checkbox-item.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,35 @@ | ||
<script lang="ts"> | ||
import { Icons } from '$lib/assets/icons'; | ||
import { cn } from '$lib/utils.js'; | ||
import { ContextMenu as ContextMenuPrimitive } from 'bits-ui'; | ||
type $$Props = ContextMenuPrimitive.CheckboxItemProps; | ||
type $$Events = ContextMenuPrimitive.CheckboxItemEvents; | ||
let className: $$Props['class'] = undefined; | ||
export let checked: $$Props['checked'] = undefined; | ||
export { className as class }; | ||
</script> | ||
|
||
<ContextMenuPrimitive.CheckboxItem | ||
bind:checked | ||
class={cn( | ||
'relative flex h-10 cursor-pointer select-none items-center rounded-md pl-8 pr-2 text-sm outline-none data-[disabled]:cursor-default data-[highlighted]:bg-gray-200 data-[disabled]:text-gray-700', | ||
className | ||
)} | ||
{...$$restProps} | ||
on:click | ||
on:keydown | ||
on:focusin | ||
on:focusout | ||
on:pointerdown | ||
on:pointerleave | ||
on:pointermove | ||
> | ||
<span class="absolute left-2 flex size-3.5 items-center justify-center"> | ||
<ContextMenuPrimitive.CheckboxIndicator> | ||
<Icons.Check class="size-3" /> | ||
</ContextMenuPrimitive.CheckboxIndicator> | ||
</span> | ||
<slot /> | ||
</ContextMenuPrimitive.CheckboxItem> |
24 changes: 24 additions & 0 deletions
24
src/lib/components/ui/context-menu/context-menu-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,24 @@ | ||
<script lang="ts"> | ||
import { cn, flyAndScale } from '$lib/utils.js'; | ||
import { ContextMenu as ContextMenuPrimitive } from 'bits-ui'; | ||
type $$Props = ContextMenuPrimitive.ContentProps; | ||
let className: $$Props['class'] = undefined; | ||
export let transition: $$Props['transition'] = flyAndScale; | ||
export let transitionConfig: $$Props['transitionConfig'] = undefined; | ||
export { className as class }; | ||
</script> | ||
|
||
<ContextMenuPrimitive.Content | ||
{transition} | ||
{transitionConfig} | ||
class={cn( | ||
'z-50 min-w-[10rem] rounded-xl bg-background-100 p-2 text-sm text-gray-1000 shadow-shadow-menu focus:outline-none', | ||
className | ||
)} | ||
{...$$restProps} | ||
on:keydown | ||
> | ||
<slot /> | ||
</ContextMenuPrimitive.Content> |
42 changes: 42 additions & 0 deletions
42
src/lib/components/ui/context-menu/context-menu-item.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,42 @@ | ||
<script lang="ts"> | ||
import type { Icons } from '$lib/assets/icons'; | ||
import { cn } from '$lib/utils.js'; | ||
import { ContextMenu as ContextMenuPrimitive } from 'bits-ui'; | ||
type $$Props = ContextMenuPrimitive.ItemProps & { | ||
inset?: boolean; | ||
affix?: typeof Icons.ArrowLeft; | ||
suffix?: typeof Icons.ArrowLeft; | ||
}; | ||
type $$Events = ContextMenuPrimitive.ItemEvents; | ||
let className: $$Props['class'] = undefined; | ||
export let inset: $$Props['inset'] = undefined; | ||
export let affix: $$Props['affix'] = undefined; | ||
export let suffix: $$Props['suffix'] = undefined; | ||
export { className as class }; | ||
</script> | ||
|
||
<ContextMenuPrimitive.Item | ||
class={cn( | ||
'relative flex h-10 select-none items-center gap-2 rounded-md px-2 text-sm outline-none data-[disabled]:cursor-default data-[highlighted]:cursor-pointer data-[highlighted]:bg-gray-200 data-[disabled]:text-gray-700', | ||
inset && 'pl-8', | ||
className | ||
)} | ||
{...$$restProps} | ||
on:click | ||
on:keydown | ||
on:focusin | ||
on:focusout | ||
on:pointerdown | ||
on:pointerleave | ||
on:pointermove | ||
> | ||
{#if affix} | ||
<svelte:component this={affix} class="size-4" aria-hidden="true" /> | ||
{/if} | ||
<slot /> | ||
{#if suffix} | ||
<svelte:component this={suffix} class="ml-auto size-4" aria-hidden="true" /> | ||
{/if} | ||
</ContextMenuPrimitive.Item> |
23 changes: 23 additions & 0 deletions
23
src/lib/components/ui/context-menu/context-menu-label.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,23 @@ | ||
<script lang="ts"> | ||
import { cn } from '$lib/utils.js'; | ||
import { ContextMenu as ContextMenuPrimitive } from 'bits-ui'; | ||
type $$Props = ContextMenuPrimitive.LabelProps & { | ||
inset?: boolean; | ||
}; | ||
let className: $$Props['class'] = undefined; | ||
export let inset: $$Props['inset'] = undefined; | ||
export { className as class }; | ||
</script> | ||
|
||
<ContextMenuPrimitive.Label | ||
class={cn( | ||
'inline-flex h-10 items-center px-2 text-sm font-semibold text-gray-1000', | ||
inset && 'pl-8', | ||
className | ||
)} | ||
{...$$restProps} | ||
> | ||
<slot /> | ||
</ContextMenuPrimitive.Label> |
11 changes: 11 additions & 0 deletions
11
src/lib/components/ui/context-menu/context-menu-radio-group.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,11 @@ | ||
<script lang="ts"> | ||
import { ContextMenu as ContextMenuPrimitive } from 'bits-ui'; | ||
type $$Props = ContextMenuPrimitive.RadioGroupProps; | ||
export let value: $$Props['value'] = undefined; | ||
</script> | ||
|
||
<ContextMenuPrimitive.RadioGroup {...$$restProps} bind:value> | ||
<slot /> | ||
</ContextMenuPrimitive.RadioGroup> |
35 changes: 35 additions & 0 deletions
35
src/lib/components/ui/context-menu/context-menu-radio-item.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,35 @@ | ||
<script lang="ts"> | ||
import { Icons } from '$lib/assets/icons'; | ||
import { cn } from '$lib/utils.js'; | ||
import { ContextMenu as ContextMenuPrimitive } from 'bits-ui'; | ||
type $$Props = ContextMenuPrimitive.RadioItemProps; | ||
type $$Events = ContextMenuPrimitive.RadioItemEvents; | ||
let className: $$Props['class'] = undefined; | ||
export let value: ContextMenuPrimitive.RadioItemProps['value']; | ||
export { className as class }; | ||
</script> | ||
|
||
<ContextMenuPrimitive.RadioItem | ||
class={cn( | ||
'relative flex h-10 cursor-pointer select-none items-center rounded-md pl-8 pr-2 text-sm outline-none data-[disabled]:cursor-default data-[highlighted]:bg-gray-200', | ||
className | ||
)} | ||
{value} | ||
{...$$restProps} | ||
on:click | ||
on:keydown | ||
on:focusin | ||
on:focusout | ||
on:pointerdown | ||
on:pointerleave | ||
on:pointermove | ||
> | ||
<span class="absolute left-2 flex size-3.5 items-center justify-center"> | ||
<ContextMenuPrimitive.RadioIndicator> | ||
<Icons.Status class="size-3 fill-current" /> | ||
</ContextMenuPrimitive.RadioIndicator> | ||
</span> | ||
<slot /> | ||
</ContextMenuPrimitive.RadioItem> |
14 changes: 14 additions & 0 deletions
14
src/lib/components/ui/context-menu/context-menu-separator.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,14 @@ | ||
<script lang="ts"> | ||
import { cn } from '$lib/utils.js'; | ||
import { ContextMenu as ContextMenuPrimitive } from 'bits-ui'; | ||
type $$Props = ContextMenuPrimitive.SeparatorProps; | ||
let className: $$Props['class'] = undefined; | ||
export { className as class }; | ||
</script> | ||
|
||
<ContextMenuPrimitive.Separator | ||
class={cn('-mx-1 my-1 h-px bg-gray-400', className)} | ||
{...$$restProps} | ||
/> |
13 changes: 13 additions & 0 deletions
13
src/lib/components/ui/context-menu/context-menu-shortcut.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,13 @@ | ||
<script lang="ts"> | ||
import { cn } from '$lib/utils.js'; | ||
import type { HTMLAttributes } from 'svelte/elements'; | ||
type $$Props = HTMLAttributes<HTMLSpanElement>; | ||
let className: $$Props['class'] = undefined; | ||
export { className as class }; | ||
</script> | ||
|
||
<span class={cn('ml-auto text-xs tracking-widest text-gray-700', className)} {...$$restProps}> | ||
<slot /> | ||
</span> |
29 changes: 29 additions & 0 deletions
29
src/lib/components/ui/context-menu/context-menu-sub-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,29 @@ | ||
<script lang="ts"> | ||
import { cn, flyAndScale } from '$lib/utils.js'; | ||
import { ContextMenu as ContextMenuPrimitive } from 'bits-ui'; | ||
type $$Props = ContextMenuPrimitive.SubContentProps; | ||
let className: $$Props['class'] = undefined; | ||
export let transition: $$Props['transition'] = flyAndScale; | ||
export let transitionConfig: $$Props['transitionConfig'] = { | ||
x: -10, | ||
y: 0 | ||
}; | ||
export { className as class }; | ||
</script> | ||
|
||
<ContextMenuPrimitive.SubContent | ||
{transition} | ||
{transitionConfig} | ||
class={cn( | ||
'z-50 min-w-[10rem] overflow-hidden rounded-xl bg-background-100 p-2 text-sm text-gray-1000 shadow-shadow-menu focus:outline-none', | ||
className | ||
)} | ||
{...$$restProps} | ||
on:keydown | ||
on:focusout | ||
on:pointermove | ||
> | ||
<slot /> | ||
</ContextMenuPrimitive.SubContent> |
32 changes: 32 additions & 0 deletions
32
src/lib/components/ui/context-menu/context-menu-sub-trigger.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,32 @@ | ||
<script lang="ts"> | ||
import { Icons } from '$lib/assets/icons'; | ||
import { cn } from '$lib/utils.js'; | ||
import { ContextMenu as ContextMenuPrimitive } from 'bits-ui'; | ||
type $$Props = ContextMenuPrimitive.SubTriggerProps & { | ||
inset?: boolean; | ||
}; | ||
type $$Events = ContextMenuPrimitive.SubTriggerEvents; | ||
let className: $$Props['class'] = undefined; | ||
export let inset: $$Props['inset'] = undefined; | ||
export { className as class }; | ||
</script> | ||
|
||
<ContextMenuPrimitive.SubTrigger | ||
class={cn( | ||
'flex h-10 cursor-pointer select-none items-center rounded-md px-2 text-sm outline-none data-[highlighted]:bg-gray-200 data-[state=open]:bg-gray-200', | ||
inset && 'pl-8', | ||
className | ||
)} | ||
{...$$restProps} | ||
on:click | ||
on:keydown | ||
on:focusin | ||
on:focusout | ||
on:pointerleave | ||
on:pointermove | ||
> | ||
<slot /> | ||
<Icons.ChevronRight class="ml-auto size-4" /> | ||
</ContextMenuPrimitive.SubTrigger> |
Oops, something went wrong.