-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dialog): the dialog component (#580)
- Loading branch information
1 parent
b0c5162
commit 456ac7b
Showing
14 changed files
with
1,798 additions
and
1,791 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,42 @@ | ||
# `Dialog` | ||
|
||
#### `should internal contents` | ||
|
||
```html | ||
<div | ||
aria-describedby="content" | ||
aria-labelledby="title" | ||
aria-modal="true" | ||
class="mdc-dialog" | ||
role="alertdialog" | ||
> | ||
<div class="mdc-dialog__container"> | ||
<div class="mdc-dialog__surface"> | ||
<div | ||
class="mdc-dialog__content" | ||
id="content" | ||
> | ||
<slot id="contentSlot"> | ||
</slot> | ||
</div> | ||
<footer | ||
class="mdc-dialog__actions" | ||
id="actions" | ||
> | ||
<span> | ||
<slot name="secondaryAction"> | ||
</slot> | ||
</span> | ||
<span> | ||
<slot name="primaryAction"> | ||
</slot> | ||
</span> | ||
</footer> | ||
</div> | ||
</div> | ||
<div class="mdc-dialog__scrim"> | ||
</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
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,32 @@ | ||
{ | ||
"name": "@vonage/vwc-dialog", | ||
"version": "1.0.2", | ||
"description": "dialog component", | ||
"homepage": "https://github.com/Vonage/vivid/tree/master/components/dialog#readme", | ||
"license": "ISC", | ||
"main": "vwc-dialog.js", | ||
"module": "vwc-dialog.js", | ||
"files": [ | ||
"*.js", | ||
"*.ts", | ||
"*.map" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/vonage/vivid.git", | ||
"directory": "components/dialog" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: run tests from root\" && exit 1" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Vonage/vivid/issues" | ||
}, | ||
"dependencies": { | ||
"@material/mwc-dialog": "^0.20.0", | ||
"@vonage/vvd-style-coupling": "1.0.2", | ||
"@vonage/vvd-foundation": "1.0.2", | ||
"lit-element": "^2.4.0", | ||
"tslib": "^2.0.3" | ||
} | ||
} |
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,15 @@ | ||
# vwc-dialog | ||
|
||
Add a description of vwc-dialog. | ||
|
||
## Properties | ||
|
||
| Property | Type | | ||
|---------------------------|-------------------------------------------| | ||
| `prop ` | `propType` | | ||
|
||
## Methods | ||
|
||
| Method | Type | | ||
|---------|------------| | ||
| `method`| `(): void` | |
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 @@ | ||
@use '@vonage/vvd-foundation/scss/variable-names/color-semantic-variable-names' as color-semantic; | ||
@use '@vonage/vvd-foundation/scss/mixins/color-connotation-mixins'; | ||
|
||
:host { | ||
|
||
} |
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,26 @@ | ||
import { customElement } from 'lit-element'; | ||
import { style } from './vwc-dialog.css'; | ||
import { Dialog as MWCDialog } from '@material/mwc-dialog'; | ||
import { style as mwcDialogStyle } from '@material/mwc-dialog/mwc-dialog-css'; | ||
import { style as styleCoupling } from '@vonage/vvd-style-coupling'; | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'vwc-dialog': VWCDialog; | ||
} | ||
} | ||
|
||
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
// @ts-ignore | ||
MWCDialog.styles = [styleCoupling, mwcDialogStyle, style]; | ||
|
||
@customElement('vwc-dialog') | ||
export class VWCDialog extends MWCDialog { | ||
connectedCallback(): void { | ||
super.connectedCallback(); | ||
} | ||
|
||
disconnectedCallback(): void { | ||
super.disconnectedCallback(); | ||
} | ||
} |
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,15 @@ | ||
export const argTypes = { | ||
connotation: { | ||
control: { | ||
type: 'select', | ||
options: ['primary', 'cta', 'success', 'error', 'info', 'announcement'], | ||
} | ||
}, | ||
disabled: { | ||
control: { | ||
type: 'inline-radio', | ||
options: { 'true': '', 'false': undefined } | ||
} | ||
}, | ||
styles: { table: { disable: true } }, | ||
} |
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,41 @@ | ||
import '@vonage/vwc-dialog/vwc-dialog.js'; | ||
import '@vonage/vwc-button'; | ||
import { html } from 'lit-element'; | ||
import { spread } from '@open-wc/lit-helpers'; | ||
import { argTypes } from './arg-types.js'; | ||
|
||
export default { | ||
title: 'Components/Atoms/Dialog', | ||
component: 'vwc-dialog', | ||
argTypes | ||
}; | ||
|
||
const Template = args => html` | ||
<vwc-button @click="${handleOpenDialogClick}">Open dialog</vwc-button> | ||
<vwc-dialog ...=${spread(args)}> | ||
<div>This is the modal's content.</div> | ||
<vwc-button | ||
slot="primaryAction" | ||
dialogAction="discard"> | ||
Discard | ||
</vwc-button> | ||
<vwc-button | ||
slot="secondaryAction" | ||
dialogAction="cancel"> | ||
Cancel | ||
</vwc-button> | ||
</vwc-dialog> | ||
`; | ||
|
||
export const Basic = Template.bind({}); | ||
Basic.args = { id: 'dialog-a' }; | ||
|
||
export const Heading = Template.bind({}); | ||
Heading.args = { id: 'dialog-a', heading: 'Hello Modal!'}; | ||
|
||
export const Stacked = Template.bind({}); | ||
Stacked.args = { id: 'dialog-a', stacked: ''}; | ||
|
||
function handleOpenDialogClick(e) { | ||
e.target.parentNode.querySelector('#dialog-a').show(); | ||
} |
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,28 @@ | ||
import '../vwc-dialog.js'; | ||
import { | ||
waitNextTask, | ||
textToDomToParent, | ||
isolatedElementsCreation, | ||
} from '../../../test/test-helpers.js'; | ||
import { chaiDomDiff } from '@open-wc/semantic-dom-diff'; | ||
|
||
chai.use(chaiDomDiff); | ||
|
||
const COMPONENT_NAME = 'vwc-dialog'; | ||
|
||
describe('Dialog', () => { | ||
let addElement = isolatedElementsCreation(); | ||
|
||
it(`${COMPONENT_NAME} is defined as a custom element`, async () => { | ||
assert.exists(customElements.get(COMPONENT_NAME)); | ||
}); | ||
|
||
it('should internal contents', async () => { | ||
const addedElements = addElement( | ||
textToDomToParent(`<${COMPONENT_NAME}>Button Text</${COMPONENT_NAME}>`) | ||
); | ||
const actualElement = addedElements[0]; | ||
await waitNextTask(); | ||
expect(actualElement.shadowRoot.innerHTML).to.equalSnapshot(); | ||
}); | ||
}); |
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,26 @@ | ||
{ | ||
"extends": "../../tsconfig.settings.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"rootDir": "src", | ||
"outDir": "./", | ||
"tsBuildInfoFile": ".tsbuildinfo" | ||
}, | ||
"include": [ | ||
"src/*.ts" | ||
], | ||
"exclude": [ | ||
"src/test/*.ts" | ||
], | ||
"references": [ | ||
{ | ||
"path": "../../common/core" | ||
}, | ||
{ | ||
"path": "../../common/foundation" | ||
}, | ||
{ | ||
"path": "../../common/style-coupling" | ||
} | ||
] | ||
} |
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,10 @@ | ||
const fetchOriginalConfig = require('./karma.conf'); | ||
|
||
const browsers = [process.env.RUN === 'CI' ? 'ChromeHeadless' : 'Chrome']; | ||
module.exports = config => { | ||
const originalConfig = fetchOriginalConfig(config); | ||
originalConfig.browsers = browsers; | ||
originalConfig.autoWatch = true; | ||
originalConfig.singleRun = false; | ||
return originalConfig; | ||
}; |
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.