Skip to content

Commit

Permalink
feat: radio button template
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Sep 19, 2021
1 parent 48c5a17 commit a623804
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
18 changes: 18 additions & 0 deletions components/radio-button/bem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @license EUPL-1.2
* Copyright (c) 2021 Robbert Broersma
*/

import clsx from 'clsx';

export const defaultArgs = {
checked: false,
disabled: false,
};

export const RadioButton = ({ checked = false, disabled = false }) =>
`<input type="radio"${checked ? ' checked' : ''}${disabled ? ' disabled' : ''} class="${clsx(
'utrecht-radio-button',
checked && 'utrecht-radio-button--checked',
disabled && 'utrecht-radio-button--disabled',
)}">`;
4 changes: 4 additions & 0 deletions components/radio-button/bem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
margin-inline-start: 0;
}

/* stylelint-disable-next-line block-no-empty */
.utrecht-radio-button--checked {
}

.utrecht-radio-button--disabled {
cursor: var(--utrecht-action-disabled-cursor);
}
59 changes: 59 additions & 0 deletions components/radio-button/bem.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!--
@license EUPL-1.2
Copyright (c) 2021 Robbert Broersma
-->

import { Meta, Story, Canvas, ArgsTable } from "@storybook/addon-docs";
import { defaultArgs, RadioButton } from "./bem";

<Meta
title="CSS Component/Radio Button"
argTypes={{}}
parameters={{
docs: {
transformSource: (_src, { args }) => RadioButton(args),
},
status: {
type: "WORK IN PROGRESS",
},
}}
/>

# Radio Button Component

<Canvas>
<Story
name="Radio Button"
args={{
...defaultArgs,
}}
>
{RadioButton.bind({})}
</Story>
</Canvas>

<ArgsTable story="Radio Button" />

<Canvas>
<Story
name="Disabled radio button"
args={{
...defaultArgs,
disabled: true,
}}
>
{RadioButton.bind({})}
</Story>
</Canvas>

<Canvas>
<Story
name="Checked radio button"
args={{
...defaultArgs,
checked: true,
}}
>
{RadioButton.bind({})}
</Story>
</Canvas>

0 comments on commit a623804

Please sign in to comment.