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

Scrollable modal styles #506

Merged
merged 4 commits into from
Dec 15, 2023
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
2 changes: 1 addition & 1 deletion web/app/components/related-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export default class RelatedResourcesComponent extends Component<RelatedResource
try {
let algoliaResponse = await this.algolia.searchIndex
.perform(index, query, {
hitsPerPage: options?.hitsPerPage || 4,
hitsPerPage: options?.hitsPerPage || 12,
filters: filterString,
attributesToRetrieve: [
"title",
Expand Down
62 changes: 32 additions & 30 deletions web/app/components/related-resources/add.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<Hds::Modal
data-test-add-related-resource-modal
@onClose={{@onClose}}
class="h-[475px]"
class="search-window related-resources-modal"
as |M|
>
<M.Header data-test-add-related-resource-modal-title>
{{@headerTitle}}
</M.Header>
<M.Body>
<M.Body class="h-[440px]">
<X::DropdownList
data-test-add-related-resources-list
@items={{this.algoliaResults}}
Expand All @@ -29,38 +29,40 @@
class="non-floating-list theme--neutral"
>
<:anchor as |dd|>
<div class="relative">
<Hds::Form::TextInput::Base
data-test-related-resources-search-input
{{autofocus waitUntilNextRunloop=true}}
{{did-insert (fn this.didInsertInput dd)}}
{{on "input" this.onInput}}
{{on "keydown" this.onInputKeydown}}
{{on "focusin" this.enableKeyboardNav}}
{{on "focusout" this.disableKeyboardNav}}
@type="search"
@value={{this.query}}
name="related-resources-search"
size="25"
placeholder={{@inputPlaceholder}}
aria-label={{@inputPlaceholder}}
aria-controls={{dd.ariaControls}}
aria-expanded={{dd.contentIsShown}}
aria-haspopup="listbox"
/>
{{#if @searchIsRunning}}
<div
data-test-related-resources-search-loading-icon
class="absolute top-1/2 right-3 flex -translate-y-1/2 bg-white"
>
<FlightIcon @name="loading" />
</div>
{{/if}}
<div class="search-container">
<div class="relative">
<Hds::Form::TextInput::Base
data-test-related-resources-search-input
{{autofocus waitUntilNextRunloop=true}}
{{did-insert (fn this.didInsertInput dd)}}
{{on "input" this.onInput}}
{{on "keydown" this.onInputKeydown}}
{{on "focusin" this.enableKeyboardNav}}
{{on "focusout" this.disableKeyboardNav}}
@type="search"
@value={{this.query}}
name="related-resources-search"
size="25"
placeholder={{@inputPlaceholder}}
aria-label={{@inputPlaceholder}}
aria-controls={{dd.ariaControls}}
aria-expanded={{dd.contentIsShown}}
aria-haspopup="listbox"
/>
{{#if @searchIsRunning}}
<div
data-test-related-resources-search-loading-icon
class="absolute top-1/2 right-3 flex -translate-y-1/2 bg-white"
>
<FlightIcon @name="loading" />
</div>
{{/if}}
</div>
</div>
</:anchor>
<:header>
{{#if this.listHeaderIsShown}}
<div class="related-resources-modal-container mt-3.5">
<div class="related-resources-modal-container mt-0.5">
<h4 class="hermes-h4" data-test-related-resources-list-header>
{{#if this.query.length}}
Results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}

.related-resources-modal-container {
@apply relative w-full px-3;
@apply relative w-full px-6;
}

.add-external-resource-container {
Expand Down
39 changes: 38 additions & 1 deletion web/app/styles/components/modal-dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
.hds-modal {
@apply overflow-visible;

.search-container {
@apply sticky top-0 z-10 bg-color-page-primary px-4 pb-4 pt-4;
}

.ember-basic-dropdown {
@apply w-full mb-2 mt-1;
@apply mb-2 mt-1 w-full;
}

&__body {
Expand All @@ -15,5 +19,38 @@
// Positions dropdown correctly
@apply mb-0;
}

&.search-window {
@apply overflow-hidden;

.hds-modal__body {
// height must be set for scroll-into-view to work
@apply relative flex flex-col p-0;
}

.hds-modal__footer {
@apply relative;
}

.x-dropdown-list {
@apply max-h-full overflow-auto;
}

.x-dropdown-list-container {
@apply h-full rounded-none;
}

.x-dropdown-list-scroll-container {
@apply rounded-none;
}

.x-dropdown-list-items {
@apply pb-4;
}

.x-dropdown-list-item-link {
@apply px-6;
}
}
}
}