-
Notifications
You must be signed in to change notification settings - Fork 19
chore(z-index): add Z-Index utility #5741
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a1e8d06
chore(z-index): add Z-Index utility
hugomslv 676c969
Merge branch 'main' into 5631-create-z-index-utility-and-document-it
hugomslv 99f50cc
fix comments
hugomslv 943d189
Update slick-banks-report.md
hugomslv b7e2a52
Merge branch 'main' into 5631-create-z-index-utility-and-document-it
hugomslv e10d59f
Remove this unused import
hugomslv 8fc4fab
Merge branch '5631-create-z-index-utility-and-document-it' of https:/β¦
hugomslv 2703f46
Merge branch 'main' into 5631-create-z-index-utility-and-document-it
hugomslv 3b834df
fix comment
hugomslv b644760
Merge branch 'main' into 5631-create-z-index-utility-and-document-it
hugomslv 273a2f0
Merge branch 'main' into 5631-create-z-index-utility-and-document-it
hugomslv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 | ||
--- | ||
|
||
Internalized bootstrap z-index utilities. |
7 changes: 7 additions & 0 deletions
7
packages/documentation/cypress/snapshots/utilities/z-index.snapshot.ts
This file contains hidden or 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('Z-Index', () => { | ||
it('z-index', () => { | ||
cy.visit('/iframe.html?id=snapshots--z-index'); | ||
cy.get('.container-examples', { timeout: 30000 }).should('be.visible'); | ||
cy.percySnapshot('Z-Index', { widths: [1440] }); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
packages/documentation/src/stories/utilities/z-index/z-index.docs.mdx
This file contains hidden or 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,24 @@ | ||
import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks'; | ||
import * as ZIndexStories from './z-index.stories'; | ||
|
||
<Meta of={ZIndexStories} /> | ||
|
||
# Z-Index | ||
|
||
<div className="lead"> | ||
Use our <code>{".z-{value}"}</code> utility classes to control element stacking. Each element must have a non-static position (e.g. <code>relative</code>, <code>absolute</code> or <code>fixed</code>) for the z-index to take effect. | ||
</div> | ||
|
||
**Available classes:** | ||
- <code>.z-n1</code> | ||
- <code>.z-0</code> | ||
- <code>.z-1</code> | ||
- <code>.z-2</code> | ||
- <code>.z-3</code> | ||
|
||
## Example | ||
|
||
<Canvas sourceState="shown" of={ZIndexStories.ZIndex} /> | ||
<div className="hide-col-default"> | ||
<Controls of={ZIndexStories.ZIndex} /> | ||
</div> |
31 changes: 31 additions & 0 deletions
31
packages/documentation/src/stories/utilities/z-index/z-index.snapshot.stories.ts
This file contains hidden or 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,31 @@ | ||
import type { StoryObj } from '@storybook/web-components-vite'; | ||
import { html } from 'lit'; | ||
import { COLOR_SCHEMES, schemes } from '@/shared/snapshots/schemes'; | ||
import meta from './z-index.stories'; | ||
import './z-index.styles.scss'; | ||
|
||
const { id, ...metaWithoutId } = meta; | ||
|
||
export default { | ||
...metaWithoutId, | ||
title: 'Snapshots', | ||
}; | ||
|
||
type Story = StoryObj; | ||
|
||
export const ZIndex: Story = { | ||
render: () => { | ||
return schemes( | ||
() => html` | ||
<div class="container-examples"> | ||
<div class="position-absolute z-3">z-3</div> | ||
<div class="position-absolute z-2">z-2</div> | ||
<div class="position-absolute z-1">z-1</div> | ||
<div class="position-absolute z-0">z-0</div> | ||
<div class="position-absolute z-n1">z-n1</div> | ||
</div> | ||
`, | ||
{ filter: scheme => scheme === COLOR_SCHEMES.light }, | ||
); | ||
}, | ||
}; |
50 changes: 50 additions & 0 deletions
50
packages/documentation/src/stories/utilities/z-index/z-index.stories.ts
This file contains hidden or 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,50 @@ | ||
import type { Args, StoryObj } from '@storybook/web-components-vite'; | ||
import { html } from 'lit'; | ||
import './z-index.styles.scss'; | ||
import { MetaExtended } from '@root/types'; | ||
|
||
const meta: MetaExtended = { | ||
id: 'd4b7f8a2-1c3e-4b5d-9f1a-2e6b0c7a9f3d', | ||
title: 'Utilities/Z-Index', | ||
args: { | ||
zIndex1: '0', | ||
zIndex2: '1', | ||
zIndex3: '2', | ||
}, | ||
argTypes: { | ||
zIndex1: { | ||
name: 'Box 1 z-Index', | ||
description: 'z-index first box', | ||
control: { type: 'select' }, | ||
options: ['n1', '0', '1', '2', '3'], | ||
table: { category: 'Boxes' }, | ||
}, | ||
zIndex2: { | ||
name: 'Box 2 z-Index', | ||
description: 'z-index second box', | ||
control: { type: 'select' }, | ||
options: ['n1', '0', '1', '2', '3'], | ||
table: { category: 'Boxes' }, | ||
}, | ||
zIndex3: { | ||
name: 'Box 3 z-Index', | ||
description: 'z-index third box ', | ||
control: { type: 'select' }, | ||
options: ['n1', '0', '1', '2', '3'], | ||
table: { category: 'Boxes' }, | ||
}, | ||
}, | ||
render: (args: Args) => { | ||
return html` | ||
<div class="container-examples"> | ||
<div class="z-${args.zIndex1} position-absolute">z-${args.zIndex1}</div> | ||
<div class="z-${args.zIndex2} position-absolute">z-${args.zIndex2}</div> | ||
<div class="z-${args.zIndex3} position-absolute">z-${args.zIndex3}</div> | ||
</div> | ||
`; | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj; | ||
export const ZIndex: Story = {}; |
28 changes: 28 additions & 0 deletions
28
packages/documentation/src/stories/utilities/z-index/z-index.styles.scss
This file contains hidden or 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,28 @@ | ||
@use '@swisspost/design-system-styles/core' as post; | ||
|
||
.container-examples { | ||
position: relative; | ||
height: 250px; | ||
z-index: 0; | ||
} | ||
|
||
.container-examples > div{ | ||
width: 100px; | ||
height: 100px; | ||
background-color: post.$yellow; | ||
color: post.$black; | ||
font-weight: bold; | ||
display: flex; | ||
align-items: end; | ||
justify-content: start; | ||
border: post.$white 2px solid ; | ||
border-radius: 0.5rem; | ||
} | ||
|
||
@for $i from 1 through 5 { | ||
.container-examples > div:nth-child(#{$i}) { | ||
top: #{($i - 1) * 30}px; | ||
left: #{($i - 1) * 40}px; | ||
} | ||
} | ||
|
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.