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 all 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
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;
}