Skip to content

Commit

Permalink
feat: Match Ian's styles
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Nov 14, 2024
1 parent d17220b commit c6189aa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const FlagsSelect: React.FC<Props> = (props) => {
<SelectMultiple
id="select-multiple-flags"
key="select-multiple-flags"
label="Flags (up to one per category)"
placeholder="Flags (up to one per category)"
options={flatFlags}
getOptionLabel={(flag) => flag.text}
groupBy={(flag) => flag.category}
Expand Down
2 changes: 1 addition & 1 deletion editor.planx.uk/src/ui/editor/ListManager/ListManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface Props<T, EditorExtraProps = {}> {

const Item = styled(Box)(({ theme }) => ({
display: "flex",
marginBottom: theme.spacing(1),
marginBottom: theme.spacing(2),
}));

export default function ListManager<T, EditorExtraProps>(
Expand Down
8 changes: 6 additions & 2 deletions editor.planx.uk/src/ui/shared/SelectMultiple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ type WithPlaceholder<T> = {
type Props<T> = WithLabel<T> | WithPlaceholder<T>;

const StyledAutocomplete = styled(Autocomplete)(({ theme }) => ({
marginTop: theme.spacing(2),
"& > div > label": {
paddingRight: theme.spacing(3),
},
Expand Down Expand Up @@ -113,9 +112,14 @@ export const CustomCheckbox = styled("span")(({ theme }) => ({
}));

export function SelectMultiple<T>(props: Props<T>) {
// MUI doesn't pass the Autocomplete value along to the TextField automatically
const isSelectEmpty = !props.value?.length;
const placeholder = isSelectEmpty ? props.placeholder : undefined

return (
<FormControl sx={{ display: "flex", flexDirection: "column" }}>
<StyledAutocomplete<T, true, true, false, "div">
sx={{ mt: props.label ? 2 : 0 }}
role="status"
aria-atomic={true}
aria-live="polite"
Expand All @@ -129,9 +133,9 @@ export function SelectMultiple<T>(props: Props<T>) {
InputProps={{
...params.InputProps,
notched: false,
placeholder: props?.placeholder
}}
label={props.label}
placeholder={placeholder}
/>
)}
ChipProps={{
Expand Down

0 comments on commit c6189aa

Please sign in to comment.