-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(styles): component form footer (#3616)
Co-authored-by: Alizé Debray <[email protected]>
- Loading branch information
1 parent
c607efc
commit 8174593
Showing
10 changed files
with
308 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@swisspost/design-system-documentation': minor | ||
'@swisspost/design-system-styles': minor | ||
--- | ||
|
||
Added Form Footer component. |
7 changes: 7 additions & 0 deletions
7
packages/documentation/cypress/snapshots/components/form-footer.snapshot.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe('Form footer', () => { | ||
it('default', () => { | ||
cy.visit('/iframe.html?id=snapshots--form-footer'); | ||
cy.get('.form-footer post-icon', { timeout: 30000 }).should('be.visible'); | ||
cy.percySnapshot('Form footer', { widths: [320, 1440] }); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
...ges/documentation/src/stories/components/forms/form-footer/form-footer.docs.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Canvas, Controls, Meta } from '@storybook/blocks'; | ||
import * as FormFooterStories from './form-footer.stories'; | ||
import StylesPackageImport from '@/shared/styles-package-import.mdx'; | ||
|
||
<Meta of={FormFooterStories} /> | ||
|
||
<div className="docs-title"> | ||
# Footer | ||
|
||
<nav> | ||
<link-design of={JSON.stringify(FormFooterStories)}></link-design> | ||
</nav> | ||
</div> | ||
|
||
<div className="lead"> | ||
The form footer is placed at the end/bottom of a form or a form step, in case the form is splitted with a stepper. It provides workflow-related actions to the form or form step. | ||
</div> | ||
|
||
<Canvas sourceState="shown" of={FormFooterStories.Default} /> | ||
<div className="hide-col-default"> | ||
<Controls of={FormFooterStories.Default} /> | ||
</div> |
70 changes: 70 additions & 0 deletions
70
...es/documentation/src/stories/components/forms/form-footer/form-footer.snapshot.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import type { StoryObj } from '@storybook/web-components'; | ||
import meta, { FooterArgs } from './form-footer.stories'; | ||
import { html } from 'lit'; | ||
import { bombArgs } from '@/utils'; | ||
|
||
const { id, ...metaWithoutId } = meta; | ||
|
||
export default { | ||
...metaWithoutId, | ||
title: 'Snapshots', | ||
}; | ||
|
||
type Story = StoryObj; | ||
|
||
export const FormFooter: Story = { | ||
render: () => { | ||
return html` | ||
<div class="d-flex flex-column gap-3"> | ||
${['bg-white', 'bg-dark'].map( | ||
bg => html` | ||
<div class="${bg} d-flex flex-column p-3 gap-3"> | ||
${bombArgs({ | ||
showPrimaryButton: [true, false], | ||
showSecondaryButton: [true, false], | ||
showTertiaryButton: [true, false], | ||
}).map(args => { | ||
const primaryButton = args.showPrimaryButton | ||
? html`<button class="btn btn-primary"> | ||
${FooterArgs.primaryButtonText}<post-icon | ||
aria-hidden="true" | ||
name="${FooterArgs.primaryButtonIcon}" | ||
></post-icon> | ||
</button>` | ||
: null; | ||
const secondaryButton = args.showSecondaryButton | ||
? html`<button class="btn btn-secondary"> | ||
${FooterArgs.secondaryButtonText} | ||
</button>` | ||
: null; | ||
return html` | ||
<div class="form-footer"> | ||
${args.showPrimaryButton || args.showSecondaryButton | ||
? html` | ||
<div class="form-footer-primary-actions"> | ||
${primaryButton} ${secondaryButton} | ||
</div> | ||
` | ||
: null} | ||
${args.showTertiaryButton | ||
? html` | ||
<button class="btn btn-tertiary"> | ||
<post-icon | ||
aria-hidden="true" | ||
name="${FooterArgs.tertiaryButtonIcon}" | ||
></post-icon | ||
>${FooterArgs.tertiaryButtonText} | ||
</button> | ||
` | ||
: null} | ||
</div> | ||
`; | ||
})} | ||
</div> | ||
`, | ||
)} | ||
</div> | ||
`; | ||
}, | ||
}; |
146 changes: 146 additions & 0 deletions
146
packages/documentation/src/stories/components/forms/form-footer/form-footer.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import { Args, StoryObj } from '@storybook/web-components'; | ||
import { html } from 'lit'; | ||
import { MetaComponent } from '@root/types'; | ||
|
||
export const FooterArgs = { | ||
showPrimaryButton: true, | ||
primaryButtonText: 'Send', | ||
primaryButtonIcon: '3020', | ||
showSecondaryButton: true, | ||
secondaryButtonText: 'Cancel', | ||
showTertiaryButton: true, | ||
tertiaryButtonText: 'Back', | ||
tertiaryButtonIcon: '3024', | ||
}; | ||
|
||
const meta: MetaComponent = { | ||
id: 'f2eddf67-2c3c-40c4-bfec-df49bd028001', | ||
title: 'Components/Forms/Form Footer', | ||
tags: ['package:HTML'], | ||
render: render, | ||
parameters: { | ||
badges: [], | ||
design: { | ||
type: 'figma', | ||
url: 'https://www.figma.com/design/JIT5AdGYqv6bDRpfBPV8XR/Foundations-%26-Components-Next-Level?node-id=1498-28215', | ||
}, | ||
}, | ||
args: { | ||
...FooterArgs, | ||
}, | ||
argTypes: { | ||
showPrimaryButton: { | ||
name: 'Show primary button', | ||
description: 'Show or hide the primary button (last one on the right)', | ||
control: { type: 'boolean' }, | ||
table: { | ||
category: 'Primary button', | ||
}, | ||
}, | ||
primaryButtonText: { | ||
name: 'Primary button text', | ||
description: 'Text to display on the primary button', | ||
control: { type: 'text' }, | ||
table: { | ||
category: 'Primary button', | ||
}, | ||
if: { | ||
arg: 'showPrimaryButton', | ||
}, | ||
}, | ||
primaryButtonIcon: { | ||
name: 'Primary button icon', | ||
description: 'Icon to display on the primary button', | ||
control: { type: 'text' }, | ||
table: { | ||
category: 'Primary button', | ||
}, | ||
if: { | ||
arg: 'showPrimaryButton', | ||
}, | ||
}, | ||
showSecondaryButton: { | ||
name: 'Show secondary button', | ||
description: 'Show or hide the secondary button (first one on the right)', | ||
control: { type: 'boolean' }, | ||
table: { | ||
category: 'Secondary button', | ||
}, | ||
}, | ||
secondaryButtonText: { | ||
name: 'Secondary button text', | ||
description: 'Text to display on the secondary button', | ||
control: { type: 'text' }, | ||
table: { | ||
category: 'Secondary button', | ||
}, | ||
if: { | ||
arg: 'showSecondaryButton', | ||
}, | ||
}, | ||
showTertiaryButton: { | ||
name: 'Show tertiary button', | ||
description: 'Show or hide the tertiary button (button on the left)', | ||
control: { type: 'boolean' }, | ||
table: { | ||
category: 'Tertiary button', | ||
}, | ||
}, | ||
tertiaryButtonText: { | ||
name: 'Tertiary button text', | ||
description: 'Text to display on the tertiary button', | ||
control: { type: 'text' }, | ||
table: { | ||
category: 'Tertiary button', | ||
}, | ||
if: { | ||
arg: 'showTertiaryButton', | ||
}, | ||
}, | ||
tertiaryButtonIcon: { | ||
name: 'Tertiary button icon', | ||
description: 'Icon to display on the tertiary button', | ||
control: { type: 'text' }, | ||
table: { | ||
category: 'Tertiary button', | ||
}, | ||
if: { | ||
arg: 'showTertiaryButton', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj; | ||
|
||
export function render(args: Args) { | ||
const primaryButton = args.showPrimaryButton | ||
? html`<button class="btn btn-primary"> | ||
${args.primaryButtonText}<post-icon | ||
aria-hidden="true" | ||
name="${args.primaryButtonIcon}" | ||
></post-icon> | ||
</button>` | ||
: null; | ||
const secondaryButton = args.showSecondaryButton | ||
? html`<button class="btn btn-secondary">${args.secondaryButtonText}</button>` | ||
: null; | ||
|
||
return html` | ||
<div class="form-footer"> | ||
${args.showPrimaryButton || args.showSecondaryButton | ||
? html` <div class="form-footer-primary-actions">${primaryButton} ${secondaryButton}</div> ` | ||
: null} | ||
${args.showTertiaryButton | ||
? html`<button class="btn btn-tertiary"> | ||
<post-icon aria-hidden="true" name="${args.tertiaryButtonIcon}"></post-icon | ||
>${args.tertiaryButtonText} | ||
</button>` | ||
: null} | ||
</div> | ||
`; | ||
} | ||
|
||
export const Default: Story = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@use '../mixins/utilities' as utility-mx; | ||
@use '../tokens/components'; | ||
@use '../functions/tokens' as tokens; | ||
|
||
tokens.$default-map: components.$post-form-footer; | ||
|
||
.form-footer { | ||
@include utility-mx.responsive-actions(); | ||
border-block-start-width: tokens.get('form-footer-border-block-start-width'); | ||
border-block-start-color: tokens.get('form-footer-border-start-color'); | ||
border-block-start-style: tokens.get('form-footer-border-block-start-style'); | ||
padding-block-start: tokens.get('form-footer-padding-block-start'); | ||
gap: tokens.get('form-footer-gap'); | ||
|
||
&-primary-actions { | ||
gap: tokens.get('form-footer-gap'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters