diff --git a/platforms/metagram/src/lib/ui/Input/Input.stories.ts b/platforms/metagram/src/lib/ui/Input/Input.stories.ts index 650064ca..5b273f1b 100644 --- a/platforms/metagram/src/lib/ui/Input/Input.stories.ts +++ b/platforms/metagram/src/lib/ui/Input/Input.stories.ts @@ -1,54 +1,62 @@ -import { Input } from '..'; +import { Input } from ".."; export default { - title: 'UI/Input', - component: Input, - tags: ['autodocs'], - render: (args: { type: string; placeholder: string }) => ({ - Component: Input, - props: args - }) + title: "UI/Input", + component: Input, + tags: ["autodocs"], + render: (args: { type: string; placeholder: string }) => ({ + Component: Input, + props: args, + }), }; export const Text = { - args: { - type: 'text', - placeholder: 'Joe Biden' - } + args: { + type: "text", + placeholder: "Joe Biden", + }, }; export const Tel = { - args: { - type: 'tel', - placeholder: '987654321' - } + args: { + type: "tel", + placeholder: "987654321", + }, }; export const NumberInput = { - args: { - type: 'number', - placeholder: 'Enter something' - } + args: { + type: "number", + placeholder: "Enter something", + }, }; export const Email = { - args: { - type: 'email', - placeholder: 'example@email.com' - } + args: { + type: "email", + placeholder: "example@email.com", + }, }; export const Invalid = { - args: { - type: 'email', - placeholder: 'Invalid email', - value: 'not-an-email' - } + args: { + type: "email", + placeholder: "Invalid email", + value: "not-an-email", + }, }; export const Password = { - args: { - type: 'password', - placeholder: 'Please enter password' - } + args: { + type: "password", + placeholder: "Please enter password", + }, +}; + +export const Radio = { + args: { + type: "radio", + value: "option1", + name: "option-1", + }, }; diff --git a/platforms/metagram/src/lib/ui/Input/Input.svelte b/platforms/metagram/src/lib/ui/Input/Input.svelte index 4fec6341..d3862fd5 100644 --- a/platforms/metagram/src/lib/ui/Input/Input.svelte +++ b/platforms/metagram/src/lib/ui/Input/Input.svelte @@ -17,17 +17,16 @@ ...restProps }: IInputProps = $props(); - const cbase = $derived( - 'w-full bg-grey py-3.5 px-6 text-[15px] text-black-800 font-geist font-normal placeholder:text-black-600 rounded-4xl outline-0 border border-transparent invalid:border-red invalid:text-red focus:invalid:text-black-800 focus:invalid:border-transparent' - ); + const cbase = + 'w-full bg-grey py-3.5 px-6 text-[15px] text-black-800 font-geist font-normal placeholder:text-black-600 rounded-4xl outline-0 border border-transparent invalid:border-red invalid:text-red focus:invalid:text-black-800 focus:invalid:border-transparent'; diff --git a/platforms/metagram/src/lib/ui/InputRadio/InputRadio.stories.ts b/platforms/metagram/src/lib/ui/InputRadio/InputRadio.stories.ts new file mode 100644 index 00000000..4dbe6af3 --- /dev/null +++ b/platforms/metagram/src/lib/ui/InputRadio/InputRadio.stories.ts @@ -0,0 +1,19 @@ +import { InputRadio } from ".."; + +export default { + title: "UI/InputRadio", + component: InputRadio, + tags: ["autodocs"], + render: (args: { type: string; placeholder: string }) => ({ + Component: InputRadio, + props: args, + }), +}; + +export const Radio = { + args: { + type: "radio", + value: "option1", + name: "option-1", + }, +}; diff --git a/platforms/metagram/src/lib/ui/InputRadio/InputRadio.svelte b/platforms/metagram/src/lib/ui/InputRadio/InputRadio.svelte new file mode 100644 index 00000000..522c30d0 --- /dev/null +++ b/platforms/metagram/src/lib/ui/InputRadio/InputRadio.svelte @@ -0,0 +1,53 @@ + + + + + radioElement?.click()} + onkeydown={(e) => { + if (e.key === ' ' || e.key === 'Enter') { + e.preventDefault(); + radioElement?.click(); + } + }} +> + {#if selected === value} + + {/if} + diff --git a/platforms/metagram/src/lib/ui/index.ts b/platforms/metagram/src/lib/ui/index.ts index d28618f9..dfc0602f 100644 --- a/platforms/metagram/src/lib/ui/index.ts +++ b/platforms/metagram/src/lib/ui/index.ts @@ -1,7 +1,8 @@ -export { default as Button } from './Button/Button.svelte'; -export { default as Avatar } from './Avatar/Avatar.svelte'; -export { default as Input } from './Input/Input.svelte'; -export { default as Select } from './Select/Select.svelte'; -export { default as Label } from './Label/Label.svelte'; -export { default as Toggle } from './Toggle/Toggle.svelte'; -export { default as Helper } from './Helper/Helper.svelte'; +export { default as Button } from "./Button/Button.svelte"; +export { default as Avatar } from "./Avatar/Avatar.svelte"; +export { default as Input } from "./Input/Input.svelte"; +export { default as Select } from "./Select/Select.svelte"; +export { default as Label } from "./Label/Label.svelte"; +export { default as Toggle } from "./Toggle/Toggle.svelte"; +export { default as Helper } from "./Helper/Helper.svelte"; +export { default as InputRadio } from "./InputRadio/InputRadio.svelte";