-
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.
Merge branch 'main' into 3753-bug-inactive-chips-have-no-visible-focus
- Loading branch information
Showing
6 changed files
with
194 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-styles': minor | ||
'@swisspost/design-system-documentation': minor | ||
--- | ||
|
||
Internalized bootstraps floating utilities into the design system. |
7 changes: 7 additions & 0 deletions
7
packages/documentation/cypress/snapshots/utilities/float.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('Float', () => { | ||
it('float', () => { | ||
cy.visit('/iframe.html?id=snapshots--float'); | ||
cy.get('.float-example', { timeout: 30000 }).should('be.visible'); | ||
cy.percySnapshot('Float', { widths: [320, 400, 600, 780, 1024, 1280, 1440] }); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
packages/documentation/src/stories/utilities/float/float.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,36 @@ | ||
import { Canvas, Controls, Meta, Source } from '@storybook/blocks'; | ||
import * as FloatStories from './float.stories'; | ||
|
||
<Meta of={FloatStories} /> | ||
|
||
# Float | ||
|
||
<div className="lead"> | ||
Use `float-start`, `float-end`, or `float-none` to easily float elements. | ||
</div> | ||
|
||
## Properties | ||
|
||
- `float-start`: Floats the element to the left (in LTR). | ||
- `float-end`: Floats the element to the right (in LTR). | ||
- `float-none`: Removes floating from the element. | ||
|
||
### Relative to breakpoints | ||
|
||
<div className="alert alert-info"> | ||
The `float-{breakpoint}-{position}` classes provide control over floating elements at specific | ||
breakpoints, enabling you to float elements or remove floating based on the screen size. | ||
</div> | ||
|
||
> - `float-sm-{start|end|none}` | ||
> - `float-md-{start|end|none}` | ||
> - `float-lg-{start|end|none}` | ||
> - `float-xl-{start|end|none}` | ||
> - `float-xxl-{start|end|none}` | ||
#### Example | ||
|
||
<Canvas sourceState="shown" of={FloatStories.Float} /> | ||
<div className="hide-col-default"> | ||
<Controls of={FloatStories.Float} /> | ||
</div> |
46 changes: 46 additions & 0 deletions
46
packages/documentation/src/stories/utilities/float/float.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,46 @@ | ||
import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; | ||
import { html } from 'lit'; | ||
import meta from './float.stories'; | ||
import { bombArgs } from '@/utils'; | ||
|
||
const { id, ...metaWithoutId } = meta; | ||
|
||
export default { | ||
...metaWithoutId, | ||
title: 'Snapshots', | ||
}; | ||
|
||
type Story = StoryObj; | ||
|
||
export const Float: Story = { | ||
render: (_args: Args, context: StoryContext) => { | ||
return html` | ||
<div class="snapshot-example"> | ||
<h1>Snapshot with Float</h1> | ||
${['bg-white', 'bg-dark'].map( | ||
bg => html` | ||
<div class="${bg} p-16"> | ||
${(meta.argTypes?.floatBreakPoint?.options ?? []).map((breakpoint: string) => { | ||
return html` | ||
<h2>Breakpoint ${breakpoint}</h2> | ||
<div> | ||
${bombArgs({ | ||
floatPosition: [...(meta.argTypes?.floatPosition?.options ?? [])], | ||
floatBreakPoint: [breakpoint], | ||
}).map((args: Args) => { | ||
return html` | ||
<div class="clearfix"> | ||
${meta.render?.({ ...context.args, ...args, breakpoint }, context)} | ||
</div> | ||
`; | ||
})} | ||
</div> | ||
`; | ||
})} | ||
</div> | ||
`, | ||
)} | ||
</div> | ||
`; | ||
}, | ||
}; |
62 changes: 62 additions & 0 deletions
62
packages/documentation/src/stories/utilities/float/float.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,62 @@ | ||
import type { Args, StoryObj, StoryFn, StoryContext } from '@storybook/web-components'; | ||
import { html } from 'lit/static-html.js'; | ||
import { MetaExtended } from '@root/types'; | ||
import { nothing } from 'lit'; | ||
|
||
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ | ||
|
||
const meta: MetaExtended = { | ||
id: 'ccf092c1-f0ab-49a1-a612-87e5be23adde', | ||
title: 'Utilities/Float', | ||
argTypes: { | ||
floatPosition: { | ||
name: 'float', | ||
description: 'Sets the float. ', | ||
control: { | ||
type: 'select', | ||
}, | ||
options: ['start', 'end', 'none'], | ||
table: { | ||
category: 'Add float', | ||
}, | ||
}, | ||
floatBreakPoint: { | ||
name: 'breakpoint', | ||
description: 'Sets the float for a specific breakpoint. ', | ||
control: { | ||
type: 'select', | ||
}, | ||
options: ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'], | ||
table: { | ||
category: 'Add float', | ||
}, | ||
}, | ||
}, | ||
args: { | ||
floatPosition: null, | ||
floatBreakPoint: null, | ||
}, | ||
render: (args: Args) => { | ||
const classMembers = ['float', args.floatBreakPoint ?? 'xs', args.floatPosition].filter(m => m); | ||
const floatClass = | ||
classMembers.length === 3 ? classMembers.filter(m => m !== 'xs').join('-') : nothing; | ||
|
||
return html` | ||
<div class="${floatClass}"> | ||
Content ${floatClass !== nothing ? '(' + String(floatClass) + ')' : ''} | ||
</div> | ||
`; | ||
}, | ||
decorators: [ | ||
(story: StoryFn, context: StoryContext) => { | ||
const storyTemplate = html`<div class="clearfix">${story(context.args, context)}</div>`; | ||
return storyTemplate; | ||
}, | ||
], | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj; | ||
|
||
export const Float: 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