-
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.
test(documentation): implement schemes wrapper around all snapshot st…
…ories (#4109)
- Loading branch information
1 parent
c19daf9
commit 62ebad8
Showing
54 changed files
with
1,273 additions
and
1,402 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,24 @@ | ||
import { html, TemplateResult } from 'lit'; | ||
|
||
interface IOptions { | ||
filter?: (scheme: string) => boolean; | ||
additionalSchemes?: string[]; | ||
} | ||
|
||
export const COLOR_SCHEMES = { | ||
light: 'light', | ||
// dark: 'dark', | ||
}; | ||
|
||
export function schemes(renderFn: (scheme: string) => TemplateResult, options: IOptions = {}) { | ||
const filter = options.filter || (() => true); | ||
const additionalSchemes = options.additionalSchemes ?? []; | ||
|
||
return html`${[...additionalSchemes, ...Object.values(COLOR_SCHEMES)] | ||
.filter(filter) | ||
.map( | ||
scheme => html` <div data-color-scheme="${scheme}" class="p-16 palette-default"> | ||
${renderFn(scheme)} | ||
</div>`, | ||
)}`; | ||
} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; | ||
import meta, { Default } from './avatar.stories'; | ||
import { html } from 'lit'; | ||
import { schemes } from '@/shared/snapshots/schemes'; | ||
import { bombArgs } from '@/utils'; | ||
|
||
const { id, ...metaWithoutId } = meta; | ||
|
@@ -10,43 +11,38 @@ export default { | |
title: 'Snapshots', | ||
}; | ||
|
||
type Story = StoryObj<HTMLPostAvatarPictureElement>; | ||
type Story = StoryObj; | ||
|
||
export const AvatarPicture: Story = { | ||
render: (args: Args, context: StoryContext<HTMLPostAvatarPictureElement>) => { | ||
return html` | ||
<div id="Snapshots"> | ||
<h1 class="h4">Avatar</h1> | ||
${['bg-white', 'bg-dark'].map( | ||
bg => html` | ||
<div class="${bg} mt-16 p-16"> | ||
<div class="d-flex flex-column gap-regular"> | ||
${bombArgs({ | ||
lastname: [null, 'Source'], | ||
firstname: ['Open'], | ||
}).map( | ||
(bombArgs: Args) => | ||
html`<div class="py-8"> | ||
${Default.render?.({ ...context.args, ...bombArgs }, context)} | ||
</div>`, | ||
)} | ||
render: (args: Args, context: StoryContext) => { | ||
return schemes( | ||
() => html` | ||
<div class="mt-16"> | ||
<div class="d-flex flex-column gap-regular"> | ||
${bombArgs({ | ||
lastname: [null, 'Source'], | ||
firstname: ['Open'], | ||
}).map( | ||
(bombArgs: Args) => | ||
html`<div class="py-8"> | ||
${Default.render?.({ ...context.args, ...bombArgs }, context)} | ||
</div>`, | ||
)} | ||
<div class="py-8"> | ||
${Default.render?.({ ...args, email: '[email protected]' }, context)} | ||
</div> | ||
<div class="py-8"> | ||
${Default.render?.({ ...args, email: '[email protected]' }, context)} | ||
</div> | ||
<div class="py-8"> | ||
${Default.render?.( | ||
{ ...args, imageSrc: '/assets/images/logo-swisspost.svg' }, | ||
context, | ||
)} | ||
</div> | ||
</div> | ||
<div class="py-8"> | ||
${Default.render?.( | ||
{ ...args, imageSrc: '/assets/images/logo-swisspost.svg' }, | ||
context, | ||
)} | ||
</div> | ||
</div> | ||
`, | ||
)} | ||
</div> | ||
`; | ||
</div> | ||
</div> | ||
`, | ||
); | ||
}, | ||
}; |
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.