diff --git a/.stylelintrc b/.stylelintrc index 3f7dd4312..e325a63af 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -9,6 +9,8 @@ "declaration-property-value-blacklist": null, "max-nesting-depth": null, "order/properties-alphabetical-order": null, - "selector-max-compound-selectors": 4 + "selector-max-compound-selectors": 4, + "at-rule-no-unknown": null, + "scss/at-rule-no-unknown": true } } diff --git a/src/components/SelectInput/SelectInput.module.scss b/src/components/SelectInput/SelectInput.module.scss index 966d20ae9..8d8674749 100644 --- a/src/components/SelectInput/SelectInput.module.scss +++ b/src/components/SelectInput/SelectInput.module.scss @@ -31,24 +31,26 @@ react-select elements for which we do not own the markup */ .react-select-icon { padding: 0; padding-right: 2px; - color: var(--form-control-select-icon-color); + color: var(--form-control-icon-color); &:hover { - color: var(--form-control-select-icon-hover-color) - } - - svg { - width: var(--form-control-select-icon-size); - height: var(--form-control-select-icon-size); + color: var(--form-control-icon-hover-color) } } :global(.react-select__dropdown-indicator) { @extend .react-select-icon; + + svg { + width: var(--form-control-select-icon-size); + height: var(--form-control-select-icon-size); + } } :global(.react-select__clear-indicator) { @extend .react-select-icon; + + margin-right: var(--form-control-select-clear-icon-margin); } &:global(.react-select__control--is-focused) { diff --git a/src/components/SelectInput/SelectInput.tsx b/src/components/SelectInput/SelectInput.tsx index 985bdabcc..2e5643d3a 100644 --- a/src/components/SelectInput/SelectInput.tsx +++ b/src/components/SelectInput/SelectInput.tsx @@ -1,6 +1,14 @@ import React, { FC, FocusEvent, ReactNode } from 'react'; import classNames from 'classnames'; -import Select, { ValueType, OptionTypeBase, FocusEventHandler } from 'react-select'; +import Select, { + components, + ValueType, + OptionTypeBase, + FocusEventHandler, + IndicatorProps, +} from 'react-select'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faTimes } from '@fortawesome/free-solid-svg-icons'; import FormLabel from '../FormLabel/FormLabel'; import InputValidationMessage from '../InputValidationMessage/InputValidationMessage'; import styles from './SelectInput.module.scss'; @@ -144,12 +152,19 @@ const SelectInput: FC = ({ isDisabled, }; + const ClearIndicator = (props: IndicatorProps) => ( + + + + ); + return (
{label && !hideLabel && {label}} - ) : ( - - )} +
+ {!inputMask ? ( + + ) : ( + + )} + {!!onClear && !!value && renderClearIcon()} +
{error && error !== true && {error}}
); diff --git a/src/styles/variables/forms.scss b/src/styles/variables/forms.scss index 5e67e8619..a95ece556 100644 --- a/src/styles/variables/forms.scss +++ b/src/styles/variables/forms.scss @@ -34,6 +34,8 @@ --form-control-description-color: var(--color-font-grey-dark); --form-control-disabled-font-color: var(--color-font-grey-light); --form-control-placeholder-color: var(--color-font-grey-light); + --form-control-icon-color: var(--form-control-placeholder-color); + --form-control-icon-hover-color: var(--color-brand-grey); /* ----RADIO GROUP---- */ --form-control-radio-group-description-spacing: var(--size-spacing-xs); @@ -41,8 +43,11 @@ --form-control-radio-group-options-spacing: var(--size-spacing-md); /* ----SELECT INPUT---- */ - --form-control-select-icon-color: var(--color-brand-grey-light); - --form-control-select-icon-hover-color: var(--color-brand-grey); --form-control-select-icon-size: 34px; --form-control-select-padding: var(--size-spacing-2xs); + --form-control-select-clear-icon-margin: var(--size-spacing-xs); + + /* ----TEXT INPUT---- */ + --form-control-text-clear-icon-margin: var(--size-spacing-xs); + --form-control-text-clear-icon-font-size: var(--size-font-lg); } diff --git a/tsconfig.json b/tsconfig.json index bf6d51769..7d22c3193 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,10 @@ "esModuleInterop": true, "isolatedModules": true, "resolveJsonModule": true, + "lib": [ + "ES6", + "DOM" + ] }, "include": [ "./src",