Skip to content

Commit 15a6c6f

Browse files
committed
fix: Remove withPrefix function, that no longer seems necessary
1 parent 696e9a9 commit 15a6c6f

File tree

1 file changed

+12
-34
lines changed

1 file changed

+12
-34
lines changed

react/SelectBox/SelectBox.jsx

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,6 @@ const reactSelectControl = CustomControl => ({
122122
</div>
123123
)
124124

125-
export const withPrefix = (reactSelectCx, className) => {
126-
// react-select implement a classnames function https://git.io/fhT8S
127-
// it's not the same as classnames library (https://www.npmjs.com/package/classnames)
128-
// 1st parameter is bound by react-select with prefix https://git.io/fhkIj
129-
// 2nd parameter is cssKey. We don't need it so it's set to null
130-
// 3rd parameter is used to add prefix but we don't want to stick with
131-
// webpack className so we add space (' ') in front of it
132-
const classNameWithPrefix = reactSelectCx(null, { [` ${className}`]: true })
133-
134-
// When we don't use classNamePrefix cx return '' so we verify to send
135-
// className
136-
return classNameWithPrefix === '' ? className : classNameWithPrefix
137-
}
138-
139125
const Option = ({
140126
children,
141127
isSelected,
@@ -144,43 +130,35 @@ const Option = ({
144130
innerProps,
145131
innerRef,
146132
labelComponent,
147-
cx,
148133
withCheckbox
149134
}) => (
150135
<div
151136
{...innerProps}
152137
ref={innerRef}
153-
className={withPrefix(
154-
cx,
155-
classNames(styles['select-option'], {
156-
[styles['select-option--selected']]: isSelected && !withCheckbox,
157-
[styles['select-option--focused']]: isFocused,
158-
[styles['select-option--disabled']]: isDisabled
159-
})
160-
)}
138+
className={classNames(styles['select-option'], {
139+
[styles['select-option--selected']]: isSelected && !withCheckbox,
140+
[styles['select-option--focused']]: isFocused,
141+
[styles['select-option--disabled']]: isDisabled
142+
})}
161143
>
162144
{withCheckbox && (
163145
<input
164146
type="checkbox"
165147
readOnly
166148
checked={isSelected}
167-
className={withPrefix(cx, styles['select-option__checkbox'])}
149+
className={styles['select-option__checkbox']}
168150
/>
169151
)}
170-
<span className={withPrefix(cx, styles['select-option__label'])}>
171-
<span className={withPrefix(cx, 'u-ellipsis')}>
152+
<span className={styles['select-option__label']}>
153+
<span className="u-ellipsis">
172154
{labelComponent ? labelComponent : children}
173155
</span>
174156
{labelComponent ? children : false}
175157
</span>
176158
{!withCheckbox && (
177-
<span className={withPrefix(cx, styles['select-option__checkmark'])}>
159+
<span className={styles['select-option__checkmark']}>
178160
{isSelected && (
179-
<Icon
180-
icon={CheckIcon}
181-
color={dodgerBlue}
182-
className={withPrefix(cx, 'u-ph-half')}
183-
/>
161+
<Icon icon={CheckIcon} color={dodgerBlue} className="u-ph-half" />
184162
)}
185163
</span>
186164
)}
@@ -202,14 +180,14 @@ CheckboxOption.propTypes = {}
202180

203181
const ActionsOption = ({ actions, ...props }) => (
204182
<Option {...props} labelComponent={props.children}>
205-
<span className={withPrefix(props.cx, styles['select-option__actions'])}>
183+
<span className={styles['select-option__actions']}>
206184
{actions.map((action, index) => (
207185
<Icon
208186
{...action.iconProps}
209187
key={index}
210188
icon={action.icon}
211189
color={props.isFocused ? coolGrey : silver}
212-
className={withPrefix(props.cx, 'u-ph-half')}
190+
className="u-ph-half"
213191
onClick={e => {
214192
e.stopPropagation()
215193
action.onClick(props)

0 commit comments

Comments
 (0)