-
Notifications
You must be signed in to change notification settings - Fork 0
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: Allow autocomplete to be styled from parent #124
Changes from all commits
0752b3e
a8861d1
6f73d2b
1beb70f
002185b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ export class AddressAutocomplete extends LitElement { | |
source: this._options, | ||
defaultValue: this.initialAddress, | ||
showAllValues: true, | ||
displayMenu: "overlay", | ||
tNoResults: () => "No addresses found", | ||
onConfirm: (option: string) => { | ||
this._selectedAddress = this._addressesInPostcode.filter( | ||
|
@@ -175,7 +176,12 @@ export class AddressAutocomplete extends LitElement { | |
href="https://cdn.jsdelivr.net/npm/accessible-autocomplete@2.0.4/dist/accessible-autocomplete.min.css" | ||
/> | ||
<label class="govuk-label" htmlFor=${this.id}>${this.label}</label> | ||
<div id="${this.id}-container" role="status" tabindex="0"></div>`; | ||
<div | ||
id="${this.id}-container" | ||
role="status" | ||
tabindex="0" | ||
spellcheck="false" | ||
></div>`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 thanks for catching these extra props! |
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,53 @@ | ||
@import "node_modules/govuk-frontend/govuk/all"; | ||
// @import "accessible-autocomplete"; | ||
|
||
// makes listbox items consistent with label font, etc | ||
ul, | ||
li { | ||
font-family: Inter, Helvetica, sans-serif; | ||
:host { | ||
$font-family: var( | ||
--autocomplete__font-family, | ||
"GDS Transport", | ||
arial, | ||
sans-serif | ||
); | ||
$font-size: var(--autocomplete__input__font-size, 19px); | ||
$input-height: var(--autocomplete__input__height, 35px); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe option to pass i have a weird little hack below for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! ⚾ |
||
|
||
.govuk-label { | ||
font-family: $font-family; | ||
} | ||
|
||
.autocomplete__input { | ||
font-family: $font-family; | ||
font-size: $font-size; | ||
height: $input-height; | ||
padding: var(--autocomplete__input__padding, 5px 34px 5px 5px); | ||
} | ||
|
||
.autocomplete__dropdown-arrow-down { | ||
z-index: var(--autocomplete__dropdown-arrow-down__z-index, -1); | ||
// Ensure the down arrow is vertically centred | ||
$arrow-down-height: 17px; | ||
top: calc(($input-height - $arrow-down-height) / 2); | ||
} | ||
|
||
.autocomplete__option { | ||
font-family: $font-family; | ||
font-size: $font-size; | ||
padding: var(--autocomplete__option__padding, 5px); | ||
border-bottom: var( | ||
--autocomplete__option__border-bottom, | ||
solid 1px #b1b4b6 | ||
); | ||
&:hover, | ||
&:focus { | ||
border-color: var(--autocomplete__option__hover-border-color, #1d70b8); | ||
background-color: var( | ||
--autocomplete__option__hover-background-color, | ||
#1d70b8 | ||
); | ||
} | ||
} | ||
|
||
.autocomplete__menu { | ||
max-height: var(--autocomplete__menu__max-height, 342px); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool to see theming in action, this all works smoothly for me locally 🌺