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

feat(autocomplete): on mobile for trip planner, use detached experience #2300

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 17 additions & 12 deletions assets/css/_autocomplete-theme.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@import '@algolia/autocomplete-theme-classic';

// styles that will be used for every instance
[phx-hook='AlgoliaAutocomplete'] {
[phx-hook='AlgoliaAutocomplete'], .aa-Detached {
.aa-Autocomplete {
--aa-icon-color-rgb: 22, 92, 150; // $brand-primary;
--aa-primary-color-rgb: 22, 92, 150; // $brand-primary;
--aa-input-border-color-rgb: 22, 92, 150;
--aa-overlay-color-rgb: 22, 92, 150; // $brand-primary;
}

.aa-Label {
Expand All @@ -24,7 +25,7 @@
order: 2;
}

.aa-Form {
.aa-Form, .aa-DetachedSearchButton {
border-color: rgb(var(--aa-input-border-color-rgb));
border-width: 3px;

Expand Down Expand Up @@ -205,13 +206,6 @@

#trip-planner-input-form--from,
#trip-planner-input-form--to {
--aa-search-input-height: 2rem;

.aa-Form {
border-radius: var(--border-radius-default);
padding: var(--spacing-xs);
}

.aa-InputWrapperPrefix {
display: grid;
grid-template-areas: "stack";
Expand All @@ -236,15 +230,26 @@
width: calc(var(--aa-spacing) + var(--aa-icon-size) - 1px);
}

.aa-SubmitButton {
// hide default search magnifying glass icon
.aa-SubmitIcon {
display: none;
}

.aa-DetachedSearchButtonIcon {
font-size: 1.25rem;
font-weight: bold;
width: calc(var(--aa-spacing) + (var(--aa-icon-size) * 0.5) - 1px);
}
}

#trip-planner-input-form--from .aa-Label::before {
#trip-planner-input-form--from .aa-DetachedSearchButtonIcon::before {
content: "A"
}

#trip-planner-input-form--to .aa-Label::before {
#trip-planner-input-form--to .aa-DetachedSearchButtonIcon::before {
content: "B"
}

.aa-DetachedOverlay .aa-InputWrapper {
padding-left: calc(var(--aa-spacing));
}
2 changes: 1 addition & 1 deletion assets/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = {
preflight: false
},
blocklist: ["container", "collapse"],
important: ".body-wrapper",
important: "body",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't we get rid of this field? Why do we need this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in the elaborated commit message hehe
image

content: [
...content,
"./js/**/*.js",
Expand Down
1 change: 1 addition & 0 deletions assets/ts/ui/autocomplete/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ const TRIP_PLANNER = ({

return {
...baseOptions,
detachedMediaQuery: "screen and (max-width: 544px)",
initialState: {
query: initialState()
},
Expand Down
2 changes: 1 addition & 1 deletion lib/dotcom_web/components/trip_planner/input_form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ defmodule DotcomWeb.Components.TripPlanner.InputForm do
<legend class="text-charcoal-40 m-0 py-sm">{Phoenix.Naming.humanize(field)}</legend>
<.algolia_autocomplete
config_type="trip-planner"
placeholder="Enter a location"
placeholder={"Enter #{if(field == :from, do: "an origin", else: "a destination")} location"}
id={"trip-planner-input-form--#{field}"}
>
<.inputs_for :let={location_f} field={f[field]} skip_hidden={true}>
Expand Down
Loading