-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(vwc-surface): viv-510 iss-859 complex menu surface #863
Merged
Merged
Changes from 23 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
9960eb3
issue #859 initial commit
gullerya 4ec9f57
issue #859: initial content
gullerya cedea0c
fixing depcheck
gullerya 3ada760
merging with master
gullerya b671823
merging with remote
gullerya 7684e48
wip
gullerya 3707a37
wip
gullerya 56de34f
wip
gullerya 0074c32
issue #859: refactored surface to use our own wrapper
gullerya 4fa625e
issue #859: fixing the tests
gullerya e95b14a
issue #859: added complex drop down
gullerya c9bdca4
issue #859: added complex drop down
gullerya ec0fdb6
fixing dependencies
gullerya 4eaac7e
fixing Sonar issues
gullerya 58e0b28
Merge branch 'master' into viv-510/iss-859-complex-menu-surface
yinonov 82dd6c3
issue #859: replaces mwc-list with vwc-list in menu
gullerya 0f999f6
merging with remote
gullerya 8e49813
issue #859: additional cleanups
gullerya e5025db
fix tests
gullerya d475535
fixing CR remarks
gullerya 8375b78
fixing CR remarks
gullerya 27a1c4f
merge with master
gullerya 29faa24
issue #859: fixed as per CR remarks
gullerya c26ee81
issue #859: fixing CR remarks
gullerya 13fbddb
issue #859: fixing the dark theme
gullerya 02b0fc1
issue #859: removing unneeded variables
gullerya ebec32f
issue #859: removing unneeded variables
gullerya 8cb11c2
issue #859: removing unneeded variables
gullerya 66bf336
fixed a story: added dense and opening the dropdown on the start
gullerya 6391848
adding chevron icon to the dropper
gullerya 06d7003
refine story
yinonov 7d8f153
issue #859: fixing CR remarks
gullerya e8febbe
merged with remote
gullerya 914bc7e
issue #859: refactored surface styles
gullerya d93c6a7
issue #859: refactored surface styles
gullerya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,31 @@ | ||
# `dropdown` | ||
|
||
#### `should have internal contents` | ||
|
||
```html | ||
<vwc-surface | ||
class="mdc-menu mdc-menu-surface" | ||
hidden="" | ||
> | ||
<div class="dropdown-content"> | ||
<div class="header section"> | ||
<slot name="header"> | ||
</slot> | ||
</div> | ||
<div class="body section"> | ||
<slot> | ||
</slot> | ||
</div> | ||
<div class="actions section"> | ||
<slot name="actions"> | ||
</slot> | ||
</div> | ||
<div class="footer section"> | ||
<slot name="footer"> | ||
</slot> | ||
</div> | ||
</div> | ||
</vwc-surface> | ||
|
||
``` | ||
|
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
Empty file.
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,39 @@ | ||
{ | ||
"name": "@vonage/vwc-dropdown", | ||
"version": "2.9.1", | ||
"description": "dropdown component", | ||
"homepage": "https://github.com/Vonage/vivid/tree/master/components/dropdown#readme", | ||
"license": "ISC", | ||
"main": "vwc-dropdown.js", | ||
"module": "vwc-dropdown.js", | ||
"files": [ | ||
"*.js", | ||
"*.ts", | ||
"*.map" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/vonage/vivid.git", | ||
"directory": "components/dropdown" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: run tests from root\" && exit 1", | ||
"build:typescript": "tsc -b", | ||
"build:styles": "umbrella-style-modules", | ||
"build": "yarn run build:styles && yarn run build:typescript" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Vonage/vivid/issues" | ||
}, | ||
"dependencies": { | ||
"@vonage/vvd-core": "2.9.1", | ||
"@vonage/vwc-menu": "2.9.1", | ||
"@vonage/vwc-surface": "2.9.1", | ||
"lit-element": "^2.4.0", | ||
"tslib": "^2.0.3" | ||
}, | ||
"devDependencies": { | ||
"@vonage/vvd-umbrella": "2.9.1", | ||
"typescript": "^4.1.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,75 @@ | ||
### `vwc-dropdown` | ||
|
||
`vwc-dropdown` is a surfacing content component, dropdown, showing up on demand, eg upon user action. | ||
`vwc-dropdown`, in contrast to `vwc-menu`, allows a free content provided by consumer, while structuring the internal body with slots: `header`, `footer` and the default content. | ||
|
||
### Usage | ||
|
||
Usage example: | ||
```html | ||
<vwc-menu> | ||
<vwc-textfield slot="header">Item 1</vwc-textfield> | ||
<div> | ||
any HTML content can go here as main body | ||
</div> | ||
<vwc-button slot="footer">Done</vwc-button> | ||
</vwc-menu> | ||
``` | ||
|
||
Initiate `vwc-dropdown` to be available in your component/application: | ||
```javascript | ||
import '@vonage/vwc-dropdown'; | ||
|
||
// or, to be able to use casting in TypeScript, do | ||
|
||
import { VWCDropdown } from '@vonage/vwc-dropdown'; | ||
``` | ||
|
||
### API | ||
|
||
`vwc-dropdown` exposes several APIs to provide its fuctionality, namely properties, methods and events. | ||
|
||
#### Properties | ||
|
||
| Property | Modifiers | Type | Description | | ||
|---------------------------|-----------|--------------------------------------------------|--------------------------------------------------| | ||
| `absolute` | | `boolean` | | | ||
| `activatable` | | `boolean` | | | ||
| `anchor` | | `HTMLElement \| null` | | | ||
| `corner` | | `"TOP_LEFT" \| "TOP_RIGHT" \| "BOTTOM_LEFT" \| "BOTTOM_RIGHT" \| "TOP_START" \| "TOP_END" \| "BOTTOM_START" \| "BOTTOM_END"` | | | ||
| `defaultFocus` | | `"NONE" \| "LIST_ROOT" \| "FIRST_ITEM" \| "LAST_ITEM"` | | | ||
| `fixed` | | `boolean` | | | ||
| `forceGroupSelection` | | `boolean` | | | ||
| `fullwidth` | | `boolean` | | | ||
| `index` | readonly | `MWCListIndex` | | | ||
| `innerRole` | | `"menu" \| "listbox"` | | | ||
| `items` | readonly | `ListItemBase[]` | | | ||
| `menuCorner` | | `MenuCorner` | | | ||
| `multi` | | `boolean` | | | ||
| `open` | | `boolean` | | | ||
| `quick` | | `boolean` | | | ||
| `selected` | readonly | `ListItemBase \| ListItemBase[] \| null` | | | ||
| `slotElement` | | `HTMLSlotElement \| null` | | | ||
| `wrapFocus` | | `boolean` | | | ||
| `x` | | `number \| null` | | | ||
| `y` | | `number \| null` | | | ||
|
||
#### Methods | ||
|
||
| Method | Type | | ||
|-----------------------|----------------------------------------------| | ||
| `close` | `(): void` | | ||
| `focusItemAtIndex` | `(index: number): void` | | ||
| `getFocusedItemIndex` | `(): number` | | ||
| `layout` | `(updateItems?: boolean \| undefined): void` | | ||
| `select` | `(index: MWCListIndex): void` | | ||
| `show` | `(): void` | | ||
|
||
#### Events | ||
|
||
| Event | Description | | ||
|-----------------|------------------| | ||
| `action` | {ActionDetail} | | ||
| `closed` | | | ||
| `opened` | | | ||
| `selected` | {SelectedDetail} | |
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,23 @@ | ||||||
.dropdown-content { | ||||||
padding: 24px; | ||||||
} | ||||||
|
||||||
.section { | ||||||
display: flex; | ||||||
} | ||||||
|
||||||
.section.body { | ||||||
display: block; | ||||||
width: calc(100% + 48px); | ||||||
margin-inline-start: -24px; | ||||||
} | ||||||
|
||||||
// actions | ||||||
.section.actions { | ||||||
display: flex; | ||||||
justify-content: flex-end; | ||||||
|
||||||
::slotted(vwc-button) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've tried several syntaxes, nothing worked to me... |
||||||
margin-inline-start: 8px; | ||||||
} | ||||||
} |
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,63 @@ | ||
import '@vonage/vvd-core'; | ||
import '@vonage/vwc-surface'; | ||
import { VWCMenu } from '@vonage/vwc-menu'; | ||
import { customElement, html } from 'lit-element'; | ||
import { style as vwcDropdownStyle } from './vwc-dropdown.css'; | ||
|
||
export const COMPONENT_NAME = 'vwc-dropdown'; | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
[COMPONENT_NAME]: VWCDropdown; | ||
} | ||
} | ||
|
||
/** | ||
* This component is an extension of [<vwc-menu>](https://github.com/Vonage/vivid/tree/master/components/menu) | ||
*/ | ||
@customElement('vwc-dropdown') | ||
export class VWCDropdown extends VWCMenu { | ||
static styles = [vwcDropdownStyle]; | ||
|
||
constructor() { | ||
super(); | ||
this.multi = true; | ||
} | ||
|
||
render() { | ||
return html` | ||
<vwc-surface | ||
?hidden=${!this.open} | ||
.anchor=${this.anchor} | ||
.open=${this.open} | ||
.quick=${this.quick} | ||
.corner=${this.corner} | ||
.x=${this.x} | ||
.y=${this.y} | ||
.absolute=${this.absolute} | ||
.fixed=${this.fixed} | ||
.fullwidth=${this.fullwidth} | ||
.menuCorner=${this.menuCorner} | ||
?stayOpenOnBodyClick=${this.stayOpenOnBodyClick} | ||
class="mdc-menu mdc-menu-surface" | ||
@closed=${this.onClosed} | ||
@opened=${this.onOpened} | ||
@keydown=${this.onKeydown}> | ||
<div class="dropdown-content"> | ||
<div class="section header"> | ||
<slot name="header"></slot> | ||
</div> | ||
<div class="section body"> | ||
<slot></slot> | ||
</div> | ||
<div class="section actions"> | ||
<slot name="actions"></slot> | ||
</div> | ||
<div class="section footer"> | ||
<slot name="footer"></slot> | ||
</div> | ||
</div> | ||
</vwc-surface> | ||
`; | ||
} | ||
} |
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 @@ | ||
export { argTypes } from '@vonage/vwc-menu/stories/arg-types.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { argTypes } from './arg-types.js'; | ||
|
||
export default { | ||
title: 'Alpha/Components/Dropdown', | ||
component: 'vwc-dropdown', | ||
argTypes | ||
} | ||
|
||
export { ComplexContent } from './dropdown-basic.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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import '@vonage/vwc-dropdown'; | ||
import '@vonage/vwc-button'; | ||
import '@vonage/vwc-list/vwc-list-item.js'; | ||
import '@vonage/vwc-list/vwc-check-list-item.js'; | ||
import { html } from 'lit-element'; | ||
import { spread } from '@open-wc/lit-helpers'; | ||
|
||
const TemplateA = args => html` | ||
<style> | ||
html, body { | ||
height: 100%; | ||
} | ||
</style> | ||
<div style="position: relative"> | ||
<vwc-button id="button" label="Open dropdown" @click="${anchorClickHandler}"></vwc-button> | ||
<vwc-dropdown id="dropdown" ...=${spread(args)}> | ||
<vwc-textfield slot="header" label="Do something..."></vwc-textfield> | ||
<vwc-list multi> | ||
<vwc-check-list-item left> | ||
Basic item 1 | ||
</vwc-check-list-item> | ||
<vwc-check-list-item left> | ||
Basic item 2 | ||
</vwc-check-list-item> | ||
<vwc-check-list-item left> | ||
Basic item 3 | ||
</vwc-check-list-item> | ||
<vwc-check-list-item left> | ||
Basic item 4 | ||
</vwc-check-list-item> | ||
</vwc-list> | ||
<vwc-button slot="actions" @click="${actionClickHandler}">Cancel</vwc-button> | ||
<vwc-button slot="actions" layout="filled" @click="${actionClickHandler}">Done</vwc-button> | ||
</vwc-dropdown> | ||
</div> | ||
`; | ||
|
||
export const ComplexContent = TemplateA.bind({}); | ||
ComplexContent.args = { | ||
corner: 'BOTTOM_START' | ||
} | ||
|
||
function anchorClickHandler() { | ||
const anchor = document.querySelector('#button'); | ||
const dropdown = document.querySelector('#dropdown'); | ||
dropdown.anchor = anchor; | ||
dropdown.open = true; | ||
} | ||
|
||
function actionClickHandler() { | ||
const dropdown = document.querySelector('#dropdown'); | ||
dropdown.open = false; | ||
} |
14 changes: 14 additions & 0 deletions
14
components/dropdown/stories/dropdown-introduction.config.mjs
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,14 @@ | ||
export default { | ||
sourcePath: '../readme.md', | ||
outputName: 'dropdown-introduction', | ||
story: { | ||
title: 'Alpha/Components/Dropdown/Introduction', | ||
name: 'Introduction', | ||
parameters: { | ||
options: { | ||
showPanel: false, | ||
isToolshown: false | ||
} | ||
} | ||
} | ||
}; |
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,29 @@ | ||
import '@vonage/vwc-list/vwc-list-item'; | ||
import { COMPONENT_NAME } from '../vwc-dropdown.js'; | ||
import { | ||
isolatedElementsCreation, | ||
waitNextTask, | ||
textToDomToParent | ||
} from '../../../test/test-helpers.js'; | ||
import { chaiA11yAxe } from 'chai-a11y-axe'; | ||
|
||
chai.use(chaiA11yAxe); | ||
|
||
describe('menu a11y', () => { | ||
const addElement = isolatedElementsCreation(); | ||
|
||
it('should have 0 accessibility violations', async () => { | ||
const [actualElement] = addElement( | ||
textToDomToParent(` | ||
<${COMPONENT_NAME}> | ||
<vwc-list-item>Item 0</vwc-list-item> | ||
<vwc-list-item>Item 1</vwc-list-item> | ||
<vwc-list-item>Item 2</vwc-list-item> | ||
</${COMPONENT_NAME}> | ||
`) | ||
); | ||
await waitNextTask(); | ||
|
||
await expect(actualElement).shadowDom.to.be.accessible(); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest defining a variable as we discussed for each of the sections
that way we have full control. what do you say?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented!