Skip to content
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

style(list-item): add connotation support for activated list items #833

Merged
merged 33 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7ef1ff3
add connotation support
JoelGraham93 May 5, 2021
11162f5
Merge branch 'master' into viv-530-list-item-ripple
JoelGraham93 May 11, 2021
1a5613c
add basic list item story
JoelGraham93 May 11, 2021
2560a8a
remove comment
JoelGraham93 May 11, 2021
6311ea8
Merge branch 'master' into viv-530-list-item-ripple
JoelGraham93 May 11, 2021
f4aa3cd
Merge branch 'master' into viv-530-list-item-ripple
yinonov May 12, 2021
1f15cfa
Merge branch 'master' into viv-530-list-item-ripple
yinonov May 12, 2021
571a695
Merge branch 'master' into viv-530-list-item-ripple
JoelGraham93 May 13, 2021
9d8277b
prevent background hiding activated ripple
JoelGraham93 May 14, 2021
158f8ec
Merge branch 'master' into viv-530-list-item-ripple
JoelGraham93 May 16, 2021
05946fb
fix ripple indication
JoelGraham93 May 17, 2021
78dbf2d
Merge branch 'master' into viv-530-list-item-ripple
JoelGraham93 May 18, 2021
a8e2907
Merge branch 'master' into viv-530-list-item-ripple
yinonov May 20, 2021
77ad193
Merge branch 'master' into viv-530-list-item-ripple
JoelGraham93 May 20, 2021
dd1339e
proxy shape from list to list-item
JoelGraham93 May 21, 2021
6906878
update list shape tests
JoelGraham93 May 21, 2021
c2e051a
Merge branch 'master' into viv-530-list-item-ripple
yinonov May 23, 2021
156a651
proxy list connotation to list-item
JoelGraham93 May 24, 2021
9299292
add list connotation test
JoelGraham93 May 24, 2021
1457af4
Merge branch 'master' into viv-530-list-item-ripple
yinonov May 24, 2021
9fbea1b
reset branch
JoelGraham93 May 25, 2021
c7ff20b
Merge branch 'master' into viv-530-list-item-ripple
JoelGraham93 May 25, 2021
b88f016
add list-item connotation test
JoelGraham93 May 25, 2021
a613f5f
Merge branch 'master' into viv-530-list-item-ripple
yinonov May 25, 2021
074ab89
Merge branch 'viv-530-list-item-ripple' of https://github.com/Vonage/…
yinonov May 25, 2021
6ac6baa
correctly reset changes
JoelGraham93 May 25, 2021
4831050
fix list test imports
JoelGraham93 May 25, 2021
2d192e7
add list-item story
JoelGraham93 May 25, 2021
74e8065
add text-parts import
JoelGraham93 May 25, 2021
6e17a73
activated story update
yinonov May 25, 2021
a16b233
Merge branch 'viv-530-list-item-ripple' of https://github.com/Vonage/…
yinonov May 25, 2021
2f64a2e
lint story args
yinonov May 25, 2021
fa122bc
Merge branch 'master' into viv-530-list-item-ripple
JoelGraham93 May 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion components/list/src/vwc-list-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
@use '@vonage/vvd-typography/scss/typography' as typography;
@use '@vonage/vvd-design-tokens/build/scss/semantic-variables/scheme-variables' as scheme-variables;
@use '@vonage/vvd-style-coupling/scss/vvd-formfield' as vvd-formfield;
@use '@vonage/vvd-foundation/scss/mixins/color-connotation' as color-connotation with (
$connotations-set: primary cta
);
@use '@vonage/vvd-foundation/scss/mixins/shape-mixins' with (
$variable-name: --vvd-list-item-shape
);
Expand All @@ -10,6 +13,9 @@ $vvd-list-item-block-size: --vvd-list-item-block-size;
$vvd-list-item-side-padding: --vvd-list-item-side-padding;
$vvd-list-item-graphic-margin: --vvd-list-item-graphic-margin;

@include color-connotation.connotations-main;
@include color-connotation.connotations-main-default(primary);

:host {
--mdc-list-side-padding: var(#{$vvd-list-item-side-padding});
--mdc-list-item-graphic-margin: var(#{$vvd-list-item-graphic-margin});
Expand All @@ -25,14 +31,44 @@ $vvd-list-item-graphic-margin: --vvd-list-item-graphic-margin;
@include typography.typography-cat-shorthand('body-2');
@include vvd-formfield.coupling;

position: relative;
height: var(#{$vvd-list-item-block-size});

border-radius: var(--vvd-list-item-shape);

#{$vvd-list-item-block-size}: 40px;
#{$vvd-list-item-side-padding}: 24px;
#{$vvd-list-item-graphic-margin}: 16px;
}

:host([activated]) {
--mdc-theme-text-icon-on-background: var(
#{color-connotation.$vvd-color-on-connotation}
);
--mdc-theme-text-hint-on-background: var(
#{color-connotation.$vvd-color-on-connotation}
);
--mdc-ripple-color: var(#{color-connotation.$vvd-color-on-connotation});

@include typography.typography-cat-shorthand('body-2-bold');
z-index: 0;
color: var(#{color-connotation.$vvd-color-on-connotation});

mwc-ripple,
.fake-activated-ripple {
z-index: -1;
yinonov marked this conversation as resolved.
Show resolved Hide resolved
}

.fake-activated-ripple {
--mdc-ripple-activated-opacity: 1;
--mdc-ripple-color: var(#{color-connotation.$vvd-color-connotation});
}

mwc-ripple {
--mdc-ripple-activated-opacity: 0;
background-color: var(#{color-connotation.$vvd-color-connotation});
}
}

:host([graphic='icon']:not([twoline])) {
height: var(#{$vvd-list-item-block-size}); // override mwc fixed height
}
Expand Down
11 changes: 10 additions & 1 deletion components/list/src/vwc-list-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ListItem as MWCListItem } from '@material/mwc-list/mwc-list-item';
import { style as vwcListItemStyle } from './vwc-list-item.css.js';
import { style as mwcListItemStyle } from '@material/mwc-list/mwc-list-item-css.js';
import { style as styleCoupling } from '@vonage/vvd-style-coupling/mdc-vvd-coupling.css';
import { Shape } from '@vonage/vvd-foundation/constants';
import { Connotation, Shape } from '@vonage/vvd-foundation/constants';

declare global {
interface HTMLElementTagNameMap {
Expand All @@ -15,13 +15,22 @@ declare global {
// @ts-ignore
MWCListItem.styles = [styleCoupling, mwcListItemStyle, vwcListItemStyle];

type ListItemConnotation = Extract<
Connotation,
| Connotation.Primary
| Connotation.CTA
>;

type ListItemShape = Extract<Shape, Shape.Rounded>;

/**
* This component is an extension of [<mwc-list-item>](https://github.com/material-components/material-components-web-components/tree/master/packages/list)
*/
@customElement('vwc-list-item')
export class VWCListItem extends MWCListItem {
@property({ type: String, reflect: true })
connotation?: ListItemConnotation;

@property({ type: String, reflect: true })
shape?: ListItemShape;
}
28 changes: 18 additions & 10 deletions components/list/stories/arg-types-list-item.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { Shape } from '@vonage/vvd-foundation/constants';
import { Connotation, Shape } from '@vonage/vvd-foundation/constants';

export const argTypes = {
connotation: {
control: {
type: 'select',
options: Object.values(Connotation).filter(c => [
Connotation.Primary, Connotation.CTA
].includes(c)),
}
},
shape: {
control: {
type: 'select',
Expand All @@ -10,44 +18,44 @@ export const argTypes = {
twoline: {
control: {
type: 'inline-radio',
options: { 'true': '', 'false': undefined }
options: { true: '', false: undefined }
}
},
disabled: {
control: {
type: 'inline-radio',
options: { 'true': '', 'false': undefined }
options: { true: '', false: undefined }
}
},
activated: {
control: {
type: 'inline-radio',
options: { 'true': '', 'false': undefined }
options: { true: '', false: undefined }
}
},
selected: {
control: {
type: 'inline-radio',
options: { 'true': '', 'false': undefined }
options: { true: '', false: undefined }
}
},
multipleGraphics: {
control: {
type: 'inline-radio',
options: { 'true': '', 'false': undefined }
options: { true: '', false: undefined }
}
},
hasMeta: {
control: {
type: 'inline-radio',
options: { 'true': '', 'false': undefined }
options: { true: '', false: undefined }
}
},
noninteractive: {
control: {
type: 'inline-radio',
options: { 'true': '', 'false': undefined }
options: { true: '', false: undefined }
}
},
ripple: { table: { disable: true } }
}
};
17 changes: 8 additions & 9 deletions components/list/stories/list-basic.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ export const Basic = args => html`
}
</style>

<h4>Main</h4>
<div class="box">
${renderList(args)}
</div>
<h4>Alternate</h4>
<div class="box vvd-scheme-alternate">
${renderList(args)}
</div>

<h4>Main</h4>
<div class="box">
${renderList(args)}
</div>
<h4>Alternate</h4>
<div class="box vvd-scheme-alternate">
${renderList(args)}
</div>
`;

export const metaIcon = args => html`
Expand Down
41 changes: 39 additions & 2 deletions components/list/stories/list-item.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
title: 'Components/List (list item)',
component: 'vwc-list-item',
argTypes
}
};

const Template = args => html`
<style>
Expand Down Expand Up @@ -38,9 +38,20 @@ const Template = args => html`
</vwc-list-item>
</vwc-list>`;


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

export const Shape = Template.bind({});
Shape.args = { shape: 'rounded' };

export const Connotation = Template.bind({});
Connotation.args = {
connotation: 'cta',
activated: '',
shape: 'rounded',
graphic: 'icon'
};

export const TwoLine = Template.bind({});
TwoLine.args = { twoline: '', hasMeta: '' };

Expand All @@ -51,4 +62,30 @@ export const MetaIcon = Template.bind({});
MetaIcon.args = { hasMeta: '' };

export const Icon = Template.bind({});
Icon.args = { graphic: 'icon' };
Icon.args = { graphic: 'icon' };

const ActivatedTemplate = args => html`
<style>
vwc-list {
width: 240px;
}
</style>

<vwc-list>
<vwc-list-item graphic="icon">
Item A
<vwc-icon slot="graphic" type="chat" size="small"></vwc-icon>
</vwc-list-item>
<vwc-list-item ...=${spread(args)}>
Item B
<vwc-icon slot="graphic" type="chat" size="small"></vwc-icon>
</vwc-list-item>
<vwc-list-item graphic="icon">
Item C
<vwc-icon slot="graphic" type="chat" size="small"></vwc-icon>
</vwc-list-item>
</vwc-list>`;


export const Activated = ActivatedTemplate.bind({});
Activated.args = { activated: '' };
22 changes: 22 additions & 0 deletions components/list/test/list-item.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,28 @@ describe('list item', () => {
});
});

describe('connotation', () => {
let listItem,
ripple;
beforeEach(async () => {
[listItem] = addElement(
textToDomToParent(`<vwc-list-item activated>Item 1</vwc-list-item>`)
);
await waitNextTask();
ripple = listItem.shadowRoot.querySelector('.fake-activated-ripple');
});

it('should proxy primary connotation to activated list-item by default', async () => {
assertComputedStyle(ripple, { backgroundColor: 'rgb(0,0,0)' }, ':before');
});

it('should proxy cta connotation to activated list-item when connotation set to cta', async () => {
listItem.connotation = 'cta';
await waitNextTask();
assertComputedStyle(ripple, { backgroundColor: 'rgb(153,65,255)' }, ':before');
});
});

describe('shape', () => {
let actualElement;
beforeEach(async () => {
Expand Down