Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small mode selector enhancements #609

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,12 @@ const defaultModeButtonDefinitions = [

const modeSettingDefinitionsWithDropdown = [
...modeSettingDefinitions,
{
applicableMode: "TRANSIT",
default: "blue",
key: "busColor",
label: "Bus Color",
options: [{ value: "blue", text: "Blue" }],
type: "DROPDOWN"
},
daniel-heppner-ibigroup marked this conversation as resolved.
Show resolved Hide resolved
{
applicableMode: "TRANSIT",
default: true,
key: "tram",
label: "Tram",
iconName: "tram",
label: "Tram but long",
addTransportMode: {
mode: "TRAM"
},
Expand All @@ -91,7 +84,7 @@ const modeSettingDefinitionsWithDropdown = [
applicableMode: "TRANSIT",
default: true,
key: "bus",
label: "Bus",
label: "MARTA Rail",
iconName: "bus",
addTransportMode: {
mode: "BUS"
Expand Down
12 changes: 10 additions & 2 deletions packages/trip-form/src/MetroModeSelector/SubSettingsPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,20 @@ const SettingsPanel = styled.fieldset`
}
`;

export const SubSettingsCheckbox = styled(CheckboxSelector)`
export const SubSettingsCheckbox = styled(CheckboxSelector)<{
flexbox: boolean;
}>`
display: ${props => (props.flexbox ? "flex" : "box")};
daniel-heppner-ibigroup marked this conversation as resolved.
Show resolved Hide resolved
margin-left: 4px;
input {
vertical-align: middle;
}
`;

const FormLabelIconWrapper = styled.span`
align-items: center;
daniel-heppner-ibigroup marked this conversation as resolved.
Show resolved Hide resolved
display: flex;
gap: 4px;
svg {
width: 16px;
height: 16px;
Expand All @@ -81,7 +87,8 @@ const ModeSettingRenderer = ({
const labelWithIcon =
"icon" in setting ? (
<FormLabelIconWrapper>
<span role="none">{setting.icon}</span> {label}
<div role="none">{setting.icon}</div>
<div> {label}</div>
daniel-heppner-ibigroup marked this conversation as resolved.
Show resolved Hide resolved
</FormLabelIconWrapper>
) : (
label
Expand All @@ -92,6 +99,7 @@ const ModeSettingRenderer = ({
case "SUBMODE":
return (
<SubSettingsCheckbox
flexbox={setting.type === "SUBMODE"}
label={labelWithIcon}
name={setting.key}
onChange={onChange}
Expand Down
3 changes: 2 additions & 1 deletion packages/trip-form/src/MetroModeSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ function ModeButton({
useDismiss(context)
]);

const renderDropdown = open && modeButton.enabled;
const renderDropdown =
open && modeButton.enabled && modeButton.modeSettings?.length > 0;
const interactionProps = getReferenceProps();

// ARIA roles are added by the `useRole` hook.
Expand Down