diff --git a/apps/website/src/components/menu/menu.tsx b/apps/website/src/components/menu/menu.tsx index 77eec60c5..2adbd8261 100644 --- a/apps/website/src/components/menu/menu.tsx +++ b/apps/website/src/components/menu/menu.tsx @@ -27,6 +27,7 @@ export const Menu = component$(({ onClose$ }) => { }, { label: 'Drawer', path: `/docs/${appState.theme.toLowerCase()}/drawer` }, { label: 'Rating', path: `/docs/${appState.theme.toLowerCase()}/rating` }, + { label: 'Radio', path: `/docs/${appState.theme.toLowerCase()}/radio` }, { label: 'Popover', path: `/docs/${appState.theme.toLowerCase()}/popover` }, { label: 'Select', path: `/docs/${appState.theme.toLowerCase()}/select` }, { label: 'Tabs', path: `/docs/${appState.theme.toLowerCase()}/tabs` }, diff --git a/apps/website/src/routes/docs/daisy/radio/index.tsx b/apps/website/src/routes/docs/daisy/radio/index.tsx new file mode 100644 index 000000000..26e64f53d --- /dev/null +++ b/apps/website/src/routes/docs/daisy/radio/index.tsx @@ -0,0 +1,102 @@ +import { component$, useSignal, useStylesScoped$ } from '@builder.io/qwik'; +import { Radio } from '@qwik-ui/theme-daisy'; + +export default component$(() => { + useStylesScoped$(` + .container { width: 300px } Accordion {border: 1px solid white} + .panel { + display: flex; + gap: 8px; + flex-wrap: wrap; + } + `); + + let radioValue = useSignal('primary'); + return ( + <> +
+

This is the documentation for the Radio

+
+

Selected vatiant: {radioValue.value}

+
+ { + radioValue.value = e.target.value; + }} + checked + /> + { + radioValue.value = e.target.value; + }} + /> + { + radioValue.value = e.target.value; + }} + /> + { + radioValue.value = e.target.value; + }} + /> + { + radioValue.value = e.target.value; + }} + /> + { + radioValue.value = e.target.value; + }} + /> + { + radioValue.value = e.target.value; + }} + /> +
+ +

Primary Example

+
+ + +
+
+
+ + ); +}); diff --git a/apps/website/src/routes/docs/headless/radio/index.tsx b/apps/website/src/routes/docs/headless/radio/index.tsx new file mode 100644 index 000000000..c946c5244 --- /dev/null +++ b/apps/website/src/routes/docs/headless/radio/index.tsx @@ -0,0 +1,45 @@ +import { component$, useSignal } from '@builder.io/qwik'; +import { Radio } from '@qwik-ui/headless'; + +export default component$(() => { + let radioValue = useSignal('first'); + + return ( +
+

This is the documentation for the Radio

+

Basic Example

+
+ + + +
+ +

Change value Example

+

Selected radio: {radioValue.value}

+
+ { + radioValue.value = e.target.value; + }} + /> + { + radioValue.value = e.target.value; + }} + /> + { + radioValue.value = e.target.value; + }} + /> +
+
+ ); +}); diff --git a/packages/daisy/src/components/ratio/daisy.config.ts b/packages/daisy/src/components/ratio/daisy.config.ts new file mode 100644 index 000000000..c83888c2e --- /dev/null +++ b/packages/daisy/src/components/ratio/daisy.config.ts @@ -0,0 +1,11 @@ +export const daisyConfig = { + variants: { + accent: 'radio-accent', + error: 'radio-error', + info: 'radio-info', + primary: 'radio-primary', + secondary: 'radio-secondary', + success: 'radio-success', + warning: 'radio-warning', + }, +}; diff --git a/packages/daisy/src/components/ratio/radio.tsx b/packages/daisy/src/components/ratio/radio.tsx new file mode 100644 index 000000000..593cb0167 --- /dev/null +++ b/packages/daisy/src/components/ratio/radio.tsx @@ -0,0 +1,51 @@ +import { + component$, + PropFunction, + QwikIntrinsicElements, + QwikChangeEvent, +} from '@builder.io/qwik'; +import { Radio as HeadlessRadio } from '@qwik-ui/headless'; +import { clsq } from '@qwik-ui/shared'; +import { daisyConfig } from './daisy.config'; + +export type HTMLRadioProps = QwikIntrinsicElements['input']; + +export type DaisyRadioProps = { + variant?: DaisyRadioVariants; + name?: string; + value?: string; + onChange$?: PropFunction<(evt: QwikChangeEvent) => void>; +}; + +export type DaisyRadioVariants = + | 'primary' + | 'secondary' + | 'accent' + | 'info' + | 'success' + | 'warning' + | 'error'; + +export type RadioProps = HTMLRadioProps & DaisyRadioProps; + +export const Radio = component$((props: RadioProps) => { + const { + variant = 'primary', + class: classNames, + value = 'first', + name = 'radio-1', + ...rest + } = props; + + const { variants } = daisyConfig; + + return ( + + ); +}); diff --git a/packages/daisy/src/index.ts b/packages/daisy/src/index.ts index a752d328d..f769362ef 100644 --- a/packages/daisy/src/index.ts +++ b/packages/daisy/src/index.ts @@ -11,3 +11,4 @@ export * from './components/tabs'; export * from './components/toast/toast'; export * from './components/toggle/toggle'; export * from './components/tooltip/tooltip'; +export * from './components/ratio/radio'; diff --git a/packages/headless/src/components/radio/radio.tsx b/packages/headless/src/components/radio/radio.tsx new file mode 100644 index 000000000..a29d9885c --- /dev/null +++ b/packages/headless/src/components/radio/radio.tsx @@ -0,0 +1,7 @@ +import { component$, QwikIntrinsicElements } from '@builder.io/qwik'; + +export type RadioProps = QwikIntrinsicElements['input']; + +export const Radio = component$((props: RadioProps) => ( + +)); diff --git a/packages/headless/src/index.ts b/packages/headless/src/index.ts index 272160f47..84bc74e50 100644 --- a/packages/headless/src/index.ts +++ b/packages/headless/src/index.ts @@ -13,3 +13,4 @@ export * from './components/toast/toast'; export * from './components/toggle/toggle'; export * from './components/tooltip/tooltip'; export * as Select from './components/select/select'; +export * from './components/radio/radio';