Skip to content

Commit 0f6a955

Browse files
authored
remove non-synth colors, add borderedMultiValue styles SingleSelect (#1196)
1 parent 2a8f839 commit 0f6a955

File tree

5 files changed

+68
-96
lines changed

5 files changed

+68
-96
lines changed

src/Select/SingleSelect.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import Select from 'react-select';
44
import propTypes from 'prop-types';
55

66
import zStack from 'src/Styles/zStack';
7-
import './select.scss';
87

9-
import { defaultTheme, defaultStyles, SELECT_SIZES } from './styles';
8+
import {
9+
borderedMultiValueStyles, defaultTheme, defaultStyles, SELECT_SIZES,
10+
} from './styles';
1011

1112
const SingleSelect = ({
1213
'aria-label': ariaLabel,
1314
'aria-labelledby': ariaLabelledBy,
15+
borderedMultiValue,
1416
className,
1517
closeMenuOnSelect,
1618
components,
@@ -57,6 +59,7 @@ const SingleSelect = ({
5759
placeholder={placeholder}
5860
styles={{
5961
...defaultStyles({ menuWidth, size }),
62+
...borderedMultiValueStyles(borderedMultiValue),
6063
menuPortal: (base) => (
6164
modal ?
6265
{ ...base, zIndex: zStack.zIndexModalBackdrop + 1 } :
@@ -72,6 +75,7 @@ const SingleSelect = ({
7275
SingleSelect.propTypes = {
7376
'aria-label': propTypes.string,
7477
'aria-labelledby': propTypes.string,
78+
borderedMultiValue: propTypes.bool,
7579
className: propTypes.string,
7680
closeMenuOnSelect: propTypes.bool,
7781
components: propTypes.any,
@@ -103,6 +107,7 @@ SingleSelect.propTypes = {
103107
SingleSelect.defaultProps = {
104108
'aria-label': undefined,
105109
'aria-labelledby': undefined,
110+
borderedMultiValue: undefined,
106111
className: undefined,
107112
closeMenuOnSelect: true,
108113
components: undefined,

src/Select/SingleSelect.mdx

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/Select/SingleSelect.stories.jsx

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,11 @@ import Option from './Option';
1212
import OptionWithDescription from './OptionWithDescription';
1313
import ValueContainer from './ValueContainer';
1414

15-
import mdx from './SingleSelect.mdx';
16-
1715
const onChange = () => action('Change');
1816

1917
export default {
2018
title: 'Components/Selects/Single',
2119
component: SingleSelect,
22-
parameters: {
23-
docs: {
24-
page: mdx,
25-
},
26-
},
2720
};
2821

2922
const options = [
@@ -33,6 +26,13 @@ const options = [
3326
{ label: 'Unmoderated task', value: 4 },
3427
];
3528

29+
const peopleOptions = [
30+
{ label: 'Riley Researcher', value: 5 },
31+
{ label: 'Mickey Moderator', value: 6 },
32+
{ label: 'Connie Collaborator', value: 7 },
33+
{ label: 'Ozzy Observer', value: 8 },
34+
];
35+
3636
export const Default = () => (
3737
<FormGroup
3838
label="Default select"
@@ -74,6 +74,21 @@ export const MultipleSelect = () => (
7474
</FormGroup>
7575
);
7676

77+
export const MultipleSelectBorderedPill = () => (
78+
<FormGroup
79+
label="Multiple select bordered pill"
80+
labelHtmlFor="multi-select-bordered-pill"
81+
>
82+
<SingleSelect
83+
borderedMultiValue
84+
inputId="multi-select-bordered-pill"
85+
isMulti
86+
options={peopleOptions}
87+
onChange={onChange}
88+
/>
89+
</FormGroup>
90+
);
91+
7792
export const InModal = () => {
7893
const [isOpen, setIsOpen] = useState(false);
7994

src/Select/select.scss

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/Select/styles.js

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ const defaultStyles = ({ menuWidth, size }) => ({
5151
indicatorSeparator: (styles) => ({ ...styles, display: 'none' }),
5252
multiValue: (styles) => ({
5353
...styles,
54-
backgroundColor: systemColors.UX_BLUE_100,
55-
color: systemColors.UX_BLUE_700,
54+
backgroundColor: systemColors.SYNTH_HOVER_STATE,
55+
color: systemColors.SYNTH_SUCCESS_GREEN_DARK,
5656
borderRadius: '4px',
5757
}),
5858
menu: (styles) => ({
@@ -61,20 +61,20 @@ const defaultStyles = ({ menuWidth, size }) => ({
6161
}),
6262
multiValueLabel: (styles) => ({
6363
...styles,
64-
color: systemColors.UX_BLUE_700,
64+
color: systemColors.SYNTH_SUCCESS_GREEN_DARK,
6565
fontSize: '0.875rem',
6666
fontWeight: 400,
6767
lineHeight: '1.25rem',
6868
paddingLeft: '8px',
6969
}),
7070
multiValueRemove: (styles) => ({
7171
...styles,
72-
color: systemColors.UX_BLUE,
72+
color: systemColors.SYNTH_SUCCESS_GREEN_DARK,
7373
cursor: 'pointer',
7474
':hover': {
7575
...styles[':hover'],
76-
backgroundColor: systemColors.selectOptionFocusedBg,
77-
color: systemColors.UX_BLUE_700,
76+
backgroundColor: systemColors.SYNTH_SELECTED_STATE_GREEN,
77+
color: systemColors.SYNTH_SUCCESS_GREEN_DARK,
7878
},
7979
}),
8080
placeholder: (styles) => ({
@@ -91,10 +91,12 @@ const defaultStyles = ({ menuWidth, size }) => ({
9191
}),
9292
option: (styles, {
9393
isDisabled,
94+
isFocused,
9495
isSelected,
9596
}) => ({
9697
...styles,
97-
backgroundColor: isSelected ? systemColors.UX_BLUE_200 : styles.backgroundColor,
98+
backgroundColor: isSelected || isFocused ?
99+
systemColors.SYNTH_HOVER_STATE : styles.backgroundColor,
98100
color: systemColors.UX_GRAY_900,
99101
fontWeight: fontWeights.light,
100102
fontSize: '0.875rem',
@@ -108,11 +110,39 @@ const defaultStyles = ({ menuWidth, size }) => ({
108110

109111
':hover': {
110112
...styles[':hover'],
111-
backgroundColor: isSelected ? systemColors.UX_BLUE_200 : systemColors.UX_BLUE_100,
113+
backgroundColor: isSelected ?
114+
systemColors.SYNTH_SELECTED_STATE_GREEN : systemColors.SYNTH_HOVER_STATE,
112115
},
113116
}),
114117
});
115118

119+
const borderedMultiValueStyles = (borderedMultiValue) => borderedMultiValue ? {
120+
multiValue: (styles) => (
121+
{
122+
...styles,
123+
border: `1px solid ${systemColors.SYNTH_DARK_BACKGROUND_SELECTED_BLUE}`,
124+
borderRadius: '4px',
125+
backgroundColor: systemColors.UX_WHITE,
126+
}
127+
),
128+
multiValueLabel: (styles) => (
129+
{
130+
...styles,
131+
color: systemColors.SYNTH_DARK_BACKGROUND_SELECTED_BLUE,
132+
}
133+
),
134+
multiValueRemove: (styles) => (
135+
{
136+
...styles,
137+
color: systemColors.SYNTH_DARK_BACKGROUND_SELECTED_BLUE,
138+
':hover': {
139+
backgroundColor: systemColors.UX_NAVY_500,
140+
color: systemColors.UX_WHITE,
141+
},
142+
}
143+
),
144+
} : {};
145+
116146
const defaultTheme = (theme) => ({
117147
...theme,
118148
colors: {
@@ -122,6 +152,7 @@ const defaultTheme = (theme) => ({
122152
});
123153

124154
export {
155+
borderedMultiValueStyles,
125156
defaultStyles,
126157
defaultTheme,
127158
};

0 commit comments

Comments
 (0)