Skip to content

Commit

Permalink
feat: extra form-label tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Aug 21, 2021
1 parent 03a061d commit 1b36c06
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/form-field-checkbox-group/bem.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const Template = ({
options,
groupLabelId = "group-label",
}) => `<div class="utrecht-form-field-checkbox-group utrecht-form-field-checkbox-group--distanced" role="group" aria-labelledby="${groupLabelId}">
<div class="utrecht-form-field-checkbox-group__label" id="${groupLabelId}">${label}</div>
<div class="utrecht-form-field-checkbox-group__label utrecht-form-label" id="${groupLabelId}">${label}</div>
${options
.map((option, index) => ({
...option,
Expand Down
8 changes: 4 additions & 4 deletions components/form-field-radio-group/bem.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import "../radio-button/bem.css";
import "../form-label/bem.css";
export const Template = ({ label = "", name = "" }) =>
`<div class="utrecht-form-field-radio-group utrecht-form-field-radio-group--distanced" role="radiogroup" aria-labelledby="id-9e42cd3e">
<div class="utrecht-form-field-radio-group__label" id="id-9e42cd3e">${label}</div>
<div class="utrecht-form-field-radio-group__label utrecht-form-label" id="id-9e42cd3e">${label}</div>
<div class="utrecht-form-field-radio utrecht-form-field-radio--distanced">
<input type="radio" name="${name}" class="utrecht-form-field-radio__input utrecht-radio-button" id="option-1">
<label class="utrecht-form-field-radio__label" for="option-1">Option 1</label>
<label class="utrecht-form-field-radio__label utrecht-form-label utrecht-form-label--radio" for="option-1">Option 1</label>
</div>
<div class="utrecht-form-field-radio utrecht-form-field-radio--distanced">
<input type="radio" name="${name}" class="utrecht-form-field-radio__input utrecht-radio-button" id="option-2">
<label class="utrecht-form-field-radio__label" for="option-2">Option 2</label>
<label class="utrecht-form-field-radio__label utrecht-form-label utrecht-form-label--radio" for="option-2">Option 2</label>
</div>
<div class="utrecht-form-field-radio utrecht-form-field-radio--distanced">
<input type="radio" name="${name}" class="utrecht-form-field-radio__input utrecht-radio-button" id="option-3">
<label class="utrecht-form-field-radio__label" for="option-3">Option 3</label>
<label class="utrecht-form-field-radio__label utrecht-form-label utrecht-form-label--radio" for="option-3">Option 3</label>
</div>
</div>`;

Expand Down
11 changes: 11 additions & 0 deletions components/form-label/bem.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@
*/

.utrecht-form-label {
color: var(--utrecht-form-label-color);
font-size: var(--utrecht-form-label-font-size);
font-weight: var(--utrecht-form-label-font-weight);
}

.utrecht-form-label--checkbox {
color: var(--utrecht-form-label-checkbox-color, var(--utrecht-form-label-color));
font-weight: var(--utrecht-form-label-checkbox-font-weight, var(--utrecht-form-label-font-weight));
}

.utrecht-form-label--checked {
font-weight: var(--utrecht-form-label-checked-font-weight, var(--utrecht-form-label-font-weight));
}

.utrecht-form-label--disabled {
font-weight: var(--utrecht-form-label-disabled-color, var(--utrecht-form-label-color));
}

.utrecht-form-label--radio {
color: var(--utrecht-form-label-checkbox-color, var(--utrecht-form-label-color));
font-weight: var(--utrecht-form-label-radio-font-weight, var(--utrecht-form-label-font-weight));
}
65 changes: 63 additions & 2 deletions components/form-label/bem.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@ Copyright (c) 2021 Robbert Broersma
import { Meta, Story, Canvas, ArgsTable } from "@storybook/addon-docs";
import clsx from "clsx";
import "./bem.css";
export const Template = ({ textContent = "", type = null }) =>

export const defaultArgs = {
checked: false,
disabled: false,
textContent: "",
type: null,
};

export const Template = ({ checked = false, disabled = false, textContent = "", type = null }) =>
`<span class="${clsx(
"utrecht-form-label",
type === "checkbox" && "utrecht-form-label--checkbox",
checked && "utrecht-form-label--checked",
disabled && "utrecht-form-label--disabled",
type === "radio" && "utrecht-form-label--radio"
)}">${textContent}</span>`;

Expand Down Expand Up @@ -44,6 +54,7 @@ Styling via the `.utrecht-form-label` class name:
<Story
name="Label"
args={{
...defaultArgs,
textContent: "Username",
}}
>
Expand All @@ -53,6 +64,22 @@ Styling via the `.utrecht-form-label` class name:

<ArgsTable story="Label" />

# Label for disabled input

Styling via the `.utrecht-form-label--disabled` class name:

<Canvas>
<Story
name="Label for disabled input"
args={{
disabled: true,
textContent: "Username",
}}
>
{Template.bind({})}
</Story>
</Canvas>

# Label for checkbox

Styling via the `.utrecht-form-label--checkbox` class name:
Expand All @@ -69,6 +96,23 @@ Styling via the `.utrecht-form-label--checkbox` class name:
</Story>
</Canvas>

# Label for checked checkbox

Styling via the `.utrecht-form-label--checked` class name:

<Canvas>
<Story
name="Label for checked checkbox"
args={{
checked: true,
textContent: "Username",
type: "checkbox",
}}
>
{Template.bind({})}
</Story>
</Canvas>

# Label for radio button

Styling via the `.utrecht-form-label--radio` class name:
Expand All @@ -77,7 +121,24 @@ Styling via the `.utrecht-form-label--radio` class name:
<Story
name="Label for radio button"
args={{
textContent: "Username",
textContent: "Option 1",
type: "radio",
}}
>
{Template.bind({})}
</Story>
</Canvas>

# Label for checked radio button

Styling via the `.utrecht-form-label--radio` and `.utrecht-form-label--checked` class names:

<Canvas>
<Story
name="Label for checked radio button"
args={{
checked: true,
textContent: "Option 1",
type: "radio",
}}
>
Expand Down
6 changes: 6 additions & 0 deletions components/form-label/block.style-dictionary.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"utrecht": {
"label": {
"color": {
"css": {
"syntax": "<color>",
"inherits": true
}
},
"font-weight": {
"css": {
"syntax": "<number>",
Expand Down
28 changes: 28 additions & 0 deletions components/form-label/modifier.style-dictionary.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,42 @@
"utrecht": {
"form-label": {
"checkbox": {
"color": {
"css": {
"syntax": "<color>",
"inherits": true
}
},
"font-weight": {
"css": {
"syntax": "<number>",
"inherits": true
}
}
},
"checked": {
"font-weight": {
"css": {
"syntax": "<number>",
"inherits": true
}
}
},
"disabled": {
"color": {
"css": {
"syntax": "<color>",
"inherits": true
}
}
},
"radio": {
"color": {
"css": {
"syntax": "<color>",
"inherits": true
}
},
"font-weight": {
"css": {
"syntax": "<number>",
Expand Down

0 comments on commit 1b36c06

Please sign in to comment.