Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<div class="col-12 col-lg-8 offset-lg-2 intro-text order-2 order-lg-1{% if page.dark_theme %} dark-theme{% endif %}">
<h1 class="h1-heading text-center mt-0">{{ page.header }}</h1>
<p class="body-large mb-0">{{ page.intro_text }}</p>
<div id="product-filter-search" class='tw-col-8 tw-my-5' tabindex="0">
<span class="search-icon">&nbsp;</span>
<input type="text" role="searchbox" id="product-filter-search-input" placeholder="{% trans "Search all products" %}" class="body-large" value="">
<label for="product-filter-search-input" class="clear-icon">&nbsp;</label>
</div>
</div>
<div class="col-12 col-lg-2 badge-container text-right order-1 order-lg-2">
<img class="webby-award-badge" src="{% static '_images/buyers-guide/webby-award-badge.svg' %}" alt="{% trans "2020 Webby Award Winner Badge" %}">
Expand All @@ -35,11 +40,6 @@ <h1 class="h1-heading text-center mt-0">{{ page.header }}</h1>
<div id="sticky-bar" class="creepiness-slider bg-white text-center">

<!-- temporary location for dev work -->
<span id="product-filter-search" tabindex="0">
<span class="search-icon">&nbsp;</span>
<input type="text" role="searchbox" id="product-filter-search-input" placeholder="{% trans "Search all products" %}" class="body-large" value="">
<label for="product-filter-search-input" class="clear-icon">&nbsp;</label>
</span>

<span class="creep-o-meter-information">
<p class="speech-bubble-container">
Expand Down
31 changes: 1 addition & 30 deletions source/js/buyers-guide/search.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const SEARCH_BAR = document.getElementById(`sticky-bar`);
const ALL_PRODUCTS = document.querySelectorAll(`figure.product-box`);
const NO_RESULTS_NOTICE = document.getElementById(
`product-filter-no-results-notice`
Expand All @@ -25,35 +24,7 @@ const SearchFilter = {

if (searchText) {
searchBar.classList.add(`has-content`);
if (window.innerWidth > 768) {
SEARCH_BAR.classList.add(`search-active`, `creep-o-meter-moved`);
}
} else {
searchBar.classList.remove(`has-content`);
}

SearchFilter.filter(searchText);
});

searchBar.addEventListener(`focus`, (_evt) => {
// We want focus to fall through to the input element instead
searchInput.focus();
});

searchInput.addEventListener(`focus`, (_evt) => {
// And to make CSS work easier, set a class on the parent container
// for both search and the creep-o-meter component, so that it can
// relocate so as not to interfere with the search bar.
if (window.innerWidth > 768) {
SEARCH_BAR.classList.add(`search-active`, `creep-o-meter-moved`);
}
});

// Whenever focus is moved away from the search bar, check if we can
// safely restore the creep-o-meter component or not.
searchInput.addEventListener(`blur`, (_evt) => {
if (!searchInput.value.trim()) {
SEARCH_BAR.classList.remove(`search-active`);
SearchFilter.filter(searchText);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Since the search bar is no longer collapsing/expanding, we no longer needed this section of the javascript file which would add classes/ move the face icon when the search bar was expanded/ replace it if the search bar was collapsed again.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so nice to be able to remove code here.

}
});

Expand Down
46 changes: 22 additions & 24 deletions source/sass/buyers-guide/views/catalog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ body.catalog {

.intro-text {
padding-top: 12px;
padding-bottom: 28px;
padding-bottom: var(--search-box-height-mobile);

@media (min-width: $breakpoint) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added a new breakpoint for the MD size, since the category navigation would cover the search bar.

padding-top: 12px;
padding-bottom: calc(var(--search-box-height-desktop) + 90px);
}
@media (min-width: $hero-breakpoint) {
padding-top: 90px;
padding-bottom: 90px;
padding-bottom: calc(var(--search-box-height-desktop) + 90px);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Made room for the search bar by taking the existing 90px of padding and adding the size of the search bar.

}
}

Expand All @@ -56,11 +60,7 @@ body.catalog {
}

#product-filter-search {
--initial-width: calc(
100% - calc(var(--clear-icon-size) + var(--search-icon-size-desktop))
);
--expanded-width: var(--initial-width);

background-color: $white;
cursor: pointer;
position: relative;
display: flex;
Expand All @@ -75,17 +75,12 @@ body.catalog {

@media (min-width: $bp-md) {
--container-padding: 0.5em;
--initial-width: calc(
3 * var(--container-padding) + var(--search-icon-size-desktop)
);
--expanded-width: calc(100% - var(--pni-checkbox-container-width) - 2em);

position: absolute;
left: 0;
border: 1px solid transparent;
padding: var(--container-padding);
padding-right: 1em;
width: var(--initial-width);
height: var(--search-box-height-desktop);
overflow: hidden;

Expand All @@ -103,10 +98,6 @@ body.catalog {
border-color: $black;
cursor: default;

@media (min-width: $bp-md) {
width: var(--expanded-width);
}

.search-icon {
cursor: default;
}
Expand Down Expand Up @@ -172,14 +163,15 @@ body.catalog {
user-select: none;
position: absolute;
left: 0;
padding-top: 0.5em;
top: calc(var(--sticky-height) + var(--mobile-creep-offset));

@media (min-width: $bp-md) {
left: unset;
right: 0;
margin-left: 0.5em;
width: var(--pni-checkbox-container-width);
font-size: 100%;
top: unset;
}

input[type="checkbox"] {
Expand Down Expand Up @@ -356,7 +348,13 @@ body.catalog {
);

&.creep-o-meter-moved {
height: var(--small-sticky-height);
height: 80px;
Copy link
Copy Markdown
Collaborator Author

@danielfmiranda danielfmiranda Oct 11, 2021

Choose a reason for hiding this comment

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

This is for mobile sizes, when the user scrolls, the face icon drops from the middle of the page:
image

to the bottom corner. The containing div then shrinks to house only the privacy not included checkbox.

image


@media (max-width: $bp-md) {
#product-filter-pni {
top: calc(var(--mobile-creep-offset));
}
}
}

@media (min-width: $breakpoint) {
Expand All @@ -373,20 +371,19 @@ body.catalog {
.creep-o-meter-information {
position: absolute;
white-space: nowrap;
top: calc(var(--sticky-height) + var(--mobile-creep-offset));
right: 0;
left: 0;
opacity: 1;
transition: opacity 0.2s ease;
top: unset;
right: calc(50% - 36px);
left: unset;

&.fade-out {
opacity: 0;
}

@media (min-width: $bp-md) {
top: unset;
right: calc(50% - 36px);
left: unset;
@media (max-width: $bp-sm) {
right: calc(50% - 144px);
}
}

Expand Down Expand Up @@ -484,6 +481,7 @@ body.catalog {
.oh-no-face {
width: 50px;
height: 50px;
margin: auto;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is a minor fix to a bug I found while working on this ticket, where if you were to search and no results appeared, the "oh no" face would be all the way to the left of the page. The margin makes sure its at center :D

}
@media (min-width: $breakpoint) {
.oh-no-face {
Expand Down