mirror of
https://github.com/versia-pub/frontend.git
synced 2026-03-13 19:49:16 +01:00
feat: ✨ Make composer work again
This commit is contained in:
parent
4dfbd845d3
commit
294740c97f
18 changed files with 571 additions and 32 deletions
45
components/ui/toggle/Toggle.vue
Normal file
45
components/ui/toggle/Toggle.vue
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<script setup lang="ts">
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
Toggle,
|
||||
type ToggleEmits,
|
||||
type ToggleProps,
|
||||
useForwardPropsEmits,
|
||||
} from "radix-vue";
|
||||
import { type HTMLAttributes, computed } from "vue";
|
||||
import { type ToggleVariants, toggleVariants } from ".";
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<
|
||||
ToggleProps & {
|
||||
class?: HTMLAttributes["class"];
|
||||
variant?: ToggleVariants["variant"];
|
||||
size?: ToggleVariants["size"];
|
||||
}
|
||||
>(),
|
||||
{
|
||||
variant: "default",
|
||||
size: "default",
|
||||
disabled: false,
|
||||
},
|
||||
);
|
||||
|
||||
const emits = defineEmits<ToggleEmits>();
|
||||
|
||||
const delegatedProps = computed(() => {
|
||||
const { class: _, size, variant, ...delegated } = props;
|
||||
|
||||
return delegated;
|
||||
});
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Toggle
|
||||
v-bind="forwarded"
|
||||
:class="cn(toggleVariants({ variant, size }), props.class)"
|
||||
>
|
||||
<slot />
|
||||
</Toggle>
|
||||
</template>
|
||||
27
components/ui/toggle/index.ts
Normal file
27
components/ui/toggle/index.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { type VariantProps, cva } from "class-variance-authority";
|
||||
|
||||
export { default as Toggle } from "./Toggle.vue";
|
||||
|
||||
export const toggleVariants = cva(
|
||||
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-transparent",
|
||||
outline:
|
||||
"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground",
|
||||
},
|
||||
size: {
|
||||
default: "h-10 px-3",
|
||||
sm: "h-9 px-2.5",
|
||||
lg: "h-11 px-5",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
export type ToggleVariants = VariantProps<typeof toggleVariants>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue