diff --git a/.storybook/preview.js b/.storybook/preview.js
index 86603473..3704b646 100644
--- a/.storybook/preview.js
+++ b/.storybook/preview.js
@@ -1,8 +1,39 @@
import { setCustomElementsManifest } from '@storybook/web-components';
+import { makeDecorator } from "@storybook/addons";
+import { html } from 'lit';
+import isChromatic from 'chromatic/isChromatic';
+
import customElements from '../dist/custom-elements.json';
setCustomElementsManifest(customElements);
+const withNoAnimationOnChromaticLayout = makeDecorator({
+ name: 'withNoAnimationOnChromaticLayout',
+ parameterName: 'noAnimationOnChromaticLayout',
+ skipIfNoParametersOrOptions: true,
+ wrapper: (getStory, context) => {
+ const story = getStory(context);
+ const decoratedStory = html`
+ ${isChromatic() ? html`` : html``}
+
+
+ ${ story }
+
+ `;
+
+ // return the modified story
+ return decoratedStory;
+ }
+});
+
+export const decorators = [
+ withNoAnimationOnChromaticLayout
+]
+
export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
viewMode: 'docs',
diff --git a/package-lock.json b/package-lock.json
index 1fa22410..f967398c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -46,6 +46,7 @@
"@web/test-runner-playwright": "^0.8.6",
"@web/test-runner-puppeteer": "^0.10.5",
"@webcomponents/webcomponentsjs": "^2.5.0",
+ "chromatic": "^6.11.4",
"del": "^6.1.0",
"del-cli": "^5.0.0",
"esbuild": "^0.14.50",
@@ -9992,6 +9993,21 @@
"node": ">=10"
}
},
+ "node_modules/chromatic": {
+ "version": "6.11.4",
+ "resolved": "https://registry.npmjs.org/chromatic/-/chromatic-6.11.4.tgz",
+ "integrity": "sha512-f1TcuIXKjGUuOjPuwFF44kzbuEcESFcDxHzrzWPLmHuC90dV8HLxbufqYaTOBYMO/rJ32Zftb7S9pXuF/Rhfog==",
+ "dev": true,
+ "dependencies": {
+ "@discoveryjs/json-ext": "^0.5.7",
+ "@types/webpack-env": "^1.17.0"
+ },
+ "bin": {
+ "chroma": "bin/main.cjs",
+ "chromatic": "bin/main.cjs",
+ "chromatic-cli": "bin/main.cjs"
+ }
+ },
"node_modules/chrome-launcher": {
"version": "0.15.0",
"dev": true,
@@ -35941,6 +35957,16 @@
"integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==",
"dev": true
},
+ "chromatic": {
+ "version": "6.11.4",
+ "resolved": "https://registry.npmjs.org/chromatic/-/chromatic-6.11.4.tgz",
+ "integrity": "sha512-f1TcuIXKjGUuOjPuwFF44kzbuEcESFcDxHzrzWPLmHuC90dV8HLxbufqYaTOBYMO/rJ32Zftb7S9pXuF/Rhfog==",
+ "dev": true,
+ "requires": {
+ "@discoveryjs/json-ext": "^0.5.7",
+ "@types/webpack-env": "^1.17.0"
+ }
+ },
"chrome-launcher": {
"version": "0.15.0",
"dev": true,
diff --git a/package.json b/package.json
index a842c010..de4b99bd 100644
--- a/package.json
+++ b/package.json
@@ -97,6 +97,7 @@
"@web/test-runner-playwright": "^0.8.6",
"@web/test-runner-puppeteer": "^0.10.5",
"@webcomponents/webcomponentsjs": "^2.5.0",
+ "chromatic": "^6.11.4",
"del": "^6.1.0",
"del-cli": "^5.0.0",
"esbuild": "^0.14.50",
diff --git a/src/components/drawer/bl-drawer.css b/src/components/drawer/bl-drawer.css
index 5564cb18..c06353fa 100644
--- a/src/components/drawer/bl-drawer.css
+++ b/src/components/drawer/bl-drawer.css
@@ -1,6 +1,6 @@
-@keyframes slide-from-right{
+@keyframes slide-from-right {
0% {
- transform: translateX(+100%);
+ transform: translateX(100%);
}
100% {
@@ -8,27 +8,31 @@
}
}
-.drawer{
+.drawer {
position: fixed;
- top:0;
+ top: 0;
right: 0;
width: 424px;
- height: 100%;
+ height: 100vh;
background: var(--bl-color-primary-background);
box-shadow: var(--bl-size-xs) 0 var(--bl-size-2xl) rgba(0 0 0 / 50%);
- animation: 0.25s slide-from-right;
-
- /* FIXME: Use z-index variable */
+ transform: translateX(100%);
+ transition: transform var(--bl-drawer-animation-duration, .25s);
z-index: 999;
}
-iframe{
+:host([open]) .drawer {
+ transform: translateX(0);
+ animation: slide-from-right var(--bl-drawer-animation-duration, .25s);
+}
+
+iframe {
height: 100%;
width: 100%;
border: none;
}
-.container{
+.container {
display: flex;
flex-direction: column;
width: 100%;
@@ -46,7 +50,7 @@ header {
header .header-buttons {
display: flex;
- gap:24px;
+ gap: 24px;
margin-left: auto;
}
@@ -75,6 +79,3 @@ section {
width: calc(100vw - 24px);
}
}
-
-
-
diff --git a/src/components/drawer/bl-drawer.stories.mdx b/src/components/drawer/bl-drawer.stories.mdx
index 5be4e7e9..9ddc3df1 100644
--- a/src/components/drawer/bl-drawer.stories.mdx
+++ b/src/components/drawer/bl-drawer.stories.mdx
@@ -7,7 +7,10 @@ import { Meta, Canvas, ArgsTable, Story, Preview, Source } from '@storybook/addo
component="bl-drawer"
parameters={{
layout: 'fullscreen',
- chromatic: { viewports: [1000]},
+ noAnimationOnChromaticLayout: true,
+ chromatic: {
+ viewports: [768, 320],
+ },
}}
argTypes={{
open: {
@@ -29,32 +32,26 @@ import { Meta, Canvas, ArgsTable, Story, Preview, Source } from '@storybook/addo
}}
/>
-export const openDialog = async (event,args) => {
- const insideCanvas = !event.target || event.target.parentNode.parentNode.getAttribute("id") === "root";
- let selector= insideCanvas ? `#root #${args.id}`: `#docs-root #${args.id}`;
- const drawer = document.querySelector(selector);
- drawer.open = true;
- await new Promise(resolve => setTimeout(resolve,1000));
+export const openDialog = async (event, args) => {
+ document.getElementById(args.id).open=true
}
export const DummyContent = () => html`
-
-
- Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
-
-
- Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
-
-
- Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
-
-
- Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
-
-
- Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
-
-
+
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
+
+
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
+
+
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
+
+
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
+
+
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
+
`
export const DrawerTemplate = (args) => html`
@@ -62,13 +59,15 @@ export const DrawerTemplate = (args) => html`
caption=${ifDefined(args.caption)}
embed-url=${ifDefined(args.embedUrl)}
external-link=${ifDefined(args.externalLink)}>
- ${ifDefined(args.content)}
+
+ ${ifDefined(args.content)}
+
`
export const StoryTemplate = (args) => html`
${DrawerTemplate(args)}
- openDialog(event,args)}">${ifDefined(args.buttonText)}
+ openDialog(event, args)}">${ifDefined(args.buttonText)}
`
# Drawer
diff --git a/src/components/drawer/bl-drawer.test.ts b/src/components/drawer/bl-drawer.test.ts
index 3d2e660b..5759de77 100644
--- a/src/components/drawer/bl-drawer.test.ts
+++ b/src/components/drawer/bl-drawer.test.ts
@@ -1,4 +1,4 @@
-import {assert, elementUpdated, expect, fixture, html, oneEvent} from '@open-wc/testing';
+import {assert, aTimeout, elementUpdated, expect, fixture, html, oneEvent} from '@open-wc/testing';
import BlDrawer from "./bl-drawer";
import type typeOfBlDrawer from './bl-drawer';
@@ -112,10 +112,14 @@ describe('bl-drawer',() => {
expect(el.open).to.equal(true);
closeBtn?.click();
- setTimeout(()=>{
- expect(el.open).to.equal(false);
- expect(el.offsetWidth).to.equal(0);
- });
+ await elementUpdated(el);
+
+ expect(el.open).to.equal(false);
+ expect(el.offsetWidth).to.equal(0);
+
+ await aTimeout(1100);
+
+ expect(el?.shadowRoot?.querySelector('bl-button')).to.be.null;
});
});
describe('event tests',()=>{
diff --git a/src/components/drawer/bl-drawer.ts b/src/components/drawer/bl-drawer.ts
index ba2b7ae5..398cddc6 100644
--- a/src/components/drawer/bl-drawer.ts
+++ b/src/components/drawer/bl-drawer.ts
@@ -1,4 +1,4 @@
-import {customElement, property} from "lit/decorators.js";
+import {customElement, property, state} from "lit/decorators.js";
import {CSSResultGroup, html, LitElement, TemplateResult} from "lit";
import {event, EventDispatcher} from "../../utilities/event";
import '../button/bl-button';
@@ -65,16 +65,30 @@ export default class BlDrawer extends LitElement{
}
}
+ private domExistenceSchedule: number;
+
private toggleDialogHandler() {
if (this.open) {
+ if (this.domExistenceSchedule) {
+ clearTimeout(this.domExistenceSchedule);
+ }
+
+ this.domExistence = true;
// FIXME: Allow events without payload
this.onOpen('');
} else {
+ // Give some time for exit animation
+ this.domExistenceSchedule = window.setTimeout(() => {
+ this.domExistence = false;
+ }, 1000);
+
// FIXME: Allow events without payload
this.onClose('');
}
}
+ @state() private domExistence = false;
+
private closeDrawer() {
this.open = false;
}
@@ -118,10 +132,8 @@ export default class BlDrawer extends LitElement{
`;
}
-
-
render(): TemplateResult{
- if(this.open){
+ if(this.domExistence){
return html`
${this.renderContainer()}
`;