Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: foundations typography legend #3614

Merged
merged 18 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/beige-jobs-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@swisspost/design-system-documentation': minor
'@swisspost/design-system-styles': minor
'@swisspost/design-system-tokens': minor
---

Added legend element.
21 changes: 21 additions & 0 deletions packages/documentation/src/stories/elements/legend/legend.docs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Meta, 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.

### Default

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

### Large

<Canvas of={LegendStories.Large} sourceState="shown" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { StoryObj } from '@storybook/web-components';
import { html } from 'lit';
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=26-49',
},
},
};

export default meta;

type Story = StoryObj;

export const Default: Story = {
render: () => html`
<fieldset>
<legend>Default legend</legend>
</fieldset>
`,
};

export const Large: Story = {
render: () => html`
<fieldset>
<legend class="legend-large">Large 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';
19 changes: 19 additions & 0 deletions packages/styles/src/elements/fieldset-legend.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@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%;
}

.legend-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;
}