forked from web-padawan/aybolit
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(storybook): migrate to CSF3 [1][2]
1: https://storybook.js.org/blog/storybook-csf3-is-here/ 2: https://storybook.js.org/docs/7.0/web-components/api/csf
- Loading branch information
Showing
12 changed files
with
656 additions
and
656 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 |
---|---|---|
@@ -1,26 +1,49 @@ | ||
import { LitElement, html, svg } from 'lit'; | ||
import { customElement } from 'lit/decorators.js'; | ||
import { LitElement, html } from 'lit'; | ||
import { customElement, property } from 'lit/decorators.js'; | ||
import { when } from 'lit/directives/when.js'; | ||
import '@conversionxl/cxl-lumo-styles'; | ||
import cxlSectionStyles from '../styles/cxl-section-css'; | ||
|
||
@customElement('cxl-section') | ||
export class CXLSectionElement extends LitElement { | ||
@property({ type: Boolean }) | ||
get hasWave() { | ||
return this.classList.contains('has-wave'); | ||
} | ||
|
||
static get observedAttributes() { | ||
return ['class']; | ||
} | ||
|
||
static get styles() { | ||
return [cxlSectionStyles]; | ||
} | ||
|
||
// Better Storybook DX. | ||
attributeChangedCallback(name, old, value) { | ||
super.attributeChangedCallback(name, old, value); | ||
|
||
if (name === 'class') { | ||
this.requestUpdate(); | ||
} | ||
} | ||
|
||
render() { | ||
return html` | ||
<section class="wrap"> | ||
<slot></slot> | ||
</section> | ||
${this.classList.contains('has-wave') | ||
? svg` | ||
<svg id="wave" xmlns="http://www.w3.org/2000/svg"> | ||
<path d="M2054 128.79c-106.66 2.043-211.23 3.9-317.46 12.811-138.06 11.581-273.38 4.22-407.8-23.61C1134.57 77.796 984.18 17.54 742.28 14.259 565.44 11.857 259.72 7.614 0 0v246.37h2560c-65.21-27.369-126.32-63.768-195.36-84.649-98.3-29.68-205.7-34.945-310.64-32.932z" fill="#fff"></path> | ||
</svg> | ||
` | ||
: ''} | ||
${when( | ||
this.hasWave, | ||
() => html` | ||
<svg id="wave" xmlns="http://www.w3.org/2000/svg"> | ||
<path | ||
d="M2054 128.79c-106.66 2.043-211.23 3.9-317.46 12.811-138.06 11.581-273.38 4.22-407.8-23.61C1134.57 77.796 984.18 17.54 742.28 14.259 565.44 11.857 259.72 7.614 0 0v246.37h2560c-65.21-27.369-126.32-63.768-195.36-84.649-98.3-29.68-205.7-34.945-310.64-32.932z" | ||
fill="#fff" | ||
></path> | ||
</svg> | ||
` | ||
)} | ||
`; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,39 +1,80 @@ | ||
import { CXLAppLayout1c } from './cxl-app-layout/layout=1c.story'; | ||
import { CXLAppLayout1cc } from './cxl-app-layout/layout=1c-c.story'; | ||
import { CXLAppLayout1cw } from './cxl-app-layout/layout=1c-w.story'; | ||
import { CXLAppLayout2cl } from './cxl-app-layout/layout=2c-l.story'; | ||
import { CXLAppLayout2cr } from './cxl-app-layout/layout=2c-r.story'; | ||
import { html, nothing } from 'lit'; | ||
import { CXLAppLayout1cContent } from './cxl-app-layout/layout=1c.story'; | ||
import { CXLAppLayout1cwContent } from './cxl-app-layout/layout=1c-w.story'; | ||
import { CXLAppLayout2clContent } from './cxl-app-layout/layout=2c-l.story'; | ||
import { CXLAppLayout2crContent } from './cxl-app-layout/layout=2c-r.story'; | ||
import { CXLMarketingNav } from './cxl-marketing-nav.stories'; | ||
import { CXLFooterNav } from './footer-nav.stories'; | ||
|
||
export default { | ||
title: 'CXL UI/cxl-app-layout', | ||
}; | ||
|
||
Object.assign(CXLAppLayout1c, { | ||
const CXLAppLayout = { | ||
render: ({ layout, scroll, content }) => html` | ||
<style> | ||
.entry-content ul { | ||
font-family: var(--cxl-lumo-font-secondary), serif; | ||
} | ||
</style> | ||
<cxl-app-layout id="container" layout="${layout}" scroll="${scroll || nothing}"> | ||
${CXLMarketingNav()} ${content} ${scroll === 'panels' ? nothing : CXLFooterNav()} | ||
</cxl-app-layout> | ||
`, | ||
}; | ||
|
||
// @see https://storybook.js.org/docs/7.0/web-components/writing-stories/stories-for-multiple-components | ||
export const CXLAppLayout1c = { | ||
...CXLAppLayout, | ||
args: { | ||
backgroundColor: 'var(--lumo-shade-5pct)', | ||
hasWave: true, | ||
content: CXLAppLayout1cContent, | ||
layout: '1c', | ||
}, | ||
storyName: '[layout=1c] (default)', | ||
}); | ||
name: '[layout=1c] (default)', | ||
}; | ||
|
||
CXLAppLayout1cc.storyName = '[layout=1c-c]'; | ||
CXLAppLayout1cw.storyName = '[layout=1c-w]'; | ||
export const CXLAppLayout1cc = { | ||
...CXLAppLayout, | ||
args: { | ||
...CXLAppLayout1c.args, | ||
layout: '1c-c', | ||
}, | ||
name: '[layout=1c-c]', | ||
}; | ||
|
||
Object.assign(CXLAppLayout2cl, { | ||
export const CXLAppLayout1cw = { | ||
...CXLAppLayout, | ||
args: { | ||
postId: 1234, | ||
userId: 5678, | ||
playbookSaved: false, | ||
hasWidgetBackground: false, | ||
content: CXLAppLayout1cwContent, | ||
layout: '1c-w', | ||
}, | ||
storyName: '[layout=2c-l]', | ||
}); | ||
name: '[layout=1c-w]', | ||
}; | ||
|
||
Object.assign(CXLAppLayout2cr, { | ||
export const CXLAppLayout2cl = { | ||
...CXLAppLayout, | ||
args: { | ||
hasWidgetBackground: false, | ||
content: CXLAppLayout2clContent({ | ||
postId: 1234, | ||
userId: 5678, | ||
playbookSaved: false, | ||
hasWidgetBackground: false, | ||
}), | ||
layout: '2c-l', | ||
scroll: 'panels', | ||
}, | ||
storyName: '[layout=2c-r]', | ||
}); | ||
name: '[layout=2c-l]', | ||
}; | ||
|
||
export { CXLAppLayout1c, CXLAppLayout1cc, CXLAppLayout1cw, CXLAppLayout2cl, CXLAppLayout2cr }; | ||
export const CXLAppLayout2cr = { | ||
...CXLAppLayout, | ||
args: { | ||
content: CXLAppLayout2crContent({ | ||
hasWidgetBackground: false, | ||
}), | ||
layout: '2c-r', | ||
scroll: 'panels', | ||
}, | ||
name: '[layout=2c-r]', | ||
}; |
12 changes: 0 additions & 12 deletions
12
packages/storybook/cxl-ui/cxl-app-layout/_cxl-app-layout.js
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,15 +1,3 @@ | ||
import { html, nothing } from 'lit'; | ||
import { CXLMarketingNav } from '../cxl-marketing-nav.stories'; | ||
import { CXLFooterNav } from '../footer-nav.stories'; | ||
|
||
export const CXLAppLayout = ({ layout, scroll, content }) => html` | ||
<style> | ||
.entry-content ul { | ||
font-family: var(--cxl-lumo-font-secondary), serif; | ||
} | ||
</style> | ||
<cxl-app-layout id="container" layout="${layout}" scroll="${scroll || nothing}"> | ||
${CXLMarketingNav()} ${content} ${scroll === 'panels' ? nothing : CXLFooterNav()} | ||
</cxl-app-layout> | ||
`; |
48 changes: 0 additions & 48 deletions
48
packages/storybook/cxl-ui/cxl-app-layout/layout=1c-c.story.js
This file was deleted.
Oops, something went wrong.
46 changes: 19 additions & 27 deletions
46
packages/storybook/cxl-ui/cxl-app-layout/layout=1c-w.story.js
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,32 +1,24 @@ | ||
import { html } from 'lit'; | ||
import '@conversionxl/cxl-ui/src/components/cxl-app-layout.js'; | ||
import '@conversionxl/cxl-ui/src/components/cxl-marketing-nav.js'; | ||
import { CXLAppLayout } from './_cxl-app-layout'; | ||
import { CXLVaadinAccordionThemeArchive } from '../cxl-vaadin-accordion.stories'; | ||
|
||
export const CXLAppLayout1cw = () => html` | ||
${CXLAppLayout({ | ||
layout: '1c-w', | ||
content: html` | ||
<article class="entry"> | ||
<header class="entry-header"> | ||
<label>Page</label> | ||
<h1 class="entry-title">Join the top 1% of digital marketing.</h1> | ||
</header> | ||
<div class="entry-content"> | ||
<h2> | ||
We find the absolute best practitioners in the world, and get them to teach their craft. | ||
Learn from the top performers to become one. | ||
</h2> | ||
<p> | ||
Self-paced online digital marketing courses on all things conversion optimization, | ||
digital analytics and digital marketing. | ||
</p> | ||
<p><strong>All in a single subscription.</strong></p> | ||
export const CXLAppLayout1cwContent = html` | ||
<article class="entry"> | ||
<header class="entry-header"> | ||
<label>Page</label> | ||
<h1 class="entry-title">Join the top 1% of digital marketing.</h1> | ||
</header> | ||
<div class="entry-content"> | ||
<h2> | ||
We find the absolute best practitioners in the world, and get them to teach their craft. | ||
Learn from the top performers to become one. | ||
</h2> | ||
<p> | ||
Self-paced online digital marketing courses on all things conversion optimization, digital | ||
analytics and digital marketing. | ||
</p> | ||
<p><strong>All in a single subscription.</strong></p> | ||
${CXLVaadinAccordionThemeArchive()} | ||
</div> | ||
</article> | ||
`, | ||
})} | ||
${CXLVaadinAccordionThemeArchive()} | ||
</div> | ||
</article> | ||
`; |
Oops, something went wrong.