Skip to content

Commit

Permalink
feat(forms): implement hover styles for fields
Browse files Browse the repository at this point in the history
Ref UXD-1651
  • Loading branch information
ajkl2533 committed Oct 11, 2024
1 parent acc953f commit 4f92c27
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 18 deletions.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const SingleDatePicker = ({
defaultIsYearPickerOpen,
startDate,
endDate,
isDisabled = false,
}: SingleDatePickerProps) => {
const [showYearPicker, setShowYearPicker] = useState(defaultIsYearPickerOpen);
const pickerRef = useRef({ calendar: { instanceRef: { changeYear: noop } } });
Expand All @@ -42,6 +43,7 @@ const SingleDatePicker = ({
calendarClassName="DateRangePicker-calendar"
className="DateRangePicker-input"
dateFormat="d MMM, yyyy"
disabled={isDisabled}
endDate={endDate}
maxDate={maxDate}
minDate={minDate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export interface SingleDatePickerProps {
defaultIsYearPickerOpen?: boolean;
startDate?: Date;
endDate?: Date;
isDisabled?: boolean;
}
8 changes: 8 additions & 0 deletions src/components/_internal/BaseSingleDatePicker/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ export const datePickerStyles = css`
line-height: var(--sscds-font-lineheight-body-md);
font-weight: var(--sscds-font-weight-body-default);
}
.DateRangePicker-input:disabled {
box-shadow: inset 0px 0px 0px 1px var(--sscds-color-border-input-disabled);
background: var(--sscds-color-background-input-disabled);
}
.DateRangePicker-input:hover:not(:disabled, :focus) {
box-shadow: inset 0px 0px 0px 1px var(--sscds-color-border-input-hover);
background: var(--sscds-color-background-input-hover);
}
.DateRangePicker-input:focus {
box-shadow: inset 0 0 0 2px ${getFormStyle('focusBorderColor')};
outline: none;
Expand Down
14 changes: 10 additions & 4 deletions src/components/forms/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const CheckboxInput = styled.input<TogglingInputProps>`
&:disabled + ${Box} {
border-color: ${getFormStyle('disabledBorderColor')};
background: ${getFormStyle('disabledBgColor')};
cursor: not-allowed;
}
&:disabled:checked + ${Box} {
Expand All @@ -69,15 +70,20 @@ const CheckboxInput = styled.input<TogglingInputProps>`
}
}
&:hover:not(:disabled, :checked) + ${Box} {
border-color: var(--sscds-color-border-input-hover);
background: var(--sscds-color-background-input-hover);
}
&:focus + ${Box} {
border: 2px solid ${getFormStyle('activeBorderColor')};
}
${({ isIndeterminate }) =>
isIndeterminate &&
css`
& + ${Box} {
background: ${getFormStyle('activeBorderColor')};
& + ${Box}, &:hover + ${Box} {
background: ${getFormStyle('activeBorderColor')} !important;
border-color: ${getFormStyle('activeBorderColor')};
${Mark} {
display: block;
Expand All @@ -93,8 +99,8 @@ const CheckboxInput = styled.input<TogglingInputProps>`
${({ isInvalid }) =>
isInvalid &&
css`
& + ${Box}, &:checked + ${Box} {
border: 2px solid ${getFormStyle('invalidBorderColor')};
& + ${Box}, &:checked + ${Box}, &:hover + ${Box} {
border: 2px solid ${getFormStyle('invalidBorderColor')} !important;
}
`}
`;
Expand Down
13 changes: 11 additions & 2 deletions src/components/forms/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,19 @@ const Input = styled.input.attrs<InputProps>(
line-height: ${getFormStyle('fieldLineHeight')};
outline: none;
&:hover:not(:disabled, :focus, .focus) {
box-shadow: inset 0px 0px 0px 1px var(--sscds-color-border-input-hover);
background: var(--sscds-color-background-input-hover);
}
${({ isInvalid }) =>
isInvalid &&
css`
box-shadow: inset 0px 0px 0px 2px ${getFormStyle('invalidBorderColor')};
`}
&,
&:hover {
box-shadow: inset 0px 0px 0px 2px ${getFormStyle('invalidBorderColor')} !important;
}
`};
&:focus,
&.focus {
Expand All @@ -47,6 +55,7 @@ const Input = styled.input.attrs<InputProps>(
&:disabled {
background: ${getFormStyle('disabledBgColor')};
border-color: ${getFormStyle('disabledBorderColor')};
cursor: not-allowed;
}
::placeholder,
Expand Down
18 changes: 13 additions & 5 deletions src/components/forms/InputGroup/InputGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { Icon } from '../../Icon';
import { Inline, Padbox } from '../../layout';
import { InputGroupProps } from './InputGroup.types';
import { InlineProps } from '../../layout/Inline/Inline';
import { Button } from '../../Button';
import { SearchBar } from '../SearchBar';
import { CLX_COMPONENT } from '../../../theme/constants';
import { useLogger } from '../../../hooks/useLogger';
Expand All @@ -23,6 +22,11 @@ const InputGroupContainer = styled(Inline)<InputGroupProps>`
box-shadow: inset 0 0 0 1px ${getFormStyle('borderColor')};
border-radius: var(--sscds-radii-input);
&:hover {
box-shadow: inset 0px 0px 0px 1px var(--sscds-color-border-input-hover);
background: var(--sscds-color-background-input-hover);
}
.ssc__control {
border: 0px;
box-shadow: none;
Expand All @@ -31,14 +35,19 @@ const InputGroupContainer = styled(Inline)<InputGroupProps>`
border: none;
border-radius: 0px;
}
& > *,
& > *:not(.sscds-buttonv2),
input:not([id^='react-select']) {
border: none;
box-shadow: none;
border-radius: 0px;
background-color: transparent;
&:hover {
box-shadow: none;
background: transparent;
}
}
& > * {
& > *:not(.sscds-buttonv2) {
${(props) =>
props.hasDivider &&
`border-right: 1px solid ${getFormStyle('borderColor')(props)};`}
Expand Down Expand Up @@ -70,7 +79,6 @@ const InputGroup = ({
Select,
Input,
Icon,
Button,
ButtonV2,
IconButton,
Password,
Expand All @@ -80,7 +88,7 @@ const InputGroup = ({
Children.forEach(children, (child) => {
if (!ALLOWED_CHILDREN.includes(prop('type', child))) {
error(
'Only Select, Input, InputGroup, Icon, Button, ButtonV2, IconButton, SearchBar and Password are valid childs of InputGroup',
'Only Select, Input, InputGroup, Icon, ButtonV2, IconButton, SearchBar and Password are valid childs of InputGroup',
);
}
});
Expand Down
14 changes: 12 additions & 2 deletions src/components/forms/MultiValueInput/MultiValueInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ const Control = styled.div<ValueContainerProps>`
background: ${getFormStyle('bgColor')};
border-radius: var(--sscds-radii-input);
box-shadow: inset 0 0 0 1px ${getFormStyle('borderColor')};
cursor: text;
&:hover {
box-shadow: inset 0px 0px 0px 1px var(--sscds-color-border-input-hover);
background: var(--sscds-color-background-input-hover);
}
&:focus-within,
&.focus-within {
Expand All @@ -60,8 +66,12 @@ const Control = styled.div<ValueContainerProps>`
${({ $isDisabled }) =>
$isDisabled &&
css`
background: ${getFormStyle('disabledBgColor')};
box-shadow: inset 0 0 0 1px ${getFormStyle('disabledBorderColor')};
&,
&:hover {
background: ${getFormStyle('disabledBgColor')};
box-shadow: inset 0 0 0 1px ${getFormStyle('disabledBorderColor')};
cursor: not-allowed;
}
`};
${({ $isInvalid }) =>
Expand Down
5 changes: 5 additions & 0 deletions src/components/forms/Radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ const RadioLabel = styled(Label)<
border: 1px solid ${getFormStyle('borderColor')};
background-color: ${getFormStyle('bgColor')};
}
&:hover::before {
border-color: var(--sscds-color-border-input-hover);
background: var(--sscds-color-background-input-hover);
}
`;

const RadioInput = styled.input<TogglingInputProps>`
Expand Down
8 changes: 6 additions & 2 deletions src/components/forms/Select/Select.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const stateStyles = (
color: `var(--sscds-${string})`,
width: `${string}px`,
) => ({
boxShadow: `inset 0 0 0 ${width} ${color}`,
boxShadow: `inset 0 0 0 ${width} ${color} !important`,
});

const invalidStyles = {
Expand Down Expand Up @@ -123,7 +123,11 @@ export const selectStyles: (
fontSize: 'var(--sscds-font-size-body-md)',
lineHeight: 'var(--sscds-font-lineheight-body-md)',
outline: 'none',

':hover': {
boxShadow:
'inset 0px 0px 0px 1px var(--sscds-color-border-input-hover)',
background: 'var(--sscds-color-background-input-hover)',
},
...(isInvalid && invalidStyles),
...((isFocused || includes('focus', className)) && focusStyles),
...(isDisabled && disabledStyles),
Expand Down
15 changes: 12 additions & 3 deletions src/components/forms/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ const TextareaStyled = styled.textarea<TextareaStyledProps>`
:-ms-input-placeholder {
color: ${getFormStyle('placeholderColor')};
}
:disabled {
cursor: not-allowed;
}
`;

const TextareaRoot = styled(Padbox)<TextareaRootProps>`
Expand All @@ -79,15 +82,21 @@ const TextareaRoot = styled(Padbox)<TextareaRootProps>`
${({ $isDisabled }) =>
$isDisabled &&
css`
background: ${getFormStyle('disabledBgColor')};
box-shadow: inset 0px 0px 0px 1px ${getFormStyle('disabledBorderColor')};
background: ${getFormStyle('disabledBgColor')} !important;
box-shadow: inset 0px 0px 0px 1px ${getFormStyle('disabledBorderColor')} !important;
cursor: not-allowed;
`};
${({ $isInvalid }) =>
$isInvalid &&
css`
box-shadow: inset 0px 0px 0px 2px ${getFormStyle('invalidBorderColor')};
box-shadow: inset 0px 0px 0px 2px ${getFormStyle('invalidBorderColor')} !important;
`};
&:hover:not(:focus-within) {
box-shadow: inset 0px 0px 0px 1px var(--sscds-color-border-input-hover);
background: var(--sscds-color-background-input-hover);
}
&:focus-within {
outline: none;
box-shadow: inset 0px 0px 0px 2px ${getFormStyle('focusBorderColor')};
Expand Down

0 comments on commit 4f92c27

Please sign in to comment.