Skip to content

Commit 4ab3ddd

Browse files
committed
add SfRadio
1 parent 3ada26c commit 4ab3ddd

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { component$ } from '@builder.io/qwik';
2+
import { SfRadioProps } from './types';
3+
4+
export const SfRadio = component$<SfRadioProps>(({ invalid, ref, class: _class, disabled,onChange$, ...attributes }) => {
5+
return (
6+
<input
7+
{...(ref ? { ref } : {})}
8+
type="radio"
9+
disabled={disabled}
10+
class={`
11+
h-5 w-5 border-2 p-[3px] bg-clip-content rounded-full appearance-none cursor-pointer focus-visible:outline focus-visible:outline-offset disabled:border-disabled-500 disabled:cursor-not-allowed disabled:checked:bg-disabled-500 disabled:checked:border-disabled-500
12+
${
13+
invalid && !disabled
14+
? 'border-negative-700 checked:bg-negative-700 hover:border-negative-800 hover:checked:bg-negative-800 active:border-negative-900 active:checked:bg-negative-900'
15+
: 'border-neutral-500 active:border-primary-900 hover:border-primary-700 checked:bg-primary-700 checked:border-primary-700 hover:checked:bg-primary-800 hover:checked:border-primary-800 active:checked:bg-primary-900 active:checked:border-primary-900'
16+
}
17+
${_class}
18+
`}
19+
onChange$={onChange$}
20+
{...attributes}
21+
/>
22+
);
23+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './types';
2+
3+
export { SfRadio } from './SfRadio';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {
2+
PropFunction,
3+
QwikChangeEvent,
4+
QwikIntrinsicElements,
5+
Signal,
6+
} from '@builder.io/qwik';
7+
8+
export type SfRadioProps = Omit<QwikIntrinsicElements['input'], 'children'> & {
9+
class?: string;
10+
ref?: Signal<Element | undefined>;
11+
invalid?: boolean;
12+
onChange$: PropFunction<(event: QwikChangeEvent<HTMLInputElement>) => void>;
13+
};

0 commit comments

Comments
 (0)