-
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): add list mixins (#4097)
Co-authored-by: Alizé Debray <[email protected]>
- Loading branch information
1 parent
86e2ef1
commit c5a6491
Showing
17 changed files
with
320 additions
and
106 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 list mixins `list-bullet`, `list-revert` and `list-unstyled`. |
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
2 changes: 1 addition & 1 deletion
2
packages/documentation/cypress/snapshots/components/list.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
7 changes: 7 additions & 0 deletions
7
packages/documentation/src/stories/foundations/typography/list/list-bullet.sample.scss
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 @@ | ||
@use '@swisspost/design-system-styles/core' as post; | ||
|
||
.my-component { | ||
ul { | ||
@include post.list-bullet(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/documentation/src/stories/foundations/typography/list/list-inline.sample.scss
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 @@ | ||
@use '@swisspost/design-system-styles/core' as post; | ||
|
||
.my-component { | ||
ul { | ||
@include post.list-inline(); | ||
} | ||
} |
5 changes: 0 additions & 5 deletions
5
packages/documentation/src/stories/foundations/typography/list/list-reset.sample.scss
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
packages/documentation/src/stories/foundations/typography/list/list-unstyled.sample.scss
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,13 @@ | ||
@use '@swisspost/design-system-styles/core' as post; | ||
|
||
.my-component { | ||
ul { | ||
@include post.list-unstyled() { | ||
// custom styles for the ul element | ||
} | ||
|
||
> li { | ||
// custom styles for child elements | ||
} | ||
} | ||
} |
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
118 changes: 118 additions & 0 deletions
118
packages/documentation/src/stories/foundations/typography/list/list.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,118 @@ | ||
import type { StoryObj } from '@storybook/web-components'; | ||
import { schemes } from '@/shared/snapshots/schemes'; | ||
import meta from './list.stories'; | ||
import { html, TemplateResult } from 'lit'; | ||
import { unsafeHTML } from 'lit/directives/unsafe-html.js'; | ||
|
||
const { id, ...metaWithoutId } = meta; | ||
|
||
export default { | ||
...metaWithoutId, | ||
title: 'Snapshots', | ||
}; | ||
|
||
type Story = StoryObj; | ||
|
||
export const Lists: Story = { | ||
render: () => { | ||
return schemes( | ||
() => html` | ||
<h1>Lists</h1> | ||
<h2>Bullet</h2> | ||
<code class="mt-48"><ul></code> | ||
${renderList({ el: 'ul' })} ${renderList({ el: 'ul', classList: 'list-revert' })} | ||
${renderList({ el: 'ul', classList: 'list-unstyled' })} | ||
<code class="mt-48"><ul class="list-inline"></code> | ||
${renderList({ | ||
el: 'ul', | ||
classList: 'list-inline', | ||
})} | ||
${renderList({ | ||
el: 'ul', | ||
classList: 'list-inline list-revert', | ||
})} | ||
${renderList({ | ||
el: 'ul', | ||
classList: 'list-inline list-unstyled', | ||
})} | ||
<code class="mt-48"><ul class="list-bullet"></code> | ||
${renderList({ el: 'ul', classList: 'list-bullet' })} | ||
${renderList({ el: 'ul', classList: 'list-bullet list-revert' })} | ||
${renderList({ el: 'ul', classList: 'list-bullet list-unstyled' })} | ||
<code class="mt-48"><ul class="list-bullet list-inline"></code> | ||
${renderList({ | ||
el: 'ul', | ||
classList: 'list-bullet list-inline', | ||
})} | ||
${renderList({ | ||
el: 'ul', | ||
classList: 'list-bullet list-inline list-revert', | ||
})} | ||
${renderList({ | ||
el: 'ul', | ||
classList: 'list-bullet list-inline list-unstyled', | ||
})} | ||
<h2>Number</h2> | ||
<code class="mt-48"><ol></code> | ||
${renderList({ el: 'ol' })} ${renderList({ el: 'ol', classList: 'list-revert' })} | ||
${renderList({ el: 'ol', classList: 'list-unstyled' })} | ||
<code class="mt-48"><ul class="list-inline"></code> | ||
${renderList({ | ||
el: 'ol', | ||
classList: 'list-inline', | ||
})} | ||
${renderList({ | ||
el: 'ol', | ||
classList: 'list-inline list-revert', | ||
})} | ||
${renderList({ | ||
el: 'ol', | ||
classList: 'list-inline list-unstyled', | ||
})} | ||
`, | ||
); | ||
|
||
function renderList({ | ||
el, | ||
classList = '', | ||
}: { | ||
el: string; | ||
classList?: string; | ||
}): TemplateResult { | ||
const classAttr = classList ? ` class="${classList}"` : ''; | ||
const modifiers = classList?.split(' ').map(c => c.replace(/^list-/, '')); | ||
const modifierStr = modifiers ? modifiers.join(' ') : ''; | ||
|
||
const modifierBlock = modifierStr ? `<strong>${modifierStr}</strong> ` : ''; | ||
const subListBlock = !modifiers?.some(n => n === 'inline') | ||
? `<${el}${classAttr}> | ||
<li>${modifierBlock} sub-list-item 1</li> | ||
<li>${modifierBlock} sub-list-item 2</li> | ||
</${el}>` | ||
: ''; | ||
const listBlock = `<${el}${classAttr}> | ||
<li>${modifierBlock} list-item 1</li> | ||
<li>${modifierBlock} list-item 2 with more text to show how list-inline items wrap to a new line if necessary</li> | ||
<li>${modifierBlock} list-item 3</li> | ||
<li> | ||
${modifierBlock} list-item 4${subListBlock && ' - text before nested'} | ||
${subListBlock} | ||
${subListBlock && modifierBlock + ' list item 4 - text after nested'} | ||
</li> | ||
<li>${modifierBlock} list-item 5</li> | ||
<li>${modifierBlock} list-item 6</li> | ||
<li>${modifierBlock} list-item 7</li>`; | ||
|
||
return html`<hr /> | ||
${unsafeHTML(listBlock)}`; | ||
} | ||
}, | ||
}; |
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
Oops, something went wrong.