diff --git a/src/components/ExampleCheckbox.module.css b/src/components/ExampleCheckbox.module.css new file mode 100644 index 0000000000..01ae2c8372 --- /dev/null +++ b/src/components/ExampleCheckbox.module.css @@ -0,0 +1,34 @@ +.container { + position: relative; + margin: var(--spacing-1) var(--spacing-1-point-5) var(--spacing-1) var(--spacing-point-5); +} + +/* The panel mimics the institution's site, so the checkbox follows the text color + instead of the widget's primary color. Removing the padding makes the element box + match the icon so the overlays below can center on it. */ +.checkbox:global(.MuiCheckbox-root), +.checkbox:global(.MuiCheckbox-root.Mui-checked) { + color: var(--mui-palette-text-primary); + padding: 0; +} + +/* Center the touch indicator over the checkbox */ +.touchIndicator { + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +} + +.pseudoFocus { + /* border-box so host page box-sizing resets can't change the outline size */ + box-sizing: border-box; + /* the small checkbox SVG is 20px but its drawn box is only ~15px; 19px leaves a ~1px gap */ + width: 19px; + height: 19px; + border: 1px solid; + border-radius: 3px; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +} diff --git a/src/components/ExampleCheckbox.tsx b/src/components/ExampleCheckbox.tsx index 8bf287841f..ffd94e9f67 100644 --- a/src/components/ExampleCheckbox.tsx +++ b/src/components/ExampleCheckbox.tsx @@ -1,7 +1,8 @@ import React from 'react' import PropTypes from 'prop-types' -import { useTheme } from '@mui/material' +import { Checkbox } from '@mui/material' import { TouchIndicator } from 'src/components/TouchIndicator' +import styles from 'src/components/ExampleCheckbox.module.css' export const ExampleCheckbox: React.FC< React.HTMLAttributes & { @@ -9,45 +10,24 @@ export const ExampleCheckbox: React.FC< showTouchIndicator?: boolean } > = ({ id, showTouchIndicator, pseudoFocusColor }) => { - const theme = useTheme() - const checkboxSize = '15px' - return ( -