diff --git a/components/select/readme.md b/components/select/readme.md index 1e38bf639..84e577f41 100644 --- a/components/select/readme.md +++ b/components/select/readme.md @@ -40,21 +40,22 @@ the text/content within the items is for **labeling** purposes only, should be c #### Properties -| Property | Modifiers | Type | Description | -|---------------------------|-----------|--------------------------------------------------|--------------------------------------------------| -| `disabled` | | `boolean` | | -| `helper` | | `string` | | -| `icon` | | `string` | | -| `index` | readonly | `number` | | -| `items` | readonly | `ListItemBase[]` | | -| `label` | | `string` | | -| `naturalMenuWidth` | | `boolean` | | -| `outlined` | | `boolean` | | -| `required` | | `boolean` | | -| `selected` | readonly | `ListItemBase \| null` | | -| `validateOnInitialRender` | | `boolean` | | -| `validationMessage` | | `string` | | -| `value` | | `string` | | +| Property | Modifiers | Type | Description | +|---------------------------|-----------|------------------|-----------------| +| `disabled` | | `boolean` | | +| `helper` | | `string` | | +| `icon` | | `string` | | +| `index` | readonly | `number` | | +| `items` | readonly | `ListItemBase[]` | | +| `label` | | `string` | | +| `naturalMenuWidth` | | `boolean` | | +| `outlined` | | `boolean` | | +| `required` | | `boolean` | | +| `selected` | readonly | `ListItemBase \ | null` | | +| `validateOnInitialRender` | | `boolean` | | +| `validationMessage` | | `string` | | +| `value` | | `string` | | +| `appearance` | | `ghost` | no input border | #### Methods diff --git a/components/select/src/vwc-select.scss b/components/select/src/vwc-select.scss index 5884b398b..29b41652c 100644 --- a/components/select/src/vwc-select.scss +++ b/components/select/src/vwc-select.scss @@ -188,6 +188,7 @@ vwc-notched-outline { --mdc-notched-outline-border-color: var( --mdc-select-outlined-idle-border-color ); + } :host(:not([disabled])) .mdc-select.mdc-select--focused vwc-notched-outline, @@ -206,7 +207,7 @@ vwc-notched-outline { ) ); -:host([ghost][dense]) { +:host([appearance='ghost'i][dense]) { .mdc-select .mdc-floating-label { left: 0; } diff --git a/components/select/src/vwc-select.ts b/components/select/src/vwc-select.ts index 9e6428027..953d5da85 100644 --- a/components/select/src/vwc-select.ts +++ b/components/select/src/vwc-select.ts @@ -14,7 +14,7 @@ import { style as styleCoupling } from '@vonage/vvd-style-coupling/mdc-vvd-coupl import { style as vwcSelectStyle } from './vwc-select.css.js'; import { styles as mwcSelectStyles } from '@material/mwc-select/mwc-select.css.js'; import { associateWithForm } from '@vonage/vvd-foundation/form-association.js'; -import type { Shape } from '@vonage/vvd-foundation/constants.js'; +import type { Shape, Layout } from '@vonage/vvd-foundation/constants.js'; import { handleAutofocus } from '@vonage/vvd-foundation/general-utils.js'; declare global { @@ -30,6 +30,7 @@ const DROPDOWN_ICON_CLASS = 'vvd-select-dropdown-icon'; MWCSelect.styles = [styleCoupling, mwcSelectStyles, vwcSelectStyle]; type SelectShape = Extract; +type SelectLayout = Extract; /** * This component is an extension of [](https://github.com/material-components/material-components-web-components/tree/master/packages/select) @@ -48,8 +49,9 @@ export class VWCSelect extends MWCSelect { @property({ type: String, reflect: true }) name: string | undefined; - @property({ type: Boolean, reflect: true, attribute: 'ghost' }) - ghost = false; + @property({ type: String, reflect: true }) + appearance?: SelectLayout; + override connectedCallback(): void { super.connectedCallback(); @@ -67,7 +69,7 @@ export class VWCSelect extends MWCSelect { protected override update(changedProperties: PropertyValues): void { super.update(changedProperties); - if (this.shape === 'pill' || this.ghost) { + if (this.shape === 'pill' || this.appearance === 'ghost') { this.dense = true; } } diff --git a/components/select/stories/select.stories.js b/components/select/stories/select.stories.js index d9f5190a5..41c2f2c76 100644 --- a/components/select/stories/select.stories.js +++ b/components/select/stories/select.stories.js @@ -36,8 +36,17 @@ DenseNoLabel.args = { dense: '' }; export const PillAutoDense = Template.bind({}); PillAutoDense.args = { shape: 'pill', label: 'VWC Select' }; -export const GhostLayoutAutoDense = Template.bind({}); -GhostLayoutAutoDense.args = { ghost: '', label: 'VWC Select' }; +const TemplateGhost = args => html` + + Select one + Item 0 + Item 1 + Item 2 + Item 3 + { }); describe(`ghost`, function () { - it(`should set dense to true if ghost is set`, async function () { + it(`should set dense to true if appearance is ghost`, async function () { const [select] = addElement( textToDomToParent(` <${COMPONENT_NAME}> @@ -483,7 +484,7 @@ describe('select', () => { const denseValueBeforeGhost = select.dense; - select.ghost = true; + select.appearance = 'ghost'; await select.updateComplete; const denseValueAfterGhost = select.dense; diff --git a/ui-tests/snapshots/vwc-select.png b/ui-tests/snapshots/vwc-select.png index f49dd52da..3da0532a9 100644 Binary files a/ui-tests/snapshots/vwc-select.png and b/ui-tests/snapshots/vwc-select.png differ diff --git a/ui-tests/tests/vwc-select/index.js b/ui-tests/tests/vwc-select/index.js index 20182e3c8..827d852a4 100644 --- a/ui-tests/tests/vwc-select/index.js +++ b/ui-tests/tests/vwc-select/index.js @@ -5,7 +5,7 @@ import '@vonage/vwc-list/vwc-list-item.js'; export async function createElementVariations(wrapper) { const textElementWrapper = document.createElement('div'); textElementWrapper.innerHTML = ` - +
- + + none + + Item 0 + + + Item 1 + + + Item 2 + + + Item 3 is long + + +
+