-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mvp-2.1.0' into CRDCDH-860
- Loading branch information
Showing
17 changed files
with
303 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { | ||
Checkbox, | ||
CheckboxProps, | ||
FormControlLabelProps, | ||
styled, | ||
} from "@mui/material"; | ||
import { FC } from "react"; | ||
import { ReactComponent as CheckboxCheckedIcon } from "../../assets/icons/checkbox_checked.svg"; | ||
|
||
const StyledCheckboxCheckedIcon = styled(CheckboxCheckedIcon)<{ | ||
readOnly?: boolean; | ||
}>(({ readOnly }) => ({ | ||
width: "16px", | ||
height: "16px", | ||
color: "#1D91AB", | ||
backgroundColor: readOnly ? "#E5EEF4" : "initial", | ||
cursor: readOnly ? "not-allowed" : "pointer", | ||
})); | ||
|
||
const StyledCheckboxUncheckedIcon = styled("div")<{ readOnly?: boolean }>( | ||
({ readOnly }) => ({ | ||
width: "16px", | ||
height: "16px", | ||
color: "#083A50", | ||
outline: "2px solid #1D91AB", | ||
outlineOffset: -2, | ||
backgroundColor: readOnly ? "#E5EEF4" : "initial", | ||
cursor: readOnly ? "not-allowed" : "pointer", | ||
}) | ||
); | ||
|
||
const StyledCheckbox = styled(Checkbox)<{ readOnly?: boolean }>( | ||
({ readOnly }) => ({ | ||
padding: "2px 8px 2px 0", | ||
cursor: readOnly ? "not-allowed" : "pointer", | ||
}) | ||
); | ||
|
||
export const UncheckedIcon = styled("div")<{ readOnly?: boolean }>( | ||
({ readOnly }) => ({ | ||
outline: "2px solid #1D91AB", | ||
outlineOffset: -2, | ||
width: "16px", | ||
height: "16px", | ||
backgroundColor: readOnly ? "#E5EEF4" : "initial", | ||
color: "#083A50", | ||
cursor: readOnly ? "not-allowed" : "pointer", | ||
}) | ||
); | ||
|
||
type Props = { | ||
idPrefix?: string; | ||
formControlLabelProps?: FormControlLabelProps; | ||
} & CheckboxProps; | ||
|
||
const LabelCheckbox: FC<Props> = ({ | ||
idPrefix, | ||
formControlLabelProps, | ||
checked, | ||
name, | ||
value, | ||
onChange, | ||
readOnly, | ||
...rest | ||
}) => ( | ||
<> | ||
<StyledCheckbox | ||
id={idPrefix?.concat(`-label-checkbox`)} | ||
checked={checked} | ||
onChange={(e, checked) => !readOnly && onChange(e, checked)} | ||
readOnly={readOnly} | ||
icon={<StyledCheckboxUncheckedIcon readOnly={readOnly} />} | ||
checkedIcon={<StyledCheckboxCheckedIcon readOnly={readOnly} />} | ||
{...rest} | ||
/> | ||
{/* NOTE: This is a proxy element for form parsing purposes. */} | ||
<input | ||
name={name} | ||
type="checkbox" | ||
data-type="boolean" | ||
value={checked ? "true" : "false"} | ||
onChange={() => { }} | ||
aria-labelledby={`${idPrefix}-label`} | ||
checked | ||
hidden | ||
/> | ||
</> | ||
); | ||
|
||
export default LabelCheckbox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.