Skip to content

Commit 041c71e

Browse files
musalegavinbarron
andauthored
feat: add new CSS properties for the people picker (#1926)
* feat: add new custom CSS properties for people picker dropdown * feat: set the dropdown text color to the new CSS properties * chore: add the new CSS properties to the picker story * fix: use the correct CSS property names * fix: accessibility contrast issues on the custom css props * feat: set the custom css properties on hover and focus Closes #1888 Co-authored-by: Gavin Barron <[email protected]>
1 parent 4e59158 commit 041c71e

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

packages/mgt-components/src/components/mgt-people-picker/mgt-people-picker.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,15 @@ mgt-people-picker .root {
126126
flex: 1 1 0;
127127
max-height: 40px;
128128
overflow: hidden;
129-
color: $color;
129+
color: $dropdown-item__text__color;
130+
131+
&:hover {
132+
color: $dropdown-item__text__color--hover;
133+
}
134+
135+
&.focused {
136+
color: $dropdown-item__text__color--hover;
137+
}
130138

131139
.people-person-text {
132140
font-size: 14px;

packages/mgt-components/src/components/mgt-people-picker/mgt-people-picker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ interface IFocusable {
7575
*
7676
* @cssprop --dropdown-background-color - {Color} Background color of dropdown area
7777
* @cssprop --dropdown-item-hover-background - {Color} Background color of person during hover
78+
* @cssprop --dropdown-item-text-color - {Color} Color of person text
79+
* @cssprop --dropdown-item-text-hover-color - {Color} Color of person text during hover
7880
*
7981
* @cssprop --placeholder-color--focus - {Color} Color of placeholder text during focus state
8082
* @cssprop --placeholder-color - {Color} Color of placeholder text

packages/mgt-components/src/styles/shared-sass-variables.scss

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ $link__color--disabled--light: $gray90;
172172
$depth-shadow--light: 0 3.2px 7.2px 0 rgba(0, 0, 0, 0.132);
173173
$depth-shadow--dark: 0 5px 14px 0 rgba(0, 0, 0, 0.8);
174174

175+
/* -----People picker dropdown text----- */
176+
$dropdown__item__text__color--light: $text__color__main--light;
177+
$dropdown__item__text__color--dark: $text__color__main--dark;
178+
$dropdown__item__text__hover__color--light: $text__color__main--light;
179+
$dropdown__item__text__hover__color--dark: $text__color__main--dark;
180+
175181
$font-family: var(--default-font-family);
176182
$font-size: var(--default-font-size);
177183

@@ -339,7 +345,17 @@ $common: (
339345
_var: --list-item-background-color--hover,
340346
dark: $list__item__background-color--hover--dark,
341347
light: $list__item__background-color--hover--light
342-
)
348+
),
349+
dropdown__item__text__color: (
350+
_var: --dropdown-item-text-color,
351+
dark: $dropdown__item__text__color--dark,
352+
light: $dropdown__item__text__color--light
353+
),
354+
dropdown__item__text__color--hover: (
355+
_var: --dropdown-item-text-hover-color,
356+
dark:$dropdown__item__text__hover__color--dark,
357+
light: $dropdown__item__text__hover__color--light
358+
),
343359
);
344360

345361
@function set-var($var, $theme, $component) {
@@ -374,6 +390,8 @@ $dropdown-item__background-color--hover: var(
374390
--dropdown-item-hover-background,
375391
set-var(input-outlined__background-color--hover, $theme-default, $common)
376392
);
393+
$dropdown-item__text__color: set-var(dropdown__item__text__color, $theme-default, $common);
394+
$dropdown-item__text__color--hover: set-var(dropdown__item__text__color--hover, $theme-default, $common);
377395

378396
@mixin input__border($theme) {
379397
border-top: $input__border-top;

stories/components/peoplePicker/peoplePicker.style.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ export const customCssProperties = () => html`
3333
--input-border-color--hover: #008394; /* input area border hover color */
3434
--input-border-color--focus: #0f78d4; /* input area border focus color */
3535
36-
--dropdown-background-color: #956970; /* selection area background color */
36+
--dropdown-background-color: #ca00ca; /* selection area background color */
3737
--dropdown-item-hover-background: purple; /* person background color on hover */
38+
--dropdown-item-text-color: white; /* person item text color */
39+
--dropdown-item-text-hover-color: gold; /* person item text color on hover */
3840
3941
--selected-person-background-color: black ; /* person item background color */
4042

0 commit comments

Comments
 (0)