-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(autocomplete): fix width in the header desktop + component impro…
…vements (#1804) * feat(autocomplete): make placeholder configurable * fix(autocomplete): allow for nil data-algolia this will remove the attribute on the rendered element * feat(autocomplete): allow event handler by name * refactor(autocomplete): configurable onStateChange * refactor(autocomplete): extract shared CSS * fix(autocomplete): maintain largest width in header navbar * fixup: update tests * move notranslate to stop name instead of entire search result
- Loading branch information
1 parent
643b467
commit e689718
Showing
11 changed files
with
185 additions
and
132 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,137 +1,139 @@ | ||
@import '@algolia/autocomplete-theme-classic'; | ||
|
||
.aa-Autocomplete { | ||
--aa-icon-color-rgb: 22, 92, 150; // $brand-primary; | ||
--aa-primary-color-rgb: 22, 92, 150; // $brand-primary; | ||
--aa-search-input-height: 2.25rem; | ||
} | ||
// WIP as we upgrade all of the search bars | ||
%shared-autocomplete { | ||
.aa-Autocomplete { | ||
--aa-icon-color-rgb: 22, 92, 150; // $brand-primary; | ||
--aa-primary-color-rgb: 22, 92, 150; // $brand-primary; | ||
} | ||
|
||
// right now #header-desktop is the only search using the new library, so it's | ||
// the only one styled here. the #header-desktop can be removed once we migrate | ||
// the rest over | ||
#header-desktop { | ||
.c-search-bar__autocomplete { | ||
.aa-Label { | ||
margin-bottom: unset; | ||
} | ||
.aa-Label { | ||
margin-bottom: unset; | ||
} | ||
|
||
.aa-Input { | ||
// stylelint-disable-next-line declaration-no-important | ||
height: var(--aa-search-input-height) !important; | ||
} | ||
.aa-InputWrapperPrefix { | ||
order: 3; // move search icon to end. | ||
} | ||
|
||
.aa-InputWrapperPrefix { | ||
order: 3; // move search icon to end. | ||
} | ||
.aa-InputWrapper { | ||
order: 1; | ||
} | ||
|
||
.aa-InputWrapper { | ||
order: 1; | ||
padding-left: 1rem; | ||
} | ||
.aa-InputWrapperSuffix { | ||
order: 2; | ||
} | ||
|
||
.aa-Form { | ||
border: 3px solid $brand-primary; | ||
|
||
.aa-InputWrapperSuffix { | ||
order: 2; | ||
&:focus-within { | ||
border-color: $brand-primary-light; | ||
box-shadow: unset; | ||
} | ||
} | ||
|
||
.aa-Form { | ||
border: 3px solid $brand-primary; | ||
border-radius: .5rem; | ||
.aa-LoadingIndicator, | ||
.aa-SubmitButton { | ||
padding-left: var(--aa-spacing-half); | ||
width: calc(var(--aa-spacing) * 1.25 + var(--aa-icon-size) - 1px); | ||
} | ||
|
||
&:focus-within { | ||
border-color: $brand-primary-lightest; | ||
box-shadow: unset; | ||
} | ||
} | ||
.aa-ClearButton { | ||
@include fa-icon-solid($fa-var-times-circle); | ||
color: rgba(var(--aa-icon-color-rgb), var(--aa-icon-color-alpha)); | ||
// hide default icon | ||
.aa-ClearIcon { display: none; } | ||
} | ||
|
||
.aa-LoadingIndicator, | ||
.aa-SubmitButton { | ||
padding-left: var(--aa-spacing-half); | ||
width: calc(var(--aa-spacing) * 1.25 + var(--aa-icon-size) - 1px); | ||
} | ||
.aa-SubmitButton { | ||
@include fa-icon-solid($fa-var-search); | ||
color: rgba(var(--aa-icon-color-rgb), var(--aa-icon-color-alpha)); | ||
// hide default icon | ||
.aa-SubmitIcon { display: none; } | ||
} | ||
|
||
.aa-ClearButton { | ||
@include fa-icon-solid($fa-var-times-circle); | ||
color: rgba(var(--aa-icon-color-rgb), var(--aa-icon-color-alpha)); | ||
padding-right: var(--aa-spacing-half); | ||
// hide default icon | ||
.aa-ClearIcon { display: none; } | ||
} | ||
.aa-GradientBottom, | ||
.aa-GradientTop { all: unset; } | ||
|
||
.aa-SubmitButton { | ||
@include fa-icon-solid($fa-var-search); | ||
color: rgba(var(--aa-icon-color-rgb), var(--aa-icon-color-alpha)); | ||
// hide default icon | ||
.aa-SubmitIcon { display: none; } | ||
.aa-ItemContent { | ||
mark { | ||
padding: 0; | ||
} | ||
> * { | ||
margin-right: .25rem; | ||
} | ||
} | ||
|
||
.aa-GradientBottom, | ||
.aa-GradientTop { all: unset; } | ||
.aa-ItemContentTitle { | ||
display: unset; | ||
margin: unset; | ||
overflow: visible; | ||
text-overflow: unset; | ||
white-space: normal; | ||
} | ||
|
||
.c-search-bar__autocomplete-results { | ||
.aa-ItemContent { | ||
mark { | ||
padding: 0; | ||
} | ||
> * { | ||
margin-right: .25rem; | ||
} | ||
} | ||
.aa-PanelLayout { | ||
padding: unset; | ||
} | ||
|
||
.aa-Panel { | ||
margin-top: .25rem; | ||
z-index: var(--aa-base-z-index); | ||
} | ||
|
||
.aa-Item { | ||
border-bottom: $border; | ||
border-radius: 0; | ||
font-weight: normal; | ||
|
||
.aa-ItemContentTitle { | ||
display: unset; | ||
margin: unset; | ||
overflow: visible; | ||
text-overflow: unset; | ||
white-space: normal; | ||
&:hover { | ||
background-color: $brand-primary-lightest; | ||
} | ||
|
||
.aa-PanelLayout { | ||
padding: unset; | ||
em { | ||
font-style: inherit; | ||
font-weight: bold; | ||
} | ||
|
||
.aa-Panel { | ||
// stylelint-disable-next-line declaration-no-important | ||
top: 3.25rem !important; | ||
z-index: var(--aa-base-z-index); | ||
> a, | ||
> button { | ||
color: currentColor; | ||
display: flex; | ||
font-weight: inherit; | ||
gap: .25rem; | ||
min-width: 0; | ||
padding: calc(#{$base-spacing} / 2) $base-spacing; | ||
} | ||
|
||
.aa-Item { | ||
border-bottom: $border; | ||
border-radius: 0; | ||
font-weight: normal; | ||
|
||
&:hover { | ||
background-color: $brand-primary-lightest; | ||
} | ||
|
||
em { | ||
font-style: inherit; | ||
font-weight: bold; | ||
} | ||
|
||
> a, | ||
> button { | ||
color: currentColor; | ||
display: flex; | ||
font-weight: inherit; | ||
gap: .25rem; | ||
min-width: 0; | ||
padding: calc(#{$base-spacing} / 2) $base-spacing; | ||
} | ||
|
||
a:hover { | ||
text-decoration: none; | ||
} | ||
|
||
[class*=c-svg__icon] { | ||
width: 1em; | ||
} | ||
a:hover { | ||
text-decoration: none; | ||
} | ||
|
||
.aa-ItemContent, | ||
.aa-ItemContentBody { | ||
display: unset; | ||
[class*=c-svg__icon] { | ||
width: 1em; | ||
} | ||
} | ||
|
||
.aa-ItemContent, | ||
.aa-ItemContentBody { | ||
display: unset; | ||
} | ||
} | ||
|
||
#header-desktop { | ||
--aa-search-input-height: 2.25rem; | ||
|
||
@extend %shared-autocomplete; | ||
|
||
.aa-Form { | ||
border-radius: .5rem; | ||
} | ||
|
||
.aa-InputWrapper { | ||
padding-left: 1rem; | ||
} | ||
|
||
.aa-ClearButton { | ||
padding-right: var(--aa-spacing-half); | ||
} | ||
} |
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.