Skip to content

Commit

Permalink
feat(vwc-side-drawer): remove absolute support (#1029)
Browse files Browse the repository at this point in the history
* feat(vwc-side-drawer): 1st draft

* story added

* story added

* semi-transparent content model

* alternate scheme

* alternate

* devider check

* working example

* this will break

* this will not break

* slot="navigation"

* margin list

* side drawer bigger inline size

* side drawer position

* appContent inlined

* documentation, header, image

* vvd-umbrella under devDependencies

* @prop

* readme

* Update package.json

* Update package.json

* Update package.json

* Update package.json

* Update package.json

* add border and shadow to side drawer

* activated

* style

* Extension panel should not be activated

* wider side drawer

* slots documentation

* restore yarn.lock

* refer correct tokens

* refactor

* declartiveness

* correct module import

* ESlint

* refactor names

* update readme

* remove absolute

* split modal story

* match svg to modal side drawer

* remove absolute from ui test

* remove story duplications

* yarn

* add modal UI test

Co-authored-by: yinonov <yinon@hotmail.com>
Co-authored-by: tveinfeld <67224311+tveinfeld@users.noreply.github.com>
  • Loading branch information
3 people committed Aug 25, 2021
1 parent 6cf366c commit b00ded7
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 167 deletions.
1 change: 0 additions & 1 deletion components/side-drawer/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Represents a side drawer custom element.

| Property | Attribute | Type | Default |
|-------------|-------------|------------------------|---------|
| `absolute` | `absolute` | `boolean` | false |
| `alternate` | `alternate` | `boolean` | false |
| `hasTopBar` | `hasTopBar` | `boolean \| undefined` | |
| `open` | `open` | `boolean` | false |
Expand Down
23 changes: 5 additions & 18 deletions components/side-drawer/src/vwc-side-drawer-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,6 @@ export class VWCSideDrawerBase extends LitElement {
})
type = '';

/**
* @prop absolute - the modal and dismissible can be fixed or absolute
* accepts Boolean value
* @public
* */
@property({
type: Boolean,
reflect: true
})
absolute = true;

@property({
type: Boolean,
reflect: true
Expand Down Expand Up @@ -97,14 +86,12 @@ export class VWCSideDrawerBase extends LitElement {
const topBar = this.hasTopBar ? this.renderTopBar() : '';
const scrim = (this.type === 'modal' && this.open) ? this.renderScrim() : '';
const alternate = this.alternate ? 'vvd-scheme-alternate' : undefined;
const absolute = this.type === 'modal' && this.absolute;

const classes = {
'vvd-side-drawer--alternate': this.alternate,
'vvd-side-drawer--dismissible': dismissible,
'vvd-side-drawer--modal': modal,
'vvd-side-drawer--open': this.open,
'vvd-side-drawer--absolute': absolute,
};

const aside = html`<aside
Expand Down Expand Up @@ -143,11 +130,11 @@ export class VWCSideDrawerBase extends LitElement {

private renderScrim(): TemplateResult {
return html`
<div
class="vvd-side-drawer--scrim ${this.absolute ? 'vvd-side-drawer--absolute' : ''}"
@click="${this.#handleScrimClick}"
@keydown="${this.#handleScrimClick}"
></div>`;
<div
class="vvd-side-drawer--scrim"
@click="${this.#handleScrimClick}"
@keydown="${this.#handleScrimClick}"
></div>`;
}

#handleScrimClick(): void {
Expand Down
16 changes: 2 additions & 14 deletions components/side-drawer/src/vwc-side-drawer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,11 @@ $min-width: 280px;
}

.vvd-side-drawer--modal {
position: fixed;
top: 0;
right: initial;
bottom: 0;
left: 0;

&.vvd-side-drawer--absolute {
position: absolute;
}
&:not(.vvd-side-drawer--absolute) {
position: fixed;
}
}

.aside-container {
Expand All @@ -108,20 +102,14 @@ $min-width: 280px;

.vvd-side-drawer--scrim {
@include scrim-mixins.scrim-variables;
position: fixed;
z-index: calc(#{$z-index-default} - 1);
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: var(#{scrim-mixins.$vvd-scrim--background-color});
opacity: var(#{scrim-mixins.$vvd-scrim--opacity});

&.vvd-side-drawer--absolute {
position: absolute;
}
&:not(.vvd-side-drawer--absolute) {
position: fixed;
}
}


Expand Down
3 changes: 0 additions & 3 deletions components/side-drawer/stories/arg-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,4 @@ export const argTypes = {
hasTopBar: {
control: booleanControl
},
absolute: {
control: booleanControl
}
};
29 changes: 29 additions & 0 deletions components/side-drawer/stories/side-drawer-modal.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { html } from 'lit-element';
import { argTypes } from './arg-types.js';
import { unsafeSVG } from 'lit-html/directives/unsafe-svg';
import { pageContentMock } from '../../../scripts/storybook/svg_templates';
import { Basic } from './side-drawer.stories.js';

export default {
title: 'Alpha/Components/Side Drawer/Modal',
component: 'vwc-side-drawer',
argTypes
};

const Template = args => html`
<style>
div#demo {
top: 0px;
position: fixed;
display: flex;
width: 100%;
height: 100%;
}
</style>
<div id="demo">
${Basic(args)}
${unsafeSVG(pageContentMock('100%', '100%', 'xMinYMin slice'))}
</div>`;

export const Modal = Template.bind({});
Modal.args = { type: 'modal', open: true };
46 changes: 20 additions & 26 deletions components/side-drawer/stories/side-drawer.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export default {
argTypes
};

let prevActivatedItem;

const titleStyles = {
color: "#C0C0C0",
fontWeight: "bold",
Expand All @@ -39,12 +37,17 @@ const Template = args => html`
height: 100%;
}
div#default > svg {
width: 100%;
height: 100%;
}
width: 100%;
height: 100%;
}
</style>
<div id="demo">
${Basic(args)}
<div id="default"></div>
${unsafeSVG(pageContentMock())}
</div>`;

const SideDrawerTemplate = args => html`
<vwc-side-drawer id="side-drawer" ...=${spread(args)} @click="${onClick}">
<span slot="top-bar">
<vwc-icon type="vonage-mono"></vwc-icon> VONAGE
Expand Down Expand Up @@ -88,15 +91,21 @@ const Template = args => html`
<vwc-list-item shape="rounded">2nd level item</vwc-list-item>
</vwc-list-expansion-panel>
</vwc-list>
</vwc-side-drawer>`;

</vwc-side-drawer>
export const Basic = SideDrawerTemplate.bind({});
Basic.args = { };

<div id="default"></div>
${unsafeSVG(pageContentMock())}
export const Alternate = Template.bind({});
Alternate.args = { alternate: true };

</div>
`;
export const TopBar = Template.bind({});
TopBar.args = { hasTopBar: true };

export const Dismissible = Template.bind({});
Dismissible.args = { type: 'dismissible', open: true };

let prevActivatedItem;
function onClick(e) {
// only list items can be activated
if (e.target.localName !== "vwc-list-item") {
Expand All @@ -111,18 +120,3 @@ function onClick(e) {
prevActivatedItem = e.target;
prevActivatedItem.activated = true;
}

export const Basic = Template.bind({});
Basic.args = { };

export const Alternate = Template.bind({});
Alternate.args = { alternate: true };

export const TopBar = Template.bind({});
TopBar.args = { hasTopBar: true };

export const Dismissible = Template.bind({});
Dismissible.args = { type: 'dismissible', open: true };

export const Modal = Template.bind({});
Modal.args = { type: 'modal', open: true };
5 changes: 1 addition & 4 deletions components/side-drawer/test/side-drawer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,12 @@ describe('Side-drawer', () => {
expect(actualElement.hasTopBar, 'hasTopBar should be undefined')
.to
.equal(undefined);
expect(actualElement.absolute, 'absolute should be false')
.to
.equal(true);
});
});

describe('Side drawer attributes', () => {
it('should reflect from attribute to property', async () => {
const COMPONENT_PROPERTIES = ['open', 'alternate', 'hasTopBar', 'absolute'];
const COMPONENT_PROPERTIES = ['open', 'alternate', 'hasTopBar'];
for await (const property of COMPONENT_PROPERTIES) {
const [actualElement] = addElement(
textToDomToParent(`<${COMPONENT_NAME} ${property}></${COMPONENT_NAME}>`)
Expand Down
4 changes: 2 additions & 2 deletions scripts/storybook/svg_templates.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
pageContentMock: function (width = 782, height = 754) {
pageContentMock: function (width = '782', height = '754', preserveAspectRatio = 'xMidYMin') {
return `
<svg width='${width}' height='${height}' viewBox='0 0 ${width} ${height}' preserveAspectRatio='xMidYMin' fill='none' xmlns='http://www.w3.org/2000/svg'>
<svg width=${width} height=${height} viewBox='0 0 782 754' preserveAspectRatio='${preserveAspectRatio}' fill='none' xmlns='http://www.w3.org/2000/svg'>
\t<style>
\t\t.scheme_1 {
\t\t\tfill: var(--vvd-color-neutral-10, #eee);
Expand Down
Binary file added ui-tests/snapshots/vwc-side-drawer-modal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ui-tests/snapshots/vwc-side-drawer.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions ui-tests/tests/vwc-side-drawer-modal/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import '@vonage/vwc-side-drawer';
import '@vonage/vwc-list/vwc-list-expansion-panel.js';
import '@vonage/vwc-list/vwc-list.js';
import '@vonage/vwc-list/vwc-list-item.js';
import '@vonage/vwc-icon/vwc-icon.js';
import { snapshotTheWholePage } from '../../utils/testPageUtils';
import { pageContentMock } from '../../../scripts/storybook/svg_templates';

export async function createElementVariations(wrapper) {
snapshotTheWholePage(wrapper);
const elementWrapper = document.createElement('div');
elementWrapper.innerHTML = `
<style>
div#demo {
top: 0px;
position: fixed;
display: flex;
width: 100%;
height: 100%;
}
</style>
<div>
<div id="demo">
<vwc-side-drawer id="side-drawer" type="modal" hasTopBar open>
<span slot="top-bar">
<vwc-icon type="vonage-mono"></vwc-icon> VONAGE
</span>
<vwc-list
innerRole="navigation"
innerAriaLabel="Primary navigation"
itemRoles="link"
>
<vwc-list-item shape="rounded" graphic="icon">
<vwc-icon slot="graphic" type="home-line"></vwc-icon>1st level item
</vwc-list-item>
<p>SECTION TITLE</p>
<vwc-list-item shape="rounded" graphic="icon">
<vwc-icon slot="graphic" type="chat-line"></vwc-icon>1st level item
</vwc-list-item>
<vwc-list-expansion-panel open>
<vwc-list-item slot="header" shape="rounded" graphic="icon">
<vwc-icon slot="graphic" type="chat-line"></vwc-icon>1st level item
</vwc-list-item>
<vwc-list-expansion-panel open>
<vwc-list-item slot="header" shape="rounded"
>2nd level item</vwc-list-item
>
<vwc-list-item shape="rounded">3rd level item</vwc-list-item>
<vwc-list-item shape="rounded">3rd level item</vwc-list-item>
</vwc-list-expansion-panel>
</vwc-list-expansion-panel>
</vwc-list>
</vwc-side-drawer>
<div id="default"></div>
${pageContentMock('100%', '100%', 'xMinYMin slice')}
</div>
</div>
`;
wrapper.appendChild(elementWrapper);
}


0 comments on commit b00ded7

Please sign in to comment.