Skip to content

Commit

Permalink
feat: add placeholder design tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Aug 21, 2021
1 parent 193545d commit 0d71278
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 11 deletions.
12 changes: 12 additions & 0 deletions components/textarea/bem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@
);
}

.utrecht-textarea__placeholder {
color: var(
--utrecht-textarea-placeholder-color,
var(--utrecht-form-input-placeholder-color, var(--utrecht-textarea-color, var(--utrecht-form-input-color)))
);
opacity: 100%;
}

.utrecht-textarea--html-textarea {
&:disabled {
@extend .utrecht-textarea--disabled;
Expand All @@ -106,4 +114,8 @@
&:read-only {
@extend .utrecht-textarea--read-only;
}

&::placeholder {
@extend .utrecht-textarea__placeholder;
}
}
14 changes: 14 additions & 0 deletions components/textarea/element.style-dictionary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"utrecht": {
"textarea": {
"placeholder": {
"color": {
"css": {
"syntax": "<color>",
"inherits": true
}
}
}
}
}
}
43 changes: 35 additions & 8 deletions components/textarea/html.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,23 @@ export const defaultArgs = {
invalid: false,
readOnly: false,
disabled: false,
placeholder: "",
required: false,
textContent: "",
};

export const Template = ({ invalid = false, readOnly = false, disabled = false, required = false, textContent = "" }) =>
export const Template = ({
invalid = false,
readOnly = false,
disabled = false,
placeholder = "",
required = false,
textContent = "",
}) =>
`<section class="utrecht-html">
<textarea${invalid ? ' aria-invalid="true"' : ""}${disabled ? " disabled" : ""}${required ? " required" : ""}${
readOnly ? " readonly" : ""
}>${textContent}</textarea>
<textarea${invalid ? ' aria-invalid="true"' : ""}${disabled ? " disabled" : ""}${
placeholder ? ` placeholder="${placeholder}"` : ""
}${required ? " required" : ""}${readOnly ? " readonly" : ""}>${textContent}</textarea>
</section>`;

<Meta
Expand All @@ -36,6 +44,10 @@ export const Template = ({ invalid = false, readOnly = false, disabled = false,
description: "Disabled",
control: "boolean",
},
placeholder: {
description: "Placeholder",
control: "text",
},
required: {
description: "Required",
control: "boolean",
Expand Down Expand Up @@ -73,7 +85,9 @@ Styling via the `<textarea>` element:

<ArgsTable story="Textarea" />

## Invalid
## States

### Invalid

<Canvas>
<Story
Expand All @@ -87,7 +101,7 @@ Styling via the `<textarea>` element:
</Story>
</Canvas>

## Disabled
### Disabled

<Canvas>
<Story
Expand All @@ -101,7 +115,7 @@ Styling via the `<textarea>` element:
</Story>
</Canvas>

## Read-only
### Read-only

<Canvas>
<Story
Expand All @@ -115,7 +129,7 @@ Styling via the `<textarea>` element:
</Story>
</Canvas>

## Required
### Required

<Canvas>
<Story
Expand All @@ -128,3 +142,16 @@ Styling via the `<textarea>` element:
{Template.bind({})}
</Story>
</Canvas>

## Placeholder

<Canvas>
<Story
name="Textarea with placeholder"
args={{
placeholder: "The Quick Brown Fox Jumps Over The Lazy Dog",
}}
>
{Template.bind({})}
</Story>
</Canvas>
12 changes: 12 additions & 0 deletions components/textbox/bem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@
);
}

.utrecht-textbox__placeholder {
color: var(
--utrecht-textbox-placeholder-color,
var(--utrecht-form-input-placeholder-color, var(--utrecht-textbox-color, var(--utrecht-form-input-color)))
);
opacity: 100%;
}

.utrecht-textbox--html-input {
&:disabled {
@extend .utrecht-textbox--disabled;
Expand All @@ -107,4 +115,8 @@
&:read-only {
@extend .utrecht-textbox--read-only;
}

&::placeholder {
@extend .utrecht-textbox__placeholder;
}
}
14 changes: 14 additions & 0 deletions components/textbox/element.style-dictionary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"utrecht": {
"textarea": {
"placeholder": {
"color": {
"css": {
"syntax": "<color>",
"inherits": true
}
}
}
}
}
}
27 changes: 24 additions & 3 deletions components/textbox/html.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ Copyright (c) 2021 Robbert Broersma

import { Meta, Story, Canvas, ArgsTable } from "@storybook/addon-docs";
import "./html.scss";

export const Template = ({
autoComplete = null,
disabled = false,
invalid = false,
min = "",
max = "",
pattern = "",
placeholder = "",
readOnly = false,
required = false,
type = "text",
Expand All @@ -20,9 +22,11 @@ export const Template = ({
`<div class="utrecht-html">
<input${type ? ` type="${type}"` : ""}${invalid ? ' aria-invalid="true"' : ""}${disabled ? " disabled" : ""}${
min !== "" ? ` min="${min}"` : ""
}${max !== "" ? ` max="${max}"` : ""}${pattern ? ` pattern="${pattern}"` : ""}${required ? " required" : ""}${
readOnly ? " readonly" : ""
} value="${value}"${autoComplete ? ` autocomplete="${autoComplete}"` : ""}>
}${max !== "" ? ` max="${max}"` : ""}${pattern ? ` pattern="${pattern}"` : ""}${
placeholder ? ` placeholder="${placeholder}"` : ""
}${required ? " required" : ""}${readOnly ? " readonly" : ""} value="${value}"${
autoComplete ? ` autocomplete="${autoComplete}"` : ""
}>
</div>`;

<Meta
Expand Down Expand Up @@ -52,6 +56,10 @@ export const Template = ({
description: "Pattern",
control: "text",
},
placeholder: {
description: "Placeholder",
control: "text",
},
readOnly: {
description: "Read-only",
control: "boolean",
Expand Down Expand Up @@ -195,3 +203,16 @@ Styling via the `<input>` element:
{Template.bind({})}
</Story>
</Canvas>

## Placeholder

<Canvas>
<Story
name="Textbox with placeholder"
args={{
placeholder: "The Quick Brown Fox Jumps Over The Lazy Dog",
}}
>
{Template.bind({})}
</Story>
</Canvas>

0 comments on commit 0d71278

Please sign in to comment.