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

feat(vwc-tags): 1st component draft #1016

Merged
merged 226 commits into from
Oct 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
226 commits
Select commit Hold shift + click to select a range
dd146c4
chore(workspace): update mwc version to 0.22.1
yinonov Jul 15, 2021
9d2359a
initial commit
Jul 29, 2021
8106295
Merge branch 'master' into viv-652-chips
Aug 10, 2021
5d7c331
Chip component (wip)
Aug 11, 2021
241673b
added varying size padding
Aug 11, 2021
ca9753a
added enumerations
Aug 11, 2021
e4ab795
removed comments
Aug 11, 2021
b8d80a7
added readme
Aug 11, 2021
caceb12
added stories
Aug 11, 2021
15c7ccb
Merge branch 'master' into viv-652-chips
yinonov Aug 15, 2021
8d26753
Merge branch 'master' into viv-652-chips
yinonov Aug 15, 2021
eeebe3c
update style
yinonov Aug 15, 2021
f22d245
Merge branch 'viv-652-chips' of https://github.com/Vonage/vivid into …
yinonov Aug 15, 2021
62f1d4d
contrast in layout
yinonov Aug 15, 2021
d8ac665
partial design match
yinonov Aug 15, 2021
b1cda8a
Merge branch 'master' into viv-652-chips
yinonov Aug 16, 2021
e4785ea
build(workspace): align dependencies versions
yinonov Aug 16, 2021
fc056a3
unrelated package
yinonov Aug 16, 2021
4399a85
typo
yinonov Aug 16, 2021
f984b85
typo
yinonov Aug 16, 2021
1724d2e
wrong dep
yinonov Aug 16, 2021
eb594e8
Merge branch 'master' into dependecies-alignment
yinonov Aug 16, 2021
2eb3f27
Merge branch 'dependecies-alignment' into viv-652-chips
yinonov Aug 16, 2021
29957d3
revert
yinonov Aug 16, 2021
eff5d11
revert
yinonov Aug 16, 2021
d55ae3e
revert
yinonov Aug 16, 2021
d4b82b8
revert
yinonov Aug 16, 2021
73a7a4b
revert
yinonov Aug 16, 2021
fc56928
Merge branch 'dependecies-alignment' into viv-652-chips
yinonov Aug 16, 2021
c94b41e
typo
yinonov Aug 16, 2021
23eb06b
Merge branch 'master' into viv-652-chips
yinonov Aug 16, 2021
581b2b6
filter chip
yinonov Aug 16, 2021
b549559
Merge branch 'viv-652-chips' of https://github.com/Vonage/vivid into …
yinonov Aug 16, 2021
f4b07db
filter progress
yinonov Aug 16, 2021
6980aea
correct style
yinonov Aug 16, 2021
da1ab2d
selected behavior ok
yinonov Aug 17, 2021
0946758
chip selected
yinonov Aug 17, 2021
4b27a9f
transition
yinonov Aug 17, 2021
47beb1a
Merge branch 'master' into viv-652-chips
yinonov Aug 17, 2021
4e541d1
Merge branch 'master' into viv-652-chips
yinonov Aug 18, 2021
714b134
button is of type button
yinonov Aug 18, 2021
a38beba
try elevation
yinonov Aug 19, 2021
8e24114
duotone layout
yinonov Aug 19, 2021
c7dac00
support outlined in badge
yinonov Aug 19, 2021
70dda32
refactor(vvd-foundation): harden fallback style of connotation
yinonov Aug 19, 2021
7a28ab6
no need of value
yinonov Aug 19, 2021
fbbe569
remove duplicate selector
yinonov Aug 19, 2021
6e9b989
extract template
yinonov Aug 19, 2021
a314208
story suggestion
yinonov Aug 19, 2021
7e1ff4a
remove index.html
yinonov Aug 19, 2021
2c5d14e
fixed compound
yinonov Aug 19, 2021
be7856f
fixed compound
yinonov Aug 19, 2021
002155f
fixed compound
yinonov Aug 19, 2021
6018b88
refactoring connotation
yinonov Aug 20, 2021
7e1fa28
vwc-text pass
yinonov Aug 20, 2021
2ea78b6
badge & text updated
yinonov Aug 20, 2021
a3c6e09
note, snackbar, switch
yinonov Aug 20, 2021
7460c79
banner, button
yinonov Aug 20, 2021
af88c05
circular-progress, chip
yinonov Aug 20, 2021
d751c86
chip, icon-button
yinonov Aug 20, 2021
a1cc0c5
irrelevant chip, list-item
yinonov Aug 20, 2021
24bc9bc
context
yinonov Aug 20, 2021
bbcbc7c
refactoring
yinonov Aug 21, 2021
311d8b5
typos
yinonov Aug 21, 2021
1be5e99
updates
yinonov Aug 21, 2021
1cf8a1d
update
yinonov Aug 21, 2021
d45f974
snackbar ui snapshot
yinonov Aug 21, 2021
a09d987
fix stories
yinonov Aug 21, 2021
26abec5
revert duotone
yinonov Aug 21, 2021
6e0183a
Merge branch 'harden-connotation-default-style' into viv-652-chips
yinonov Aug 21, 2021
c1d4014
align with new connotation
yinonov Aug 22, 2021
849245c
premature accent shade
yinonov Aug 22, 2021
34a5249
rename variables
yinonov Aug 22, 2021
1ed3d78
Merge branch 'master' into viv-652-chips
yinonov Aug 25, 2021
b445481
update deps versions
yinonov Aug 25, 2021
470b4ed
rename chips to tags, ui-tests
yinonov Aug 26, 2021
95ec3a7
refactor(vvd-foundation): layout to mixin convention
yinonov Aug 26, 2021
360f9dc
layout refactored
yinonov Aug 26, 2021
c7224d8
layout aligned
yinonov Aug 26, 2021
50957fb
refactored layout
yinonov Aug 27, 2021
ca32670
experimental
yinonov Aug 27, 2021
ae31ed3
refactored layout
yinonov Aug 28, 2021
ddddc57
update button & icon-button
yinonov Aug 28, 2021
bb9d236
button refactor
yinonov Aug 28, 2021
fa7bcbc
typos in icon-button
yinonov Aug 29, 2021
e1002b9
annotate types
yinonov Aug 29, 2021
0abe5ca
typo
yinonov Aug 29, 2021
b1a12ad
mixin subcategory
yinonov Aug 29, 2021
2738cd9
all aligned
yinonov Aug 29, 2021
f52cf11
Merge branch 'master' into layout-mixin-convention
yinonov Aug 29, 2021
423cbb5
differentiate configs names
yinonov Aug 29, 2021
db48d05
refactor(vwc-icon-button-toggle): decouple component
yinonov Aug 29, 2021
7f962c9
Merge branch 'icon-button-toggle-refactor' into layout-mixin-convention
yinonov Aug 29, 2021
8c457f9
connotation typo
yinonov Aug 29, 2021
0639823
Merge branch 'icon-button-toggle-refactor' into layout-mixin-convention
yinonov Aug 29, 2021
e0869c5
snapshot changed
yinonov Aug 29, 2021
424acfa
Merge branch 'icon-button-toggle-refactor' into layout-mixin-convention
yinonov Aug 29, 2021
5dcd973
fixed tests
yinonov Aug 29, 2021
5b7a586
Merge branch 'icon-button-toggle-refactor' into layout-mixin-convention
yinonov Aug 29, 2021
221f190
restyle toggle group
yinonov Aug 29, 2021
8e1584e
Merge branch 'master' into viv-652-chips
yinonov Aug 29, 2021
a56b83f
Merge branch 'master' into layout-mixin-convention
yinonov Aug 30, 2021
e726510
Update components/icon-button/src/vwc-icon-button.scss
yinonov Aug 30, 2021
0471436
Update components/badge/src/vwc-badge.scss
yinonov Aug 30, 2021
22b5d1c
Update components/button/src/vwc-button.scss
yinonov Aug 30, 2021
0836820
refactor(vvd-foundation): encapsulate connotation custom properties
yinonov Aug 30, 2021
29fef22
Merge branch 'layout-mixin-convention' into connotation-mixin-encapsu…
yinonov Aug 30, 2021
097bf05
mixin refactored
yinonov Aug 30, 2021
08b2a05
align with connotation
yinonov Aug 30, 2021
507e9de
Merge branch 'layout-mixin-convention' of https://github.com/Vonage/v…
yinonov Aug 30, 2021
ab27ccf
Merge branch 'layout-mixin-convention' into connotation-mixin-encapsu…
yinonov Aug 30, 2021
00a6d45
update icon-button & badge
yinonov Aug 30, 2021
0232299
Merge branch 'layout-mixin-convention' into connotation-mixin-encapsu…
yinonov Aug 30, 2021
e5106ee
icon-button & badge
yinonov Aug 30, 2021
4e7c101
scope default
yinonov Aug 30, 2021
c6f2971
Merge branch 'layout-mixin-convention' into connotation-mixin-encapsu…
yinonov Aug 30, 2021
53b434c
blockquote
yinonov Aug 30, 2021
bd20d11
snackbar
yinonov Aug 31, 2021
3a4d375
note
yinonov Aug 31, 2021
1bc7bf6
vwc-text
yinonov Aug 31, 2021
c1f0d5c
text
yinonov Aug 31, 2021
c658a70
Merge branch 'master' into connotation-mixin-encapsulation-refactor
yinonov Sep 1, 2021
9fd7ec1
need update
yinonov Sep 1, 2021
21104a3
Merge branch 'master' into mwc-update-0.22.1
yinonov Sep 1, 2021
568885c
Merge branch 'master' into connotation-mixin-encapsulation-refactor
yinonov Sep 2, 2021
6c2ca3b
remove shadow open mode workaround
yinonov Sep 2, 2021
ee7d5f1
duplicate deps
yinonov Sep 2, 2021
bdeeb78
all updated
yinonov Sep 2, 2021
8ee0f91
Merge branch 'master' into mwc-update-0.22.1
yinonov Sep 2, 2021
0eafb04
typo in styles
yinonov Sep 3, 2021
f62fa8d
snapshots fix
yinonov Sep 3, 2021
00ca1b8
fab restore
yinonov Sep 3, 2021
e1a5f39
removed Safari Fiasco
yinonov Sep 3, 2021
d4155c2
Merge branch 'mwc-update-0.22.1' into connotation-mixin-encapsulation…
yinonov Sep 3, 2021
ce39c65
switch
yinonov Sep 3, 2021
80e9fd1
switch
yinonov Sep 3, 2021
263aec7
media controller
yinonov Sep 4, 2021
48afb3b
backwards compatability for list item
yinonov Sep 5, 2021
fc0e8bc
banner & linear progress
yinonov Sep 5, 2021
721baed
audio & media controls
yinonov Sep 5, 2021
7889586
circular-progress
yinonov Sep 5, 2021
88fb225
icon
yinonov Sep 5, 2021
f106a7f
new snapshots
yinonov Sep 5, 2021
67997a4
new snapshot
yinonov Sep 5, 2021
bb566d6
banner fix
yinonov Sep 5, 2021
9d96cec
Merge branch 'master' into connotation-mixin-encapsulation-refactor
yinonov Sep 5, 2021
5afa097
banner
yinonov Sep 5, 2021
03173f6
scoping
yinonov Sep 5, 2021
e981bee
incorrect syntax
yinonov Sep 5, 2021
a39ea23
badge update
yinonov Sep 5, 2021
cd7a2fa
updates
yinonov Sep 5, 2021
9f6e13f
updates
yinonov Sep 5, 2021
3dd3008
note & controller
yinonov Sep 5, 2021
9597381
styles
yinonov Sep 5, 2021
04e2056
switch ui tests
yinonov Sep 5, 2021
06a8892
refactoring snackbar (remove note integration)
yinonov Sep 6, 2021
e725d19
modern view ready
yinonov Sep 6, 2021
b18a5a5
spacing sass var
yinonov Sep 6, 2021
3c85412
modern fixed
yinonov Sep 6, 2021
ca9756b
snackbar refactored
yinonov Sep 7, 2021
1e265b3
removed import
yinonov Sep 7, 2021
5d9219a
snackbar legacy updated
yinonov Sep 7, 2021
a676f45
snackbar layout unit test -> ui tests
yinonov Sep 7, 2021
4814bc7
fix badge connotation delegation
yinonov Sep 7, 2021
64851ee
banner fixed
yinonov Sep 7, 2021
b798fc8
patch button toggle group
yinonov Sep 7, 2021
d7d8221
icon-button-toggle fix
yinonov Sep 7, 2021
dec5b5f
icon modification
yinonov Sep 8, 2021
836b32e
card correct snapshot
yinonov Sep 8, 2021
233aef5
linear progress animated test removed
yinonov Sep 8, 2021
14bd211
fixed card & restored icon
yinonov Sep 8, 2021
97bf4c4
update ui snapshots
yinonov Sep 8, 2021
75a4225
incorrect class query
yinonov Sep 9, 2021
1550dbd
banner fixed
yinonov Sep 9, 2021
3b4be01
updates
yinonov Sep 9, 2021
f7d8e0f
button snapshot update
yinonov Sep 9, 2021
de3ae7f
fix note connotation tests
yinonov Sep 9, 2021
c1f50d8
note snapshot updated
yinonov Sep 9, 2021
ee96a36
note tests fixed
yinonov Sep 9, 2021
066e8ff
correct childrenAffected
yinonov Sep 9, 2021
2809ea5
text snapshot updated
yinonov Sep 9, 2021
58129e5
update ui snapshots
yinonov Sep 9, 2021
04aaa42
update button ref
yinonov Sep 9, 2021
a238e05
datepicker integration
yinonov Sep 9, 2021
202d860
removed irrelevant comments
yinonov Sep 9, 2021
9554017
export ButtonLayout
yinonov Sep 9, 2021
83d5e0e
renamed selector ref
yinonov Sep 9, 2021
a1328dc
rename audio-tag to audio-el
yinonov Sep 9, 2021
4adfca7
logical assignment comment removed
yinonov Sep 9, 2021
a2022dd
patch button layout type
yinonov Sep 9, 2021
f9994b8
autofocus is unreliable
yinonov Sep 9, 2021
5044894
removed comment
yinonov Sep 9, 2021
af7405c
scalable selector
yinonov Sep 10, 2021
95222f4
removed info
yinonov Sep 10, 2021
5f7422d
Merge branch 'connotation-mixin-encapsulation-refactor' into viv-652-…
yinonov Sep 10, 2021
c9a4049
update layout mixture
yinonov Sep 10, 2021
e1daedd
updates
yinonov Sep 11, 2021
1b4269b
added tags component
yinonov Sep 12, 2021
bbdaadc
remove roving ui
yinonov Sep 12, 2021
761b8ae
restore attribute
yinonov Sep 12, 2021
64ad902
remove dense enlarge
yinonov Sep 12, 2021
de873ab
Merge branch 'master' into viv-652-chips
yinonov Sep 12, 2021
99ce993
dedicate to PR
yinonov Sep 12, 2021
85deec1
PR unrelated test
yinonov Sep 12, 2021
33e1766
affected ui snapshots
yinonov Sep 12, 2021
aee73df
style review
yinonov Sep 12, 2021
d536bd7
outline-duotone
yinonov Sep 12, 2021
ae44aee
Merge branch 'layout-color-refs' into viv-652-chips
yinonov Sep 12, 2021
3d5530d
update variables
yinonov Sep 12, 2021
ae4779b
update yarn lock
yinonov Sep 12, 2021
fc40e92
tags aligned
yinonov Sep 12, 2021
231bb4c
badge & tag ok
yinonov Sep 12, 2021
a2372bd
Merge branch 'master' into viv-652-chips
yinonov Sep 13, 2021
3e7d334
Merge branch 'master' of https://github.com/Vonage/vivid into viv-652…
rinaok Oct 3, 2021
a7f92b2
merge
rinaok Oct 3, 2021
1ff1fcd
vvd-foundation
rinaok Oct 3, 2021
c6d650b
Merge branch 'master' of https://github.com/Vonage/vivid into viv-652…
rinaok Oct 3, 2021
098aa1b
type
rinaok Oct 3, 2021
335a0ea
rename chip to tag
rinaok Oct 3, 2021
ba42ed3
snapshot
rinaok Oct 3, 2021
6d5869e
add tests
rinaok Oct 3, 2021
f1ba945
Update components/tags/test/tag.test.js
yinonov Oct 3, 2021
1928037
Update components/tags/src/vwc-tag.ts
yinonov Oct 3, 2021
49db3ff
align versions
yinonov Oct 3, 2021
8f6f5ca
Update components/tags/src/vwc-tag.ts
yinonov Oct 3, 2021
78cea45
update snapshots
yinonov Oct 3, 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
10 changes: 10 additions & 0 deletions __snapshots__/Tag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# `Tag`

#### `should internal contents`

```html
<span class="vwc-tag">
</span>

```

1 change: 0 additions & 1 deletion components/audio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
},
"devDependencies": {
"@vonage/vvd-design-tokens": "2.18.1",
"@vonage/vvd-foundation": "2.14.0",
"@vonage/vvd-typography": "2.18.1",
"@vonage/vvd-umbrella": "2.18.1",
"typescript": "^4.3.2"
Expand Down
39 changes: 39 additions & 0 deletions components/tags/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "@vonage/vwc-tags",
"version": "2.18.1",
"description": "tags component",
"homepage": "https://github.com/Vonage/vivid/tree/master/components/tags#readme",
"license": "ISC",
"main": "vwc-tags.js",
"module": "vwc-tags.js",
"files": [
"*.js",
"*.ts",
"*.map"
],
"repository": {
"type": "git",
"url": "https://github.com/vonage/vivid.git",
"directory": "components/tags"
},
"scripts": {
"build:typescript": "tsc -b",
"build:styles": "umbrella-style-modules --path=\"./src\"",
"build": "yarn run build:styles && yarn run build:typescript"
},
"bugs": {
"url": "https://github.com/Vonage/vivid/issues"
},
"dependencies": {
"@material/mwc-ripple": "^0.22.1",
"@vonage/vvd-foundation": "2.18.1",
"@vonage/vvd-typography": "2.18.1",
"@vonage/vwc-icon": "2.18.1",
"lit-element": "^2.4.0",
"lit-html": "^1.3.0",
"tslib": "^2.3.0"
},
"devDependencies": {
"@vonage/vvd-umbrella": "2.18.1"
}
}
35 changes: 35 additions & 0 deletions components/tags/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# vwc-tags

## Properties

| Property | Attribute | Type |
| -------------- | -------------- | ----------------------------------------------------- |
| `connotation` | `connotation` | `Connotation.Primary \| Connotation.CTA \| undefined` |
| `dense` | `dense` | `boolean \| undefined` |
| `enlarged` | `enlarged` | `boolean \| undefined` |
| `icon` | `icon` | `string \| undefined` |
| `layout` | `layout` | `string \| undefined` |
| `selected` | `selected` | `boolean \| undefined` |
| `shape` | `shape` | `Shape.Rounded \| Shape.Pill \| undefined` |
| `text` | `text` | `string \| undefined` |
| `trailingIcon` | `trailingIcon` | `string \| undefined` |

# vwc-tag

## Properties

| Property | Type |
| -------------- | ----------------------------------------------------- |
| `connotation` | `Connotation.Primary \| Connotation.CTA \| undefined` |
| `dense` | `boolean \| undefined` |
| `enlarged` | `boolean \| undefined` |
| `icon` | `string \| undefined` |
| `layout` | `string \| undefined` |
| `selected` | `boolean \| undefined` |
| `shape` | `Shape.Rounded \| Shape.Pill \| undefined` |
| `text` | `string \| undefined` |
| `trailingIcon` | `string \| undefined` |

## Accessibility

Authors MUST ensure tags default to role _option_ are contained in, or owned by, a tags set which default to the *listbox* role. Options not associated with a listbox might not be correctly mapped to an accessibility API
6 changes: 6 additions & 0 deletions components/tags/src/partials/_vwc-tags-variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$namespace: --vvd-tag;
$namespace-shape: #{$namespace}--shape;
$namespace-block-size: #{$namespace}--block-size;
$namespace-padding-inline: #{$namespace}--padding-inline;
$namespace-icon-checkmark--size: #{$namespace}__icon-checkmark--size;
$namespace-icon-checkmark--padding-inline-end: #{$namespace}__icon-checkmark--padding-inline-end;
167 changes: 167 additions & 0 deletions components/tags/src/vwc-tag-base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import '@material/mwc-ripple/mwc-ripple';
import type { Ripple } from '@material/mwc-ripple/mwc-ripple';
import { RippleHandlers } from '@material/mwc-ripple/ripple-handlers';

import type { Connotation, Shape, Layout } from '@vonage/vvd-foundation/constants';
import { ClassInfo, classMap } from 'lit-html/directives/class-map';
import {
LitElement, html, property, TemplateResult, queryAsync, state, query, eventOptions
} from 'lit-element';


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

type TagShape = Extract<Shape, Shape.Rounded | Shape.Pill>;

type TagLayout = Extract<
Layout, Layout.Outlined | Layout.Soft
>;
export class VWCTagBase extends LitElement {
@queryAsync('mwc-ripple') ripple!: Promise<Ripple|null>;

@query('#selectable') selectableElement!: HTMLElement;

@property({ type: String, reflect: true })
text?: string;

@property({ type: Boolean, reflect: true })
selected = false;

@property({ type: String, reflect: true })
connotation?: TagConnotation;

@property({ type: String, reflect: true })
shape?: TagShape;

@property({ type: String, reflect: true })
layout?: TagLayout;

@property({ type: Boolean, reflect: true })
selectable = false;

@state() protected shouldRenderRipple = false;

protected rippleHandlers = new RippleHandlers(() => {
this.shouldRenderRipple = true;
return this.ripple;
});

focus(): void {
const selectableElement = this.selectableElement;
if (selectableElement) {
this.rippleHandlers.startFocus();
selectableElement.focus();
}
}

blur(): void {
const selectableElement = this.selectableElement;
if (selectableElement) {
this.rippleHandlers.endFocus();
selectableElement.blur();
}
}

// protected firstUpdated(): void {
// if (this.selected) {
// this.handleRippleActivate();
// }
// }

protected renderRipple(): TemplateResult | string {
return this.shouldRenderRipple ?
html`<mwc-ripple class="ripple"></mwc-ripple>` : '';
}

protected renderIcon(type?: string): TemplateResult {
return html`<vwc-icon class="vwc-tag__icon" .type="${type}"></vwc-icon>`;
}

protected getRenderClasses(): ClassInfo {
return {
[`connotation-${this.connotation}`]: !!this.connotation,
[`layout-${this.layout}`]: !!this.layout
};
}

protected renderTagSelectable(): TemplateResult {
const classes = {
'vwc-tag--selected': this.selected,
...this.getRenderClasses()
};

return html`<span
id="selectable"
class="vwc-tag vwc-tag-selectable ${classMap(classes)}"
role="option"
aria-selected="${this.selected}"
@focus="${this.handleRippleFocus}"
@blur="${this.handleRippleBlur}"
@mousedown="${this.handleRippleActivate}"
@mouseenter="${this.handleRippleMouseEnter}"
@mouseleave="${this.handleRippleMouseLeave}"
@touchstart="${this.handleRippleActivate}"
@touchend="${this.handleRippleDeactivate}"
@touchcancel="${this.handleRippleDeactivate}"
@click="${() => this.selected = !this.selected}"
@keydown="${this.handleKeydown}">
${this.renderRipple()}
<span class="vwc-tag__checkmark">
${this.renderIcon('check-circle-solid')}
</span>
<span class="text">
${this.text}
</span>
</span>`;
}

render(): TemplateResult {
return this.selectable
? this.renderTagSelectable()
: html`<span class="vwc-tag ${classMap(this.getRenderClasses())}">
${this.text}
</span>`;
}

handleKeydown({ key }: KeyboardEvent): void {
if (key === ' '/* spacebar */) {
this.selected = !this.selected;
}
}

@eventOptions({ passive: true })
protected handleRippleActivate(evt?: Event): void {
const onUp = () => {
window.removeEventListener('mouseup', onUp);

this.handleRippleDeactivate();
};

window.addEventListener('mouseup', onUp);
this.rippleHandlers.startPress(evt);
}

protected handleRippleDeactivate(): void {
this.rippleHandlers.endPress();
}

protected handleRippleMouseEnter(): void {
this.rippleHandlers.startHover();
}

protected handleRippleMouseLeave(): void {
this.rippleHandlers.endHover();
}

protected handleRippleFocus(): void {
this.rippleHandlers.startFocus();
}

protected handleRippleBlur(): void {
this.rippleHandlers.endFocus();
}
}
128 changes: 128 additions & 0 deletions components/tags/src/vwc-tag.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
@use 'partials/vwc-tags-variables' as tags-variables;
@use '@vonage/vwc-icon/src/partials/vwc-icon-variables' as icon-variables;
@use '@vonage/vvd-design-tokens/build/scss/semantic-variables/scheme-variables' as scheme-variables;
@use '@vonage/vvd-typography/scss/typography' as typography;
@use '@vonage/vvd-foundation/scss/mixins/connotation/config' with (
$connotations-set: primary cta,
$shades: soft contrast,
$default: primary,
);
@use '@vonage/vvd-foundation/scss/mixins/connotation' as connotation;
@use '@vonage/vvd-foundation/scss/mixins/shape-mixins' as shape-mixins with (
$variable-name: #{tags-variables.$namespace-shape}
);
@use '@vonage/vvd-foundation/scss/mixins/layout/config' as layout-config with (
$layout-set: outlined soft,
$outline-duotone: true,
$default: soft
);
@use '@vonage/vvd-foundation/scss/mixins/layout' as layout;


@include shape-mixins.shape(
$shapes: (
rounded: 4px,
pill: 14px,
),
$default: pill
);

.vwc-tag {
@include typography.typography-cat-shorthand('body-2-bold');
@include connotation.connotation;
@include layout.layout;
#{tags-variables.$namespace-padding-inline}: 10px;
#{tags-variables.$namespace-icon-checkmark--padding-inline-end}: 6px;
#{tags-variables.$namespace-block-size}: 24px;
#{tags-variables.$namespace-icon-checkmark--size}: 16px;
#{layout.$vvd-layout-color-outline}: var(#{scheme-variables.$vvd-color-neutral-50});
z-index: 0;
display: inline-flex;
align-items: center;
padding: 0 var(#{tags-variables.$namespace-padding-inline});
// ignore layout outline color for this component
border-color: var(#{scheme-variables.$vvd-color-neutral-50});
background-color: var(#{layout.$vvd-layout-color-fill});
block-size: var(#{tags-variables.$namespace-block-size});
border-radius: var(#{tags-variables.$namespace-shape});
color: var(#{layout.$vvd-layout-color-text});
vertical-align: top;

&.layout-outlined {
box-sizing: border-box;
border-width: 1px;
border-style: solid;
}

&:not(&-selectable) {
#{layout.$vvd-layout-color-text}: var(#{scheme-variables.$vvd-color-neutral-90});
&.layout-filled,
&:not(.layout-filled):not(.layout-outlined) {
#{layout.$vvd-layout-color-fill}: var(#{scheme-variables.$vvd-color-neutral-20});
}
}

}

.vwc-tag-selectable {
position: relative;
overflow: hidden;
cursor: pointer;

.ripple {
--mdc-ripple-color: currentColor;
}

&:not(.vwc-tag--selected) {
#{layout.$vvd-layout-color-text}: var(#{scheme-variables.$vvd-color-neutral-90});
&.layout-filled,
&:not(.layout-filled):not(.layout-outlined) {
background-color: var(#{scheme-variables.$vvd-color-neutral-20});
}
}

&.vwc-tag--selected {
&.layout-outlined {
background-color: var(#{connotation.$vvd-color-connotation}-soft);
color: var(#{connotation.$vvd-color-connotation}-contrast);
}
}
}

.vwc-tag__checkmark {
block-size: var(#{tags-variables.$namespace-icon-checkmark--size});
line-height: 1;
margin-inline-end: 0;
margin-inline-start: 0;

@media (prefers-reduced-motion: no-preference) {
transition-duration: 0.1s;
transition-property: margin-inline-start, margin-inline-end;
}
.vwc-tag.vwc-tag--selected & {
margin-inline-end: var(#{tags-variables.$namespace-icon-checkmark--padding-inline-end});
margin-inline-start: calc(4px - var(#{tags-variables.$namespace-padding-inline}));
}

> .vwc-tag__icon {
block-size: var(#{tags-variables.$namespace-icon-checkmark--size});
inline-size: var(#{tags-variables.$namespace-icon-checkmark--size});

@media (prefers-reduced-motion: no-preference) {
transition: inline-size 0.1s;
}

.vwc-tag:not(.vwc-tag--selected) & {
inline-size: 0;
}
}
}

// disable connotation if not selected
// .vwc-tag:not(.vwc-tag--selected) {
// :host([connotation="cta"i]) & {
// --vvd-color-connotation: unset;
// --vvd-color-on-connotation: unset;
// }
// }

Loading