Skip to content

Commit

Permalink
feat: checkbox template
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Sep 19, 2021
1 parent ee97359 commit 486e4ec
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
18 changes: 18 additions & 0 deletions components/checkbox/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 Checkbox = ({ checked = false, disabled = false }) =>
`<input type="checkbox"${checked ? ' checked' : ''} class="${clsx(
'utrecht-checkbox',
checked && 'utrecht-checkbox--checked',
disabled && 'utrecht-checkbox--disabled',
)}">`;
59 changes: 59 additions & 0 deletions components/checkbox/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, Checkbox } from "./bem";

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

# Checkbox Component

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

<ArgsTable story="Checkbox" />

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

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

0 comments on commit 486e4ec

Please sign in to comment.