Skip to content

Commit

Permalink
feat: Button group
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed May 14, 2022
1 parent 7324d7d commit b309f02
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 0 deletions.
9 changes: 9 additions & 0 deletions components/button-group/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- @license CC0-1.0 -->

# Button group

De _button group_ is een container voor een aantal buttons, of voor een losstaande button.

## Verticale variant

Voor smalle schermen bij plaatsing in smalle panelen (zoals een sidebar) is er een variant waar buttons onder elkaar staan, in plaats van naast elkaar. Gebruik deze variant niet wanneer er voldoende ruimte is voor de standaard variant. Je kunt bijvoorbeeld CSS media queries gebruiken om deze variant toe te passen voor kleine schermen.
34 changes: 34 additions & 0 deletions components/button-group/css/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* @license EUPL-1.2
* Copyright (c) 2022 Frameless B.V.
*/

.utrecht-button-group {
background-color: var(--utrecht-button-group-background-color);
display: flex;
min-block-size: var(--utrecht-button-block-size);
padding-block-end: var(--utrecht-button-group-padding-block-end);
padding-block-start: var(--utrecht-button-group-padding-block-start);
}

.utrecht-button-group--distance {
margin-block-end: var(--utrecht-button-group-margin-block-end);
margin-block-start: var(--utrecht-button-group-margin-block-start);
}

.utrecht-button-group,
.utrecht-button-group--horizontal {
gap: var(--utrecht-button-group-inline-gap, 1em);
}

.utrecht-button-group__button-link--horizontal,
.utrecht-button-group--horizontal .utrecht-button-link,
.utrecht-button-group:not(.utrecht-button-group--vertical) .utrecht-button-link {
--utrecht-button-padding-inline-end: 0;
--utrecht-button-padding-inline-start: 0;
}

.utrecht-button-group--vertical {
flex-direction: column;
gap: var(--utrecht-button-group-block-gap, 1em);
}
45 changes: 45 additions & 0 deletions components/button-group/css/stories/01-default.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!-- @license CC0-1.0 -->

import { ArgsTable, Canvas, Meta, Story } from "@storybook/addon-docs";
import { Button } from "../../../button/bem";
import { ButtonGroup, defaultArgs } from "../template";
import "../index.scss";

<Meta
id="css-button-group"
title="CSS Component/Button group"
argTypes={{
direction: {
control: { type: "select" },
description: "Direction",
options: ["", "horizontal", "vertical"],
},
innerHTML: {
description: "HTML content",
control: "text",
},
}}
parameters={{
status: {
type: "WORK IN PROGRESS",
},
}}
/>

# Button group

Styling via the `.utrecht-button-group` class name:

<Canvas>
<Story
name="Default"
args={{
...defaultArgs,
innerHTML: [Button({ textContent: "Save and continue" }), Button({ textContent: "Back" })].join("\n"),
}}
>
{ButtonGroup.bind({})}
</Story>
</Canvas>

<ArgsTable story="Default" />
33 changes: 33 additions & 0 deletions components/button-group/css/stories/02-vertical.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!-- @license CC0-1.0 -->

import { Canvas, Meta, Story } from "@storybook/addon-docs";
import { Button } from "../../../button/bem";
import { ButtonGroup, defaultArgs } from "../template";
import "../index.scss";

<Meta
id="css-button-group"
title="CSS Component/Button group"
parameters={{
status: {
type: "WORK IN PROGRESS",
},
}}
/>

# Vertical button group

Styling via the `.utrecht-button-group--vertical` class name:

<Canvas>
<Story
name="--vertical"
args={{
...defaultArgs,
direction: "vertical",
innerHTML: [Button({ textContent: "Save and continue" }), Button({ textContent: "Back" })].join("\n"),
}}
>
{ButtonGroup.bind({})}
</Story>
</Canvas>
8 changes: 8 additions & 0 deletions components/button-group/css/stories/readme.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- @license CC0-1.0 -->

import { Description, Meta } from "@storybook/addon-docs";
import document from "../../README.md";

<Meta id="css-button-group" title="CSS Component/Button group/README" />

<Description>{document}</Description>
16 changes: 16 additions & 0 deletions components/button-group/css/stories/tokens.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- @license CC0-1.0 -->

import { Meta } from "@storybook/addon-docs";
import { ComponentTokensSection } from "../../../../documentation/components/ComponentTokensSection";
import tokens from "../../../../proprietary/design-tokens/dist/index.json";
import tokensDefinition from "../../tokens.json";

<Meta id="css-button-group--design-tokens" title="CSS Component/Button group/Design Tokens" />

# Design Tokens

<ComponentTokensSection
tokens={tokens}
definition={tokensDefinition}
component="utrecht-button-group"
></ComponentTokensSection>
13 changes: 13 additions & 0 deletions components/button-group/css/template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import clsx from 'clsx';

export const defaultArgs = {
direction: 'horizontal',
innerHTML: '',
};

export const ButtonGroup = ({ innerHTML = '', direction = 'horizontal' }) =>
`<div class="${clsx(
'utrecht-button-group',
direction === 'horizontal' && 'utrecht-button-group--horizontal',
direction === 'vertical' && 'utrecht-button-group--vertical',
)}" role="group">${innerHTML}</div>`;
50 changes: 50 additions & 0 deletions components/button-group/tokens.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"utrecht": {
"button-group": {
"background-color": {
"css": {
"syntax": "<color>",
"inherits": true
}
},
"column-gap": {
"css": {
"syntax": "<length>",
"inherits": true
},
"comment": "'column-gap', for lack of a better existing property"
},
"margin-block-end": {
"css": {
"syntax": "<length>",
"inherits": true
}
},
"margin-block-start": {
"css": {
"syntax": "<length>",
"inherits": true
}
},
"padding-block-end": {
"css": {
"syntax": "<length>",
"inherits": true
}
},
"padding-block-start": {
"css": {
"syntax": "<length>",
"inherits": true
}
},
"row-gap": {
"css": {
"syntax": "<length>",
"inherits": true
},
"comment": "'row-gap', for lack of a better existing property"
}
}
}
}
1 change: 1 addition & 0 deletions packages/component-library-css/src/bem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@import "../../../components/blockquote/css";
@import "../../../components/breadcrumb/css";
@import "../../../components/button/bem";
@import "../../../components/button-group/css";
@import "../../../components/checkbox/css";
@import "../../../components/custom-checkbox/css";
@import "../../../components/digid-button/css";
Expand Down

0 comments on commit b309f02

Please sign in to comment.