Skip to content

Commit

Permalink
chore(documentation, styles): remove deprecated bg classes (#4201)
Browse files Browse the repository at this point in the history
Co-authored-by: Alizé Debray <[email protected]>
  • Loading branch information
leagrdv and alizedebray authored Dec 17, 2024
1 parent 019aac1 commit 37bc19c
Show file tree
Hide file tree
Showing 74 changed files with 351 additions and 804 deletions.
7 changes: 7 additions & 0 deletions .changeset/poor-jars-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@swisspost/design-system-documentation': major
'@swisspost/design-system-components': major
'@swisspost/design-system-styles': major
---

Removed `.bg-` classes to define background color of elements.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<header class="bg-dark">
<header class="palette-alternate">
<nav class="container py-8">
<ul class="d-flex flex-wrap row-gap-4 column-gap-16 m-0 list-unstyled">
<li *ngFor="let route of navigationRoutes">
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@use '@swisspost/design-system-styles';
@use '@swisspost/design-system-styles/post-external.scss';
2 changes: 1 addition & 1 deletion packages/components/cypress/e2e/tag.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Tag', () => {
});
});

it('should set the tags bg-color according to the prop `variant`', () => {
it('should set the tags background color according to the prop `variant`', () => {
['gray', 'white', 'info', 'success', 'danger', 'warning', 'yellow'].forEach(bg => {
cy.get('@tag').invoke('attr', 'variant', bg).should('have.attr', 'variant', bg);
cy.get('@wrapper').should('have.class', `tag-${bg}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
}

:host {
--post-contrast-color: #{post.$white};
--post-bg-rgb: #{post.rgb-values(post.$gray-80)};

display: block;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
:where(post-popovercontainer) {
@include elevation-mx.elevation('elevation-3');

background: var(--post-current-palette-bg);
color: var(--post-current-palette-fg);
position: fixed;
z-index: commons.$zindex-popover;

width: max-content;
margin: 0;
padding: 0;
Expand All @@ -34,8 +35,6 @@
}

box-sizing: border-box;
color: var(--post-contrast-color);
background-color: rgb(var(--post-bg-rgb));
border: 2px solid transparent; // Keeping the default border for HCM
border-radius: commons.$border-radius;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
@use '@swisspost/design-system-styles/functions/color' as color-fn;
@use '@swisspost/design-system-styles/variables/spacing';

:host {
--post-contrast-color: #{color.$white};
--post-bg-rgb: #{color-fn.rgb-values(color.$gray-80)};
}

post-popovercontainer {
padding: spacing.$size-micro spacing.$size-mini;
max-width: 2 * spacing.$size-bigger-giant - spacing.$size-mini;
Expand Down
2 changes: 1 addition & 1 deletion packages/documentation/.storybook/blocks/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default (params: { pathToStoryFile?: String }) => (
)}
</div>
<footer className="docs-footer mt-56">
<div className="bg-light">
<div>
<div className="container">
<div className="pt-big-r pb-big-r">
<h2 className="mt-0">Design System Team Members</h2>
Expand Down
2 changes: 1 addition & 1 deletion packages/documentation/.storybook/blocks/header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

export default () => (
<header className="docs-header bg-yellow">
<header className="docs-header">
<div className="container py-48">
<h1>
Swiss Post
Expand Down
5 changes: 5 additions & 0 deletions packages/documentation/.storybook/blocks/layout/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
background-repeat: no-repeat;
background-position: center left 60vw;
background-size: auto 100%;
background-color: post.$yellow;

.container {
padding-right: 20vw;
Expand All @@ -28,6 +29,10 @@
}

.docs-footer {
> div:first-child {
background-color: post.$light;
}

ul.list-profile {
display: grid;
grid-template-rows: auto;
Expand Down
37 changes: 3 additions & 34 deletions packages/documentation/.storybook/styles/manager.scss
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,16 @@

#misc,
[data-item-id^='health'],
:is(#raw-components, [data-parent-id="raw-components"]):where([data-env="production"] *) {
:is(#raw-components, [data-parent-id='raw-components']):where([data-env='production'] *) {
display: none;
}

#introduction--docs,
[data-parent-id="misc"] a {
[data-parent-id='misc'] a {
padding-inline-start: 0.5rem;
}

[data-parent-id="misc"]:where(:not([data-parent-id="misc"] + *)) {
[data-parent-id='misc']:where(:not([data-parent-id='misc'] + *)) {
margin-block-start: 1rem;
}
}
Expand Down Expand Up @@ -146,34 +146,3 @@
letter-spacing: 0.1em;
}
}

.bg-dark {
#storybook-explorer-tree {
.sidebar-item {
&:hover,
&:focus-visible {
background-color: var(--post-gray-80);
}

&[data-selected='true'] {
background-color: rgba(var(--post-yellow-rgb), 0.7);
color: var(--post-contrast-color);
}
}
}

#downshift-1-menu {
.search-result-item {
.search-result-item--label {
span {
color: var(--post-gray-40);
}
}

&:hover,
&:focus-visible {
background-color: var(--post-gray-80);
}
}
}
}
2 changes: 1 addition & 1 deletion packages/documentation/cypress/e2e/components/hint.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe('Hint', () => {
describe('Accessibility', () => {
beforeEach(() => {
cy.visit('/iframe.html?id=snapshots--hint');
cy.get('.hint', { timeout: 30000 }).should('be.visible');
cy.get('.form-hint', { timeout: 30000 }).should('be.visible');
cy.injectAxe();
});

Expand Down
10 changes: 0 additions & 10 deletions packages/documentation/src/shared/decorators/dark-background.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Args, StoryContext, StoryFn, StoryObj } from '@storybook/web-components';
import { Args, StoryContext, StoryObj } from '@storybook/web-components';
import { MetaComponent } from '@root/types';
import { html, nothing } from 'lit';
import { components } from '@swisspost/design-system-components/dist/docs.json';
import { coloredBackground } from '@/shared/decorators/dark-background';

const AVATAR_ARGTYPES = components.find(c => c.tag === 'post-avatar');
const USERID_ARGTYPE = AVATAR_ARGTYPES?.props.find(p => p.name === 'userid');
Expand Down Expand Up @@ -61,9 +60,6 @@ export default meta;
type Story = StoryObj;

export const Default: Story = {
decorators: [
(story: StoryFn, context: StoryContext) => coloredBackground(story, context, 'light'),
],
render: (args: Args) => html`<post-avatar
firstname="${args.firstname || nothing}"
lastname="${args.lastname || nothing}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import StylesPackageImport from '@/shared/styles-package-import.mdx';
### Colors

You can change the badge color simply by applying a `.bg-*` class to it.
See all available classes in the [background utilities documentation](/?path=/docs/60852fac-a861-4415-8276-bd38d68653bb--docs).

<Canvas of={badgeStories.Colors} />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import { Args, StoryContext, StoryFn, StoryObj } from '@storybook/web-components
import { html, nothing } from 'lit';
import { MetaComponent } from '@root/types';
import backgroundColors from '@/shared/background-colors.module.scss';
import { coloredBackground } from '@/shared/decorators/dark-background';
import chipMeta from '@/stories/components/chip/chip.stories';

const meta: MetaComponent = {
id: 'bec68e8b-445e-4760-8bd7-1b9970206d8d',
title: 'Components/Badge',
tags: ['package:HTML'],
render: renderBadge,
decorators: [adaptiveBackground],
parameters: {
badges: [],
design: {
Expand Down Expand Up @@ -69,8 +67,8 @@ const meta: MetaComponent = {
},
},
background: {
name: 'Backround',
description: 'You can use the Background classes to color the cards',
name: 'Background',
description: 'You can use the background classes to color the cards',
control: {
type: 'select',
},
Expand All @@ -84,13 +82,6 @@ const meta: MetaComponent = {

export default meta;

// DECORATORS
function adaptiveBackground(story: StoryFn, context: StoryContext) {
const { args } = context;
const isLight = ['bg-white', 'bg-light', 'bg-gray'].includes(args.background as string);
return isLight ? coloredBackground(story, context, 'dark') : story(args, context);
}

// RENDERER
function renderBadge(args: Args) {
const sizingClass = args.showNumber && args.size !== 'large' ? ` ${args.size}` : '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ import StylesPackageImport from '@/shared/styles-package-import.mdx';

The following examples show the different characteristics of the component. These can differ in the type of visualization, the html structure, as well as when, how and why they are displayed.

### Inverted

Inverted buttons don't need special classes, just use any of the [background classes](/?path=/docs/60852fac-a861-4415-8276-bd38d68653bb--docs) to set the background, as well as set the `data-color-scheme="dark"` to a parent element and you're done for the day.

<Canvas of={ButtonStories.Inverted} />

### Full-width

In some situation, it is desirable to display a button using the full available width,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,6 @@ export const Default: Story = {
...Template,
};

export const Inverted: Story = {
...Template,
decorators: [
(story: StoryFn, context: StoryContext) =>
html`
<div class="p-16 bg-dark" data-color-scheme="dark">${story(context.args, context)}</div>
`,
],
};

const VariantsTemplate = {
parameters: {
controls: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Args, StoryObj } from '@storybook/web-components';
import { html } from 'lit';
import { useArgs } from '@storybook/preview-api';
import { MetaComponent } from '@root/types';
import backgroundColors from '@/shared/background-colors.module.scss';

const meta: MetaComponent = {
id: '6f8f76ec-a2b5-4eb0-87f7-4021e1a5b8d0',
Expand Down Expand Up @@ -62,13 +61,13 @@ const meta: MetaComponent = {
category: 'General',
},
},
background: {
name: 'Backround',
description: 'You can use the Background classes to color the cards',
palette: {
name: 'Palette',
description: 'You can use the color scheme of the cards',
control: {
type: 'select',
},
options: Object.keys(backgroundColors),
options: ['palette-default', 'palette-accent', 'palette-alternate', 'palette-brand'],
table: {
category: 'General',
},
Expand All @@ -79,7 +78,7 @@ export default meta;
function cardButtonRender(args: Args, count = 42) {
const [_, updateArgs] = useArgs();
return html`
<div class="card card-button ${args.background}" id="${`card-button${count}`}">
<div class="card card-button ${args.palette}" id="${`card-button${count}`}">
<button
class="post-card-favourit"
@click="${() => (count === 42 ? updateArgs({ favourite: !args.favourite }) : '')}"
Expand Down Expand Up @@ -129,30 +128,25 @@ const multipleArgs = [
{
focus: 'Schwerpunkt',
title: 'Post zurückbehalten',
background: 'bg-nightblue',
},
{
focus: 'Schwerpunkt',
title: 'Briefmarken',
favourite: true,
background: 'bg-nightblue',
},
{
focus: 'Schwerpunkt',
tittle: 'Meine Sendungen',
background: 'bg-nightblue',
},
],
[
{
focus: 'Schwerpunkt',
title: 'Pick@home',
favourite: 'true',
background: 'bg-nightblue',
},
{
title: 'E-Finance: Demoversion',
background: 'bg-nightblue',
},
{
title: 'Adressänderung mit Nachsendung',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ import SampleCardControlMethods from './web-component/card-control-methods.sampl

## Examples

### Dark backgrounds
<Canvas of={CardControlStandardHTMLStories.DarkBackground} />
<div className="hide-col-default">
<Controls of={CardControlStandardHTMLStories.DarkBackground} />
</div>

### Grouping

Checkbox cards can be grouped together. Use a `fieldset`/`legend` combination to label the group. If there is an error, link the legend with the error message through the `aria-describedby` attribute on the `legend`, pointing to the `id` of the error message.
Expand Down Expand Up @@ -95,23 +89,10 @@ import SampleCardControlMethods from './web-component/card-control-methods.sampl

## Installation

The `<post-card-control>` element is part of the `@swisspost/design-system-components` package. For more information, read the

<a href="/?path=/docs/edfb619b-fda1-4570-bf25-20830303d483--docs">
getting started with components guide
</a>
.
The `<post-card-control>` element is part of the `@swisspost/design-system-components` package. For more information, read the <a href="/?path=/docs/edfb619b-fda1-4570-bf25-20830303d483--docs">getting started with components guide</a>.

## Examples

### Dark backgrounds

<Canvas of={CardControlStories.DarkBackground}/>

<div className="hide-col-default">
<Controls of={CardControlStories.DarkBackground} />
</div>

### Custom icon

You can use our built-in icons by just adding the `icon` property with the name of the desired icon.<br/>
Expand Down
Loading

0 comments on commit 37bc19c

Please sign in to comment.