Skip to content

Commit

Permalink
[DPEDE-3088] Add styles and visual tests for tags component (#1460)
Browse files Browse the repository at this point in the history
  • Loading branch information
ASanchLumen authored Dec 19, 2024
1 parent 268bf00 commit c7098d4
Show file tree
Hide file tree
Showing 19 changed files with 258 additions and 0 deletions.
23 changes: 23 additions & 0 deletions backstop-non-responsive-ce.json
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,29 @@
"misMatchThreshold": 0,
"requireSameDimensions": true
},
{
"label": "tags",
"cookiePath": "",
"url": "http://localhost:8000/tests/custom-elements/tags.html",
"referenceUrl": "",
"readyEvent": "",
"readySelector": "",
"delay": 0,
"hideSelectors": [],
"removeSelectors": [],
"hoverSelector": "",
"clickSelector": "",
"postInteractionWait": "",
"selectors": [
".test-base",
".test-with-tags",
".test-with-tags-focused",
".test-with-tags-hover"
],
"selectorExpansion": true,
"misMatchThreshold": 0,
"requireSameDimensions": true
},
{
"label": "textarea",
"cookiePath": "",
Expand Down
23 changes: 23 additions & 0 deletions backstop-non-responsive.json
Original file line number Diff line number Diff line change
Expand Up @@ -1641,6 +1641,29 @@
"misMatchThreshold": 0,
"requireSameDimensions": true
},
{
"label": "tags",
"cookiePath": "",
"url": "http://localhost:8000/tests/components/tags.html",
"referenceUrl": "",
"readyEvent": "",
"readySelector": "",
"delay": 0,
"hideSelectors": [],
"removeSelectors": [],
"hoverSelector": "",
"clickSelector": "",
"postInteractionWait": "",
"selectors": [
".test-base",
".test-with-tags",
".test-with-tags-focused",
".test-with-tags-hover"
],
"selectorExpansion": true,
"misMatchThreshold": 0,
"requireSameDimensions": true
},
{
"label": "textarea",
"cookiePath": "",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions src/chi/components/tags/tags.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@import '_global-variables';
@import '_global-mixins';

.chi-tags {
border: 0.0625rem solid $tags-border-color;
border-radius: $tags-border-radius;
color: $tags-text-color;
display: flex;
height: $tags-md-height;
font-size: $tags-md-font-size;
line-height: $tags-md-line-height;
padding: $tags-md-padding;
outline: none;
transition: all 0.15s ease-in-out;
width: 100%;
align-items: center;
margin: 0;
background-color: white;

&:focus-within,
&.-focus {
border-color: $tags-focus-border-color;
box-shadow: 0 0 0 1px $tags-focus-border-color;
}

&:hover,
&.-hover {
border-color: $tags-hover-border-color;
}

li {
list-style-type: none;
height: fit-content;
}

.chi-tags__input {
border: 0;
outline: none;
width: 100%;
height: 100%;

&::placeholder {
color: $tags-input-placeholder-text-color;
}
}

.chi-tag {
margin-right: 0.5rem;
}
}
12 changes: 12 additions & 0 deletions src/chi/themes/brightspeed/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2068,3 +2068,15 @@ $tooltip-max-width: 20rem;
$transfer-list-title-color: $color-text-base;
$transfer-list-checkbox-icon-color: $color-icon-primary;
$transfer-list-reset-button-color: $color-blue-75;

// Tags
$tags-border-color: $color-border-base;
$tags-border-radius: $border-radius-base;
$tags-text-color: $color-text-base;
$tags-input-placeholder-text-color: $color-grey-50;
$tags-hover-border-color: $color-grey-40;
$tags-focus-border-color: $focus-color;
$tags-md-height: 2.5rem;
$tags-md-font-size: $font-size-md;
$tags-md-line-height: $line-height-md;
$tags-md-padding: 0.5625rem 0.75rem;
1 change: 1 addition & 0 deletions src/chi/themes/brightspeed/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ $theme: 'brightspeed';
@import '../../components/steps/steps';
@import '../../components/tables/tables';
@import '../../components/tabs/tabs';
@import '../../components/tags/tags';
@import '../../components/textarea/textarea';
@import '../../components/time-picker/time-picker';
@import '../../components/toggle-switch/toggle-switch';
Expand Down
12 changes: 12 additions & 0 deletions src/chi/themes/centurylink/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2080,3 +2080,15 @@ $tooltip-max-width: 20rem;
$transfer-list-title-color: $color-text-base;
$transfer-list-checkbox-icon-color: $color-icon-primary;
$transfer-list-reset-button-color: $color-blue-70;

// Tags
$tags-border-color: $color-border-base-dark;
$tags-border-radius: $border-radius-base;
$tags-text-color: $color-text-base;
$tags-input-placeholder-text-color: $color-grey-50;
$tags-hover-border-color: $color-grey-40;
$tags-focus-border-color: $focus-color;
$tags-md-height: 2.5rem;
$tags-md-font-size: $font-size-md;
$tags-md-line-height: $line-height-md;
$tags-md-padding: 0.5625rem 0.75rem;
1 change: 1 addition & 0 deletions src/chi/themes/centurylink/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ $theme: 'centurylink';
@import '../../components/steps/steps';
@import '../../components/tables/tables';
@import '../../components/tabs/tabs';
@import '../../components/tags/tags';
@import '../../components/textarea/textarea';
@import '../../components/time-picker/time-picker';
@import '../../components/toggle-switch/toggle-switch';
Expand Down
12 changes: 12 additions & 0 deletions src/chi/themes/colt/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2072,3 +2072,15 @@ $tooltip-max-width: 20rem;
$transfer-list-title-color: $color-text-base;
$transfer-list-checkbox-icon-color: $color-icon-primary;
$transfer-list-reset-button-color: $color-blue-75;

// Tags
$tags-border-color: $color-border-base;
$tags-border-radius: $border-radius-base;
$tags-text-color: $color-text-base;
$tags-input-placeholder-text-color: $color-grey-50;
$tags-hover-border-color: $color-grey-40;
$tags-focus-border-color: $focus-color;
$tags-md-height: 2.5rem;
$tags-md-font-size: $font-size-md;
$tags-md-line-height: $line-height-md;
$tags-md-padding: 0.5625rem 0.75rem;
1 change: 1 addition & 0 deletions src/chi/themes/colt/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ $theme: 'colt';
@import '../../components/steps/steps';
@import '../../components/tables/tables';
@import '../../components/tabs/tabs';
@import '../../components/tags/tags';
@import '../../components/textarea/textarea';
@import '../../components/time-picker/time-picker';
@import '../../components/toggle-switch/toggle-switch';
Expand Down
12 changes: 12 additions & 0 deletions src/chi/themes/lumen/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2076,3 +2076,15 @@ $tooltip-max-width: 20rem;
$transfer-list-title-color: $color-text-base;
$transfer-list-checkbox-icon-color: $color-icon-primary;
$transfer-list-reset-button-color: $color-blue-75;

// Tags
$tags-border-color: $color-border-base;
$tags-border-radius: $border-radius-base;
$tags-text-color: $color-text-base;
$tags-input-placeholder-text-color: $color-grey-60;
$tags-hover-border-color: $color-grey-40;
$tags-focus-border-color: $focus-color;
$tags-md-height: 2.5rem;
$tags-md-font-size: $font-size-md;
$tags-md-line-height: 1.25rem;
$tags-md-padding: 0.5625rem 0.75rem;
1 change: 1 addition & 0 deletions src/chi/themes/lumen/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ $theme: 'lumen';
@import '../../components/steps/steps';
@import '../../components/tables/tables';
@import '../../components/tabs/tabs';
@import '../../components/tags/tags';
@import '../../components/textarea/textarea';
@import '../../components/time-picker/time-picker';
@import '../../components/toggle-switch/toggle-switch';
Expand Down
12 changes: 12 additions & 0 deletions src/chi/themes/portal/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2074,3 +2074,15 @@ $tooltip-max-width: 20rem;
$transfer-list-title-color: $color-text-base;
$transfer-list-checkbox-icon-color: $color-icon-primary;
$transfer-list-reset-button-color: $color-text-primary;

// Tags
$tags-border-color: $color-border-base;
$tags-border-radius: $border-radius-base;
$tags-text-color: $color-text-base;
$tags-input-placeholder-text-color: $color-grey-60;
$tags-hover-border-color: $color-grey-40;
$tags-focus-border-color: $focus-color;
$tags-md-height: 2.5rem;
$tags-md-font-size: $font-size-md;
$tags-md-line-height: $line-height-md;
$tags-md-padding: 0.5625rem 0.75rem;
1 change: 1 addition & 0 deletions src/chi/themes/portal/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ $theme: 'portal';
@import '../../components/steps/steps';
@import '../../components/tables/tables';
@import '../../components/tabs/tabs';
@import '../../components/tags/tags';
@import '../../components/textarea/textarea';
@import '../../components/time-picker/time-picker';
@import '../../components/toggle-switch/toggle-switch';
Expand Down
60 changes: 60 additions & 0 deletions test/chi/components/tags.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: Tags
---

- var tags = ['Some tag', 'Another tag']

.test-base.-w--50.-mb--2.-pb--1
span.-text--h2 Base
ul.chi-tags
li.-flex--grow1
input.chi-tags__input(type="text" placeholder="Add tag")

.test-with-tags.-w--50.-mb--2.-pb--1
span.-text--h2 With tags
ul.chi-tags
each tag in tags
li
.chi-tag
.chi-badge
span=tag
button(class=`chi-button -icon -close -xs`, aria-label='Close')
.chi-button__content
.chi-icon
svg
use(xlink:href='#icon-x')
li.-flex--grow1
input.chi-tags__input(type="text" placeholder="Add tag")

.test-with-tags-focused.-w--50.-mb--2.-pb--1
span.-text--h2 With tags focused
ul.chi-tags.-focus
each tag in tags
li
.chi-tag
.chi-badge
span=tag
button(class=`chi-button -icon -close -xs`, aria-label='Close')
.chi-button__content
.chi-icon
svg
use(xlink:href='#icon-x')
li.-flex--grow1
input.chi-tags__input(type="text" placeholder="Add tag")

.test-with-tags-hover.-w--50.-mb--2.-pb--1
span.-text--h2 With tags hover
ul.chi-tags.-hover
each tag in tags
li
.chi-tag
.chi-badge
span=tag
button(class=`chi-button -icon -close -xs`, aria-label='Close')
.chi-button__content
.chi-icon
svg
use(xlink:href='#icon-x')
li.-flex--grow1
input.chi-tags__input(type="text" placeholder="Add tag")

37 changes: 37 additions & 0 deletions test/chi/custom-elements/tags.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: Tags
---
script(type='module' src='../../js/ce/ux-chi-ce/ux-chi-ce.esm.js')

.test-base.-w--50.-mb--2.-pb--1
span.-text--h2 Base
chi-tags(placeholder="Add tag")

.test-with-tags.-w--50.-mb--2.-pb--1
span.-text--h2 With tags
chi-tags#with-tags(placeholder="Add tag")

.test-with-tags-focused.-w--50.-mb--2.-pb--1
span.-text--h2 With tags focused
chi-tags#with-tags-focused(placeholder="Add tag" _status="focus")

.test-with-tags-hover.-w--50.-mb--2.-pb--1
span.-text--h2 With tags hover
chi-tags#with-tags-hover(placeholder="Add tag" _status="hover")

script.
document.addEventListener('DOMContentLoaded', () => {
[
'#with-tags',
'#with-tags-focused',
'#with-tags-hover',
].forEach(id => {

const element = document.querySelector(id);

element.tags = [
{ name: 'Some tag'},
{ name: 'Another tag'},
]
})
});

0 comments on commit c7098d4

Please sign in to comment.