Skip to content

Commit

Permalink
Fix lint errors in client
Browse files Browse the repository at this point in the history
  • Loading branch information
julianguyen committed Feb 20, 2024
1 parent 98d8d92 commit 4c4cd7a
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 67 deletions.
22 changes: 0 additions & 22 deletions client/app/components/Input/Input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,6 @@
}
}

.select select {
@include setFontSize($size-18);
@include setPadding($size-24, $size-0, $size-24, $size-24);
@include paddingForSelectIcon($size-24);

color: $white;
font-weight: $font-weight-400;
width: 100%;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
box-sizing: border-box;
background-color: $white-10;
border-radius: $size-4;
box-shadow: $size-0 $size-2 $size-10 $black-10;
border: none;

&:focus {
background-color: $white-20;
}
}

.select {
position: relative;

Expand Down
33 changes: 11 additions & 22 deletions client/app/components/Input/InputMultiSelect.jsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
// @flow
import React, { useState, useEffect, useRef } from 'react';
import renderHTML from 'react-render-html';
import type { Node } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCaretUp, faCaretDown} from '@fortawesome/free-solid-svg-icons';
import { faCaretUp, faCaretDown } from '@fortawesome/free-solid-svg-icons';
import { InputCheckbox } from 'components/Input/InputCheckbox';
import css from './InputMultiSelect.scss';
import Input from 'components/Input';
import type { Option } from './utils';
import type { Checkbox } from './utils';
import { InputCheckbox } from 'components/Input/InputCheckbox';
import inputCss from './Input.scss';

export type Props = {
id: string,
ariaLabel?: string,
label?: string,
value?: any,
checkboxes: Checkbox[],
};

export function InputMultiSelect({
id,
checkboxes,
label
}: Props) {
export function InputMultiSelect({ id, checkboxes, label }: Props): Node {
const [opened, setOpened] = useState<boolean>(false);
const ref = useRef(null);

Expand All @@ -31,15 +22,15 @@ export function InputMultiSelect({
};

useEffect(() => {
const handleClickOutside = (event) => {
const handleClickOutside = (event: any) => {
if (ref.current && !ref.current.contains(event.target)) {
setOpened(false);
}
}
};

document.addEventListener("mousedown", handleClickOutside);
document.addEventListener('mousedown', handleClickOutside);
return () => {
document.removeEventListener("mousedown", handleClickOutside);
document.removeEventListener('mousedown', handleClickOutside);
};
}, [ref]);

Expand All @@ -51,19 +42,17 @@ export function InputMultiSelect({
onClick={handleOnClick}
id={id}
>
<div>{label}</div>
<div>
{label}
</div>
<div>
<FontAwesomeIcon icon={opened ? faCaretUp : faCaretDown }/>
<FontAwesomeIcon icon={opened ? faCaretUp : faCaretDown} />
</div>
</button>
<div
data-testid="multiSelectCheckboxes"
aria-labelledby={id}
className={css.multiSelectCheckboxesWrapper}
role="listbox"
style={{ display: opened ? 'block' : 'none '}}
style={{ display: opened ? 'block' : 'none ' }}
>
<div className={css.multiSelectCheckboxes}>
{checkboxes.map((checkbox) => (
Expand Down
5 changes: 3 additions & 2 deletions client/app/components/Input/InputMultiSelect.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
justify-content: space-between;
}

&Checkboxes{
&Checkboxes {
@include setPadding($size-6, $size-6, $size-6, $size-6);
@include fadeIn(0.8s);

width: 100%;
box-sizing: border-box;
position: absolute;
Expand All @@ -30,4 +31,4 @@
position: relative;
}
}
}
}
8 changes: 1 addition & 7 deletions client/app/components/Input/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,7 @@ export const Input = ({

const displayMultiSelect = () => {
if (type === 'multiSelect' && checkboxes) {
return (
<InputMultiSelect
id={id}
label={label}
checkboxes={checkboxes}
/>
);
return <InputMultiSelect id={id} label={label} checkboxes={checkboxes} />;
}
return null;
};
Expand Down
4 changes: 3 additions & 1 deletion client/app/components/Toast/__tests__/Toast.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ describe('Toast', () => {
});

it('closes correctly on button click', () => {
const { getByRole, container } = render(<Toast notice="Login successful." />);
const { getByRole, container } = render(
<Toast notice="Login successful." />,
);

const toastContent = getByRole('region');
const toastBtn = container.querySelector('#btn-close-toast-notice');
Expand Down
22 changes: 14 additions & 8 deletions client/app/components/Toast/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ export const Toast = ({ alert, notice, appendDashboardClass }: Props): Node => {
>
{showNotice && (
<>
<div>
{notice}
</div>
<button id="btn-close-toast-notice" type="button" onClick={hideNotice} aria-label={I18n.t('close')}>
<div>{notice}</div>
<button
id="btn-close-toast-notice"
type="button"
onClick={hideNotice}
aria-label={I18n.t('close')}
>
<span aria-hidden="true">
<FontAwesomeIcon icon={faTimes} />
</span>
Expand All @@ -79,10 +82,13 @@ export const Toast = ({ alert, notice, appendDashboardClass }: Props): Node => {
>
{showAlert && (
<>
<div>
{alert}
</div>
<button id="btn-close-toast-alert" type="button" onClick={hideAlert} aria-label={I18n.t('close')}>
<div>{alert}</div>
<button
id="btn-close-toast-alert"
type="button"
onClick={hideAlert}
aria-label={I18n.t('close')}
>
<span aria-hidden="true">
<FontAwesomeIcon icon={faTimes} />
</span>
Expand Down
4 changes: 1 addition & 3 deletions client/app/stories/Input.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,7 @@ const SelectTemplate = (args) => (
);

export const MultiSelect = () => (
<>
{InputMocks.createInput(InputMocks.inputMultiSelectProps)}
</>
<>{InputMocks.createInput(InputMocks.inputMultiSelectProps)}</>
);

MultiSelect.storyName = 'MultiSelect';
Expand Down
4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"glob": "^8.0.3",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.2.2",
"jest-canvas-mock": "^2.4.0",
"optimize-css-assets-webpack-plugin": "^6.0.1",
"prettier-eslint": "^11.0.0",
"react-test-renderer": "^17.0.2",
Expand All @@ -111,8 +112,7 @@
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-manifest-plugin": "^5.0.0",
"yml-loader": "^2.1.0",
"jest-canvas-mock": "^2.4.0"
"yml-loader": "^2.1.0"
},
"jest": {
"moduleNameMapper": {
Expand Down

0 comments on commit 4c4cd7a

Please sign in to comment.