From b176836617cd454d9f08d3b1cc1467ab0ca7cd66 Mon Sep 17 00:00:00 2001 From: Jerry_wu <409187100@qq.com> Date: Tue, 3 Dec 2024 11:06:49 +0800 Subject: [PATCH] switch --- apps/website/src/routes/docs/styled/menu.md | 1 + .../src/routes/docs/styled/switch/index.mdx | 47 ++++++++++++++++++- .../setup-tailwind-generator.spec.ts.snap | 16 +++++-- 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/apps/website/src/routes/docs/styled/menu.md b/apps/website/src/routes/docs/styled/menu.md index 0945d72aa..c044156fd 100644 --- a/apps/website/src/routes/docs/styled/menu.md +++ b/apps/website/src/routes/docs/styled/menu.md @@ -38,3 +38,4 @@ - [Textarea](/docs/styled/textarea) - [Toggle](/docs/styled/toggle) - [ToggleGroup](/docs/styled/toggle-group) +- [Switch](/docs/styled/switch) diff --git a/apps/website/src/routes/docs/styled/switch/index.mdx b/apps/website/src/routes/docs/styled/switch/index.mdx index 22cf1caa3..6729a3c2c 100644 --- a/apps/website/src/routes/docs/styled/switch/index.mdx +++ b/apps/website/src/routes/docs/styled/switch/index.mdx @@ -1,5 +1,48 @@ --- -title: Qwik UI | Styled Radio Group Component +title: Qwik UI | Styled Switch Component --- -sdsds +import { statusByComponent } from '~/_state/component-statuses'; + + + +# Switch + +The Switch component allows users to toggle between two states, such as on/off or enabled/disabled. It is designed to be accessible and visually appealing, providing a smooth user experience. + + + +## Installation + +To install the Switch component, run the following command in your terminal: + +```sh +qwik-ui add switch +``` + +Alternatively, you can copy and paste the component code directly into your project. + +## Usage + +Here’s how to use the Switch component in your application: + +```tsx +import { component$, useSignal } from '@builder.io/qwik'; +import { Switch } from '~/components/ui'; + +export default component$(() => { + const checked = useSignal(false); + return ( + + + Toggle Option + + ); +}); +``` + +## Examples + +### Checked + + diff --git a/packages/cli/src/generators/setup-tailwind/__snapshots__/setup-tailwind-generator.spec.ts.snap b/packages/cli/src/generators/setup-tailwind/__snapshots__/setup-tailwind-generator.spec.ts.snap index 01fa9bb57..7b9d32ff9 100644 --- a/packages/cli/src/generators/setup-tailwind/__snapshots__/setup-tailwind-generator.spec.ts.snap +++ b/packages/cli/src/generators/setup-tailwind/__snapshots__/setup-tailwind-generator.spec.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Setup Tailwind generator +exports[`Setup Tailwind generator GIVEN no options are passed THEN it should generate "simple" style with primary color "cyan-600", base color "slate" and border-radius 0 1`] = ` "@tailwind components; @@ -89,7 +89,7 @@ html { " `; -exports[`Setup Tailwind generator +exports[`Setup Tailwind generator GIVEN style is "brutalist" and primary color is "red-600" and border-radius is 1 THEN it should generate the correct theme 1`] = ` "@tailwind components; @@ -172,7 +172,7 @@ html { " `; -exports[`Setup Tailwind generator +exports[`Setup Tailwind generator GIVEN global.css and tailwind config exist in commonjs format THEN it should generate the proper tailwind config values 1`] = ` "const plugin = require('tailwindcss/plugin'); @@ -223,6 +223,8 @@ module.exports = { ring: 'hsl(var(--ring))', background: 'hsl(var(--background))', foreground: 'hsl(var(--foreground))', + switchInactive: 'hsl(var(--switch-track-color-inactive))', + switchThumb: 'hsl(var(--switch-thumb-color-highlight))', primary: { DEFAULT: 'hsl(var(--primary))', foreground: 'hsl(var(--primary-foreground))', @@ -308,7 +310,7 @@ module.exports = { " `; -exports[`Setup Tailwind generator +exports[`Setup Tailwind generator GIVEN tailwind config exist in esm format WHEN running the generator THEN it should generate the proper tailwind config values 1`] = ` @@ -358,6 +360,8 @@ export default { ring: 'hsl(var(--ring))', background: 'hsl(var(--background))', foreground: 'hsl(var(--foreground))', + switchInactive: 'hsl(var(--switch-track-color-inactive))', + switchThumb: 'hsl(var(--switch-thumb-color-highlight))', primary: { DEFAULT: 'hsl(var(--primary))', foreground: 'hsl(var(--primary-foreground))', @@ -443,7 +447,7 @@ export default { " `; -exports[`Setup Tailwind generator +exports[`Setup Tailwind generator GIVEN tailwind config has already a plugins array THEN it should add the plugin with the right plugin and import 1`] = ` "import plugin from 'tailwindcss/plugin'; @@ -492,6 +496,8 @@ export default { ring: 'hsl(var(--ring))', background: 'hsl(var(--background))', foreground: 'hsl(var(--foreground))', + switchInactive: 'hsl(var(--switch-track-color-inactive))', + switchThumb: 'hsl(var(--switch-thumb-color-highlight))', primary: { DEFAULT: 'hsl(var(--primary))', foreground: 'hsl(var(--primary-foreground))',