Skip to content

Commit

Permalink
feat: foundations typography legend (#3614)
Browse files Browse the repository at this point in the history
Co-authored-by: karimim <[email protected]>
Co-authored-by: Philipp Gfeller <[email protected]>
  • Loading branch information
3 people authored Oct 11, 2024
1 parent 585990b commit c9be0cb
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/beige-jobs-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@swisspost/design-system-documentation': minor
'@swisspost/design-system-styles': minor
---

Updated and tokenized styles for the legend element.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Meta, Controls, Canvas } from '@storybook/blocks';
import * as LegendStories from './legend.stories';

<Meta of={LegendStories} />

<div className="docs-title">
# Legend
<nav>
<link-design of={JSON.stringify(LegendStories)}></link-design>
</nav>
</div>

A legend is in general the title of a group of related (interactive) elements in a form. Not to be confused with caption.

<Canvas of={LegendStories.Default} sourceState="shown" />

<Controls of={LegendStories.Default} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import type { Args, StoryObj } from '@storybook/web-components';
import { html, unsafeStatic } from 'lit/static-html.js';
import { MetaExtended } from '@root/types';

const meta: MetaExtended = {
id: '61faccd2-de2c-48f0-9a06-c051a56580ef',
title: 'Foundations/Typography/Legend',
parameters: {
badges: [],
design: {
type: 'figma',
url: 'https://www.figma.com/design/JIT5AdGYqv6bDRpfBPV8XR/Foundations-%26-Components-Next-Level?node-id=1495-27801&node-type=instance&m=dev',
},
},
args: {
type: 'small',
},
argTypes: {
type: {
name: 'Type',
description:
'Large: Used for the title of a section in a form. Small: Used for the title of group of selection options.',
control: {
type: 'radio',
labels: {
large: 'Large',
small: 'Small',
},
},
options: ['large', 'small'],
table: {
category: 'General',
type: {
summary: 'HTML class attribute',
},
},
},
},
};

export default meta;

type Story = StoryObj;

export const Default: Story = {
render: (args: Args) => html`
<fieldset>
<legend ${args.type !== 'small' && args.type ? unsafeStatic(`class=${args.type}`) : ''}>
Default legend
</legend>
</fieldset>
`,
};
1 change: 1 addition & 0 deletions packages/styles/src/elements/_index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use 'reset';
@use 'body';
@use 'heading';
@use 'fieldset-legend';
18 changes: 18 additions & 0 deletions packages/styles/src/elements/fieldset-legend.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@use '../functions/tokens';
@use '../tokens/elements';

tokens.$default-map: elements.$post-legend;

legend {
font-weight: tokens.get('legend', 'font-weight');
line-height: tokens.get('legend', 'line-height');
width: 100%;

&.large {
font-size: tokens.get('legend', 'large-font-size');
margin-block-start: tokens.get('legend', 'large-margin-block-start');
margin-block-end: tokens.get('legend', 'large-margin-block-end');
padding-block-end: tokens.get('legend', 'large-padding-block-end');
border-bottom: tokens.get('legend', 'large-border-bottom');
}
}
9 changes: 9 additions & 0 deletions packages/styles/src/elements/reset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,12 @@ th {
border-style: solid;
border-width: 0;
}

fieldset,
legend {
padding: 0;
}

fieldset {
border: 0;
}

0 comments on commit c9be0cb

Please sign in to comment.