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

Update deprecated sizing references #4002

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c3db078
feat(Styles): Updated sizing utility (no tokens)
myrta2302 Oct 8, 2024
f0d3a1b
Merge branch 'main' into 3433-component-sizing-utilities
myrta2302 Oct 10, 2024
a82d513
chore(Styles): Merged and adjusted Sizing utility to the updated util…
myrta2302 Oct 10, 2024
468a09a
fix(Styles): Corrected an error in Sizing utility min-vw and min-vh c…
myrta2302 Oct 10, 2024
4ee679c
chore(Styles): Removed formatter entries in settings.json
myrta2302 Oct 10, 2024
5f3ace3
chore(styles): reverted to default linting
myrta2302 Oct 15, 2024
058fe52
Update soft-pugs-dream.md
myrta2302 Oct 16, 2024
be57e5d
chore(styles): review corrections
myrta2302 Oct 16, 2024
63c8dda
Update soft-pugs-dream.md
myrta2302 Oct 16, 2024
1b7492e
Delete packages/documentation/src/stories/utilities/spacing/spacing.s…
myrta2302 Oct 29, 2024
646aa95
Update packages/documentation/src/stories/utilities/sizing/sizing.doc…
myrta2302 Oct 29, 2024
f6bd8e9
Update packages/styles/src/utilities/_variables.scss
myrta2302 Oct 29, 2024
a15095b
Revert "Delete packages/documentation/src/stories/utilities/spacing/s…
myrta2302 Oct 29, 2024
705d74c
review comments update
myrta2302 Oct 29, 2024
16eb19d
fix commit error
myrta2302 Oct 29, 2024
f924141
review comments update - merged snapshots
myrta2302 Oct 29, 2024
1bae545
minor
myrta2302 Oct 29, 2024
6da50e6
Merge branch 'main' into 3433-component-sizing-utilities
myrta2302 Oct 29, 2024
d6efe73
Update sizing.stories.ts
myrta2302 Oct 29, 2024
0430161
Update sizing.styles.scss
myrta2302 Oct 29, 2024
d1a8183
fix linting errors
myrta2302 Oct 29, 2024
3d4bec3
Update sizing.snapshot.ts
myrta2302 Oct 29, 2024
e5c0324
Merge branch 'main' into 3433-component-sizing-utilities
myrta2302 Oct 31, 2024
576de4a
Merge branch 'main' into 3433-component-sizing-utilities
myrta2302 Oct 31, 2024
42d2f5f
Merge branch 'main' into 3433-component-sizing-utilities
myrta2302 Nov 4, 2024
7e22271
Merge branch 'main' into 3433-component-sizing-utilities
myrta2302 Nov 8, 2024
ba233e9
Update packages/documentation/src/stories/utilities/sizing/sizing.doc…
myrta2302 Nov 11, 2024
49a7beb
Merge branch 'main' into 3433-component-sizing-utilities
myrta2302 Nov 11, 2024
714dee2
review comments update
myrta2302 Nov 11, 2024
5c5c154
minor
myrta2302 Nov 11, 2024
514dd7a
Merge branch 'main' into 3433-component-sizing-utilities
myrta2302 Nov 11, 2024
6cadf22
minor
myrta2302 Nov 11, 2024
93e4b90
revert file changes
myrta2302 Nov 12, 2024
2e54943
Merge branch 'main' into 3433-component-sizing-utilities
myrta2302 Nov 12, 2024
e9c0c6c
Merge branch 'main' into 3433-component-sizing-utilities
myrta2302 Nov 12, 2024
3ecb288
Merge branch 'main' into 3433-component-sizing-utilities
myrta2302 Nov 12, 2024
d48c295
Merge branch 'main' into 3433-component-sizing-utilities
myrta2302 Nov 14, 2024
544854d
Merge branch '3433-component-sizing-utilities' of https://github.com/…
myrta2302 Nov 14, 2024
87e4eac
replace deprecated sizing classes
myrta2302 Nov 15, 2024
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/soft-pugs-dream.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 the utility classes for sizing.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
describe('Sizing', () => {
it('Sizing', () => {
cy.visit('/iframe.html?id=snapshots--sizing');
cy.get('.snapshot', { timeout: 30000 }).should('be.visible');
cy.percySnapshot('Sizing', { widths: [320, 1440] });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export const PostLogo: Story = {
${['white', 'dark'].map(
color => html`
<div class="col bg-${color}">
${['big', 'huge', 'giant'].map(
${[25, 50, 75].map(
(height, i) => html`
<div class="h-${height} ${i === 0 ? 'my' : 'mb'}-mini">
<div class="h-${height} ${i === 0 ? 'my' : 'mb'}-8">
${meta.render?.({ ...context.args, url }, context)}
</div>
`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ import * as SizingStories from './sizing.stories';

## Height & Width

Height and width can be set using `h-*` and `w-*` prefixes, max-height and max-width can be set using prefixes `mh-*` and `mw-*` .
Height and width can be set using `h-*` and `w-*` prefixes, max-height and max-width can be set using prefixes `max-h-*` and `max-w-*` and min height and min width can be set using the prefixes `min-h` and `min-w`.

### Parent Based

Bootstrap offers sizing classes with the suffixes bellow. They allow you to set a height / width as a percentage of the parent element (see [Bootstrap Sizing](https://getbootstrap.com/docs/5.3/utilities/sizing/) for reference).
The design system offers sizing classes with the suffixes bellow. They allow you to set a height / width as a percentage of the parent element.

> - `*-auto`
> - `*-0`
> - `*-25`
> - `*-50`
> - `*-75`
> - `*-100`

#### Example
### Example

<Canvas sourceState="shown" of={SizingStories.SizesPercent} />
<div className="hide-col-default">
Expand All @@ -37,34 +39,7 @@ For width, we offer additionally `.w-{breakpoint}-{size}` classes (e.g. `w-md-10

See <a href="/?path=/docs/eb78afcb-ce92-4990-94b6-6536d5ec6af4--docs#full-width">Full-width button</a> for a practical example.

### Post-Sizes

Post sizes can be used as suffixes in the same way. To find out which size name to use, see the "Size name in classes" column in the reference table above or use the "Example Post-Sizes" below.

#### Sass variables

{/* prettier-ignore */}
<div className="alert alert-warning mb-40">
<h2 className="alert-heading">Sizing variables are deprecated</h2>
<p>The current set of the post-specific sizing variables is deprecated in favour of a new naming system that is consistent with the Design. For further information, please read the <a href="https://github.com/swisspost/design-system/discussions/588">discussion on sizing variables on GitHub</a> and have a look at the <a href="https://www.figma.com/file/ojCcgC5Zd12eUSzq6V5m24/Foundations?node-id=3%3A2&t=l8qimsXlxeMLOzs6-0">implementation in Figma</a>.</p>
<p>There is a new solution with updated naming system up coming for spacing sizes.</p>
</div>

<Source
language="scss"
dark
code={Object.entries(SizingStories.SCSS_VARIABLES)
.filter(([key, value]) => key !== 'parameters')
.map(([key, value]) => `$${key}: ${formatAsMap(value)};`)
.join('\n')}
></Source>

<Canvas of={SizingStories.Sizes} />
<div className="hide-col-default">
<Controls of={SizingStories.Sizes} />
</div>

## Viewport Based
### Viewport Based

There is the possibility to set the width and height relative to the viewport.

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import type { StoryObj } from '@storybook/web-components';
import { html } from 'lit';
import './sizing.styles.scss';
import meta from './sizing.stories';

const { id, ...metaWithoutId } = meta;

export default {
...metaWithoutId,
title: 'Snapshots',
argTypes: {
// ... your argTypes here
},
};

type Story = StoryObj;

export const Sizing: Story = {
render: () => {
const nonViewportSamples = [
{ w: '0', h: '100', maxW: '0', minW: '100', maxH: '50', minH: '0' },
{ w: '25', h: '50', maxW: '25', minW: '50', maxH: '100', minH: '25' },
{ w: '50', h: '25', maxW: '50', minW: '25', maxH: '75', minH: '0' },
{ w: '75', h: '75', maxW: '75', minW: '75', maxH: '25', minH: '50' },
{ w: '100', h: '0', maxW: '100', minW: '0', maxH: '100', minH: '0' },
];

const viewportSamples = [
{ vw: '0', vh: '100', maxVw: 'none', minVw: '100', maxVh: '50', minVh: '0' },
{ vw: '25', vh: '50', maxVw: 'none', minVw: '50', maxVh: '100', minVh: '25' },
{ vw: '50', vh: '25', maxVw: 'none', minVw: '25', maxVh: '75', minVh: '0' },
{ vw: '75', vh: '75', maxVw: 'none', minVw: '75', maxVh: '25', minVh: '50' },
{ vw: '100', vh: '100', maxVw: 'none', minVw: '0', maxVh: '100', minVh: '0' },
];

return html`
<div class="sizing-example snapshot">
${nonViewportSamples.map(sample => {
return html`
<div class="grid-item">
<div
class="w-${sample.w} h-${sample.h} max-w-${sample.maxW} min-w-${sample.minW} max-h-${sample.maxH} min-h-${sample.minH}"
></div>
</div>
`;
})}
</div>

<div class="sizing-vp-example snapshot">
${viewportSamples.map(sample => {
return html`
<div class="grid-item">
<div
class="vw-${sample.vw} vh-${sample.vh} max-vw-${sample.maxVw} min-vw-${sample.minVw} max-vh-${sample.maxVh} min-vh-${sample.minVh}"
></div>
</div>
`;
})}
</div>
`;
},
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import type { Args, StoryObj } from '@storybook/web-components';
import type { Args, StoryObj, StoryFn, StoryContext } from '@storybook/web-components';
import { html } from 'lit';
import './sizing.styles.scss';
import scss from './sizing.module.scss';
import { MetaExtended } from '@root/types';

export const SCSS_VARIABLES = scss;

const sizingOptions = ['auto', ...Object.keys(SCSS_VARIABLES)];

const sizeOptionsPercent = ['auto', '25', '50', '75', '100'];
export const SizeOptionsPercent = ['auto', '0', '25', '50', '75', '100'];

const meta: MetaExtended = {
render: renderSizing,
Expand All @@ -18,10 +12,12 @@ const meta: MetaExtended = {
badges: [],
},
args: {
height: 'bigger-giant',
width: 'bigger-giant',
maxHeight: 'null',
maxWidth: 'null',
height: 'none',
width: 'none',
maxHeight: 'none',
maxWidth: 'none',
minHeight: 'none',
minWidth: 'none',
},
argTypes: {
height: {
Expand All @@ -30,67 +26,104 @@ const meta: MetaExtended = {
control: {
type: 'select',
},
options: sizingOptions,
options: SizeOptionsPercent,
table: {
category: 'Height',
},
},
width: {
name: 'width',
description: 'Set the width of the rectangle',
control: {
type: 'select',
},
options: sizingOptions,
options: SizeOptionsPercent,
table: {
category: 'Width',
},
},
maxHeight: {
name: 'max-height',
description: 'Set the maximum height of the rectangle',
control: {
type: 'select',
},
options: ['none', ...sizingOptions],
options: ['none', ...SizeOptionsPercent.filter(value => value !== 'auto')],
table: {
category: 'Height',
},
},
maxWidth: {
name: 'max-width',
description: 'Set the maximum width of the rectangle',
control: {
type: 'select',
},
options: ['none', ...sizingOptions],
options: ['none', ...SizeOptionsPercent.filter(value => value !== 'auto')],
table: {
category: 'Width',
},
},
minHeight: {
name: 'min-height',
description: 'Set the minimum height of the rectangle',
control: {
type: 'select',
},
options: ['none', ...SizeOptionsPercent.filter(value => value !== 'auto')],
table: {
category: 'Height',
},
},
minWidth: {
name: 'min-width',
description: 'Set the minimum width of the rectangle',
control: {
type: 'select',
},
options: ['none', ...SizeOptionsPercent.filter(value => value !== 'auto')],
table: {
category: 'Width',
},
},
},
decorators: [
(story: StoryFn, context: StoryContext) => {
const storyTemplate = html`
<div class="sizing-example">
<div class="d-flex p-16 gap-16" style="height: 150px">
<div class="flex-fill">${story(context.args, context)}</div>
</div>
</div>
`;
return storyTemplate;
},
],
};

export default meta;

type Story = StoryObj;

function renderSizing(args: Args) {
const maximumHeight = args.maxHeight && args.maxHeight !== 'null' ? `mh-${args.maxHeight}` : '';
const maximumWidth = args.maxWidth && args.maxWidth !== 'null' ? `mw-${args.maxWidth}` : '';
const classes = `content h-${args.height} w-${args.width} ${maximumHeight} ${maximumWidth}`;
const classNames = [
`content`,
`h-${args.height}`,
`w-${args.width}`,
args.maxHeight && args.maxHeight !== 'none' ? `max-h-${args.maxHeight}` : '',
args.maxWidth && args.maxWidth !== 'none' ? `max-w-${args.maxWidth}` : '',
args.minHeight && args.minHeight !== 'none' ? `min-h-${args.minHeight}` : '',
args.minWidth && args.minWidth !== 'none' ? `min-w-${args.minWidth}` : '',
]
.filter(Boolean)
.join(' ');

return html`
<div class="sizing-example">
<div class="d-flex p-16 gap-16" style="height: 150px">
<div class="flex-fill">
<div class="${classes}"></div>
</div>
</div>
</div>
`;
return html`<div class="${classNames}"></div>`;
}

export const Sizes: Story = {};
export const SizesPercent: Story = {
args: {
width: '25',
height: '100',
},
argTypes: {
height: {
options: sizeOptionsPercent,
},
width: {
options: sizeOptionsPercent,
},
},
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,55 @@
@use '@swisspost/design-system-styles/core' as post;

.sizing-example {
.sizing-example,
.sizing-vp-example,
.sizing-auto-example {
gap: 30px;

&.snapshot {
height: 200vh;
width: 100vw;
display: flex;
flex-direction: column;
}

.content {
background-color: post.$white;
border: 1px solid post.$gray-40;
}

.info {
padding: 15px;
font-size: 0.8em;
}

.grid-item {
width: 300px;
height: 300px;
border: 1px solid post.$gray-40;

div {
background-color: post.$gray-40;
}
}
}

.sizing-vp-example {
&.snapshot {
display: grid;
grid-template-columns: 100vw;
grid-template-rows: 100vh;
}

.grid-item {
width: 100vw;
height: 100vh;
}
}

.sizing-auto-example {
.inner-div {
width: 50px;
height: 50px;
background-color: red !important;
}
}
2 changes: 2 additions & 0 deletions packages/migrations/src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export const breakpoints = [ 'xs', 'sm', 'rg', 'md', 'lg', 'xl', 'xxl' ];

const bootstrapSizes = [ '0', '1', '2', '3', '4', '5', 'auto' ];


const postSizes = [
'hair',
'line',
Expand Down
Loading
Loading