sigma-ui
Version:
CLI for SIGMA-UI components.
16 lines • 2.54 kB
JSON
{
"name": "switch",
"dependencies": [],
"registryDependencies": [],
"files": [
{
"name": "Switch.vue",
"content": "<script setup lang=\"ts\">\nimport {\n SwitchRoot,\n type SwitchRootEmits,\n type SwitchRootProps,\n SwitchThumb,\n useForwardPropsEmits,\n\n} from 'reka-ui';\n\nconst props = defineProps<SwitchRootProps>();\n\nconst emits = defineEmits<SwitchRootEmits>();\n\nconst forwarded = useForwardPropsEmits(props, emits);\n</script>\n\n<template>\n <SwitchRoot\n v-bind=\"forwarded\"\n class=\"sigma-ui-switch\"\n >\n <SwitchThumb class=\"sigma-ui-switch__thumb\" />\n </SwitchRoot>\n</template>\n\n<style>\n.sigma-ui-switch {\n display: inline-flex;\n width: 2.75rem;\n height: 1.5rem;\n flex-shrink: 0;\n align-items: center;\n border: 2px solid transparent;\n border-radius: var(--radius-full);\n cursor: pointer;\n transition-duration: 150ms;\n transition-property: color, background-color, border-color;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.sigma-ui-switch:focus-visible {\n box-shadow: 0 0 0 2px hsl(var(--ring)), 0 0 0 4px hsl(var(--background));\n outline: none;\n}\n\n.sigma-ui-switch:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n}\n\n.sigma-ui-switch[data-state=\"checked\"] {\n background-color: hsl(var(--primary));\n}\n\n.sigma-ui-switch[data-state=\"unchecked\"] {\n background-color: hsl(var(--input));\n}\n\n.sigma-ui-switch__thumb {\n display: block;\n width: 1.25rem;\n height: 1.25rem;\n border-radius: var(--radius-full);\n animation: none;\n background-color: hsl(var(--background));\n box-shadow: 0 2px 4px rgb(0 0 0 / 10%);\n pointer-events: none;\n transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.sigma-ui-switch__thumb[data-state=\"checked\"] {\n animation: thumb-motion-blur-in 150ms cubic-bezier(0.4, 0, 0.2, 1);\n transform: translateX(1.25rem);\n}\n\n.sigma-ui-switch__thumb[data-state=\"unchecked\"] {\n animation: thumb-motion-blur-out 150ms cubic-bezier(0.4, 0, 0.2, 1);\n transform: translateX(0);\n}\n\n@keyframes thumb-motion-blur-in {\n 0% {\n filter: blur(0);\n }\n\n 50% {\n filter: blur(2px);\n }\n\n 100% {\n filter: blur(0);\n }\n}\n\n@keyframes thumb-motion-blur-out {\n 0% {\n filter: blur(0);\n }\n\n 50% {\n filter: blur(2px);\n }\n\n 100% {\n filter: blur(0);\n }\n}\n</style>\n"
},
{
"name": "index.ts",
"content": "export { default as Switch } from './Switch.vue';\n"
}
],
"type": "components:ui"
}