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

Redesign filter-panel in audios and memories page #376

Merged
merged 44 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5ec6841
added the filter section partials
Jul 9, 2023
27c43bc
updated alpine component for collapsing and expanding filter panels
Jul 10, 2023
d8d9224
updated for wrapping div with filter ids
Jul 11, 2023
29eb706
filter section updated for subtitle and alpine class
Jul 11, 2023
f9579a2
memories section updated for filter redesign
Jul 11, 2023
599b4b2
added subtitle comment
Jul 11, 2023
65b2f79
comments removed
Jul 11, 2023
fb38339
code updated for render in its own line.
Jul 12, 2023
bde7b28
id removed and space removed in alpine code.
Jul 12, 2023
2d63f50
removed sortBy from gurus list working as default
Jul 13, 2023
a1c72dc
filter styles updated as per design provided
Jul 15, 2023
75665ac
hide subtitle when collapse
Jul 16, 2023
3edcca7
title panel changed to div
Jul 16, 2023
6b6f2ee
updated panel background color when expanded
Jul 16, 2023
040a7dd
updated radio button and checkboxes styles
Jul 16, 2023
3649057
updated height for checkbox and radio btn for adjusting v-alignment
Jul 17, 2023
3e69085
header height adjusted and shadow removed
Jul 18, 2023
1b75455
shadow added to the last header
Jul 18, 2023
8cda054
header font weight updated
Jul 18, 2023
f44bb89
updated content spacing with header
Jul 18, 2023
979c3b4
updated content spacing with header for bigger screens
Jul 18, 2023
c8cdee9
updated items number alignment and color
Jul 18, 2023
31bff4e
updated checkbox sytles
Jul 18, 2023
416bfd1
updated checkbox style
Jul 18, 2023
06b73f6
updated sortBy descending count
Jul 21, 2023
2321878
added rounded border filter items
Jul 26, 2023
6d12825
svg icon reversed
Jul 26, 2023
3c45d56
updated rounded border style and padding
Aug 4, 2023
1ebdd2d
refinementlist border and collapse icon adjusted
Aug 8, 2023
e3231a2
updated for refinement count text and checkbox style
Aug 8, 2023
7f8abd6
panel color changed
Aug 8, 2023
ecec0ae
padding added between title and icon
Aug 8, 2023
ca973c4
Merge branch 'main' into filter-redesign
anantakrishna Aug 13, 2023
95348b9
Adjust filter panel layout and styling
anantakrishna Aug 14, 2023
a769a9b
Move columns styling into HTML from JS
anantakrishna Aug 14, 2023
b61d297
Unify refinement list and numeric menu styling
anantakrishna Aug 14, 2023
346cd5c
Increaed padding of the filter items list
anantakrishna Aug 14, 2023
775d171
Unify text color
anantakrishna Aug 14, 2023
bbe522e
Implement checkbox and radio styling
anantakrishna Aug 14, 2023
dc01766
Disble user select and add some margin after subtitle
anantakrishna Aug 14, 2023
3ce0cc6
Remove wierd shadow of the last filter group
anantakrishna Aug 14, 2023
fed34c3
Adjust styles for mobiles
anantakrishna Aug 14, 2023
4b3c032
Remove shadow of the last filter in memories
anantakrishna Aug 18, 2023
46e7118
Merge branch 'main' into filter-redesign
anantakrishna Aug 18, 2023
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
35 changes: 35 additions & 0 deletions frontend/src/_includes/partials/filter-section.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
Declaring a data attribute to use it further with `group-data-[expanded]` modifier.
https://tailwindcss.com/docs/hover-focus-and-other-states#styling-based-on-parent-state
https://tailwindcss.com/docs/hover-focus-and-other-states#data-attributes
This is better than using :class because we stay in the Tailwind paradigm, avail of class sorting etc.
-->
<div
x-data="{ expanded: true }"
:data-expanded="expanded"
class="group mb-2 overflow-hidden text-neutral-600"
>
<header
@click="expanded = !expanded"
class="flex cursor-pointer select-none rounded-md border border-neutral-200 px-2 py-2 text-left align-baseline text-sm font-medium uppercase transition-colors group-data-[expanded]:bg-neutral-100 group-data-[expanded]:text-neutral-800"
>
<span class="mr-2 flex-grow">{{ title }}</span>
<svg class="h-5 w-3 shrink-0 group-data-[expanded]:rotate-180 motion-safe:transition-transform" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5 5 1 1 5"/>
</svg>
</header>
<main
x-show="expanded"
class="-mt-1 rounded-b-md border border-t-0 border-neutral-200 p-2 pt-3 transition-opacity dark:border-neutral-700 dark:bg-neutral-900"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
>
{% if subtitle -%}
<p class="mb-2 text-xs font-light lowercase">{{ subtitle }}</p>
{%- endif %}
<!-- Slot for Instant Search, should be empty for selectors to work -->
<div></div>
</main>
</div>
2 changes: 1 addition & 1 deletion frontend/src/_layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
</header>

<!-- Page Content -->
<section class="flex-1">
<section class="flex-1 md:py-3">
<div class="mx-auto max-w-screen-xl">{{ content }}</div>
</section>

Expand Down
44 changes: 31 additions & 13 deletions frontend/src/audios.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,44 @@
x-cloak
@keydown.escape="open = false"
:class="open ? 'translate-x-0': '-translate-x-full'"
class="fixed top-0 z-20 flex h-full w-64 flex-col bg-white text-sm transition-transform ease-linear md:static md:z-auto md:flex md:w-1/5 md:max-w-sm md:translate-x-0"
class="fixed top-0 z-20 flex h-full w-64 flex-col bg-white transition-transform ease-linear md:static md:z-auto md:flex md:w-1/5 md:max-w-sm md:translate-x-0"
>
<div class="flex-none bg-submarine-500 p-2 text-center font-bold uppercase text-neutral-600 md:hidden">Filter</div>
<div class="grow overflow-y-auto overflow-x-hidden p-2 pb-40 pt-0">
<div id="language-list"></div>
<div id="sound-quality-list"></div>
<div id="duration-menu"></div>
<div id="percentage-menu"></div>
<div id="category-list"></div>
<div id="year-list"></div>
<div id="location-list"></div>
<header class="flex-none border-b p-4 font-bold text-neutral-600 md:hidden">Filter</header>
<div class="grow overflow-y-auto overflow-x-hidden p-2 pb-40">
<div id="language-list">
{% render 'partials/filter-section.html', title: 'Languages' -%}
</div>
<div id="sound-quality-list">
{% render 'partials/filter-section.html', title: 'Sound Quality' -%}
</div>
<div id="duration-menu">
{% render 'partials/filter-section.html', title: 'Duration' -%}
</div>
<div id="percentage-menu">
{% render 'partials/filter-section.html', title: 'Srila Gurudeva Timing' -%}
</div>
<div id="category-list">
{% render 'partials/filter-section.html', title: 'Category' -%}
</div>
<!-- Columns is not an ideal solution, waiting for better suggestions: https://stackoverflow.com/q/76898065/3082178 -->
<div
id="year-list"
class="[&_.ais-RefinementList-labelText]:whitespace-nowrap [&_.ais-RefinementList]:columns-[5rem]"
>
{% render 'partials/filter-section.html', title: 'Year' -%}
</div>
<div id="location-list">
{% render 'partials/filter-section.html', title: 'Location' -%}
</div>
</div>
<div class="flex-none border-t p-2 md:hidden">
<footer class="flex-none border-t p-4 md:hidden">
<button
@click="open = false"
class="w-full rounded-md bg-neutral-600 p-2 font-semibold uppercase text-white shadow-sm"
class="rounded-md bg-neutral-600 px-10 py-2 text-sm font-semibold text-white"
>
Close
</button>
</div>
</footer>
</div>
<main class="w-full grow px-2 sm:w-4/5 sm:px-4">
<div id="searchbox" class="flex flex-none">
Expand Down
26 changes: 12 additions & 14 deletions frontend/src/css/algolia.css
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ a[class^='ais-'] {
.ais-NumericMenu-list,
.ais-RatingMenu-list,
.ais-RefinementList-list {
@apply font-normal leading-normal;
@apply space-y-2;
}

.ais-RefinementList-item {
}

.ais-HierarchicalMenu-link {
Expand All @@ -195,27 +198,26 @@ a[class^='ais-'] {
}
}

.ais-RefinementList-item {
@apply break-inside-avoid py-1;
}

.ais-NumericMenu-label,
.ais-RefinementList-label {
@apply flex items-baseline;
@apply flex break-inside-avoid items-center;
}

.ais-NumericMenu-radio,
.ais-RefinementList-checkbox {
@apply flex-none;
}

.ais-NumericMenu-labelText,
.ais-RefinementList-labelText {
@apply grow overflow-x-hidden break-words px-1;
@apply mx-2 overflow-x-hidden break-words text-sm;
}

.ais-HierarchicalMenu-count,
.ais-Menu-count,
.ais-RefinementList-count,
.ais-ToggleRefinement-count {
@apply flex-none text-xs text-gray-400;
@apply ml-auto flex-none text-xs font-semibold;
}

.ais-HierarchicalMenu-showMore,
Expand Down Expand Up @@ -279,7 +281,7 @@ a[class^='ais-'] {
@apply block rounded border px-3 py-1 transition-colors duration-200 ease-out focus:outline-none;

.ais-Pagination-item--disabled & {
@apply cursor-not-allowed text-gray-400 opacity-60;
@apply cursor-not-allowed text-neutral-400 opacity-60;
}

.ais-Pagination-item--selected & {
Expand All @@ -299,7 +301,7 @@ a[class^='ais-'] {
}

& .ais-SearchBox-input {
@apply h-8 px-8 text-sm;
@apply h-8 px-8;
}

& .ais-SearchBox-submit,
Expand Down Expand Up @@ -356,10 +358,6 @@ a[class^='ais-'] {
@apply flex flex-wrap max-sm:justify-center;
}

.ais-NumericMenu-labelText {
@apply pl-1;
}

.ais-Stats-text {
@apply font-bold italic text-neutral-600;
}
22 changes: 22 additions & 0 deletions frontend/src/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@
font-style: normal;
}

[type='checkbox'],
[type='radio'] {
@apply h-4 w-4 shrink-0 select-none appearance-none border border-neutral-300 bg-white bg-origin-border;
&:checked {
@apply border-transparent bg-current bg-contain bg-center bg-no-repeat;
}
}

input[type='checkbox'] {
@apply rounded;
&:checked {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 16 16' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0z'/%3E%3C/svg%3E");
}
}

input[type='radio'] {
@apply rounded-full;
&:checked {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 16 16' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='8' cy='8' r='3'/%3E%3C/svg%3E");
}
}

button {
@apply focus:outline-none;
}
Expand Down
60 changes: 14 additions & 46 deletions frontend/src/js/audios.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
hits,
numericMenu,
pagination,
panel,
refinementList,
stats,
} from 'instantsearch.js/es/widgets';
Expand Down Expand Up @@ -84,24 +83,16 @@ search.addWidgets([
document.getElementById('under-progress').classList.remove('hidden');
},
},
panel({
templates: {
header: () => 'Location',
},
})(refinementList)({
container: '#location-list',
refinementList({
container: '#location-list div:empty',
attribute: 'location',
searchable: true,
showMore: true,
showMoreLimit: 50,
sortBy: ['name:asc'],
}),
panel({
templates: {
header: () => 'Languages',
},
})(refinementList)({
container: '#language-list',
refinementList({
container: '#language-list div:empty',
attribute: 'languageCategory',
transformItems: (items) =>
items
Expand All @@ -116,12 +107,8 @@ search.addWidgets([
highlighted: languageCategories[item.label].label,
})),
}),
panel({
templates: {
header: () => 'Sound Quality',
},
})(refinementList)({
container: '#sound-quality-list',
refinementList({
container: '#sound-quality-list div:empty',
attribute: 'soundQualityRating',
sortBy: (a, b) =>
soundQualityRatingMapping[a.name].order -
Expand All @@ -133,47 +120,28 @@ search.addWidgets([
highlighted: soundQualityRatingMapping[item.label].label || item.label,
})),
}),
panel({
templates: {
header: () => 'Category',
},
})(refinementList)({
container: '#category-list',
refinementList({
container: '#category-list div:empty',
attribute: 'category',
sortBy: ['name:asc'],
}),
panel({
templates: {
header: () => 'Year',
},
})(refinementList)({
container: '#year-list',
refinementList({
container: '#year-list div:empty',
attribute: 'year',
limit: 100,
sortBy: ['name:asc'],
cssClasses: {
list: 'columns-[5rem]',
},
}),
panel({
templates: {
header: () => 'Srila Gurudeva Timing',
},
})(numericMenu)({
container: '#percentage-menu',
numericMenu({
container: '#percentage-menu div:empty',
attribute: 'percentage',
items: [
{ label: 'Any' },
{ label: 'More than 50%', start: 0.5 },
{ label: 'More than 90%', start: 0.9 },
],
}),
panel({
templates: {
header: () => 'Duration',
},
})(numericMenu)({
container: '#duration-menu',
numericMenu({
container: '#duration-menu div:empty',
attribute: 'duration',
items: [
{ label: 'Any' },
Expand Down
48 changes: 11 additions & 37 deletions frontend/src/js/memories.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
hits,
numericMenu,
pagination,
panel,
refinementList,
stats,
} from 'instantsearch.js/es/widgets';
Expand Down Expand Up @@ -60,39 +59,23 @@ search.addWidgets([
document.getElementById('results-footer').classList.remove('hidden');
},
},
panel({
templates: {
header: () => 'Program Name',
},
})(refinementList)({
container: '#program-name-list',
refinementList({
container: '#program-name-list div:empty',
attribute: 'programName',
sortBy: ['name:asc'],
}),
panel({
templates: {
header: () => 'Speaker Country',
},
})(refinementList)({
container: '#speaker-country-list',
refinementList({
container: '#speaker-country-list div:empty',
attribute: 'speakerCountry',
sortBy: ['name:asc'],
}),
panel({
templates: {
header: () => 'Languages',
},
})(refinementList)({
container: '#language-list',
refinementList({
container: '#language-list div:empty',
attribute: 'language',
sortBy: ['name:asc'],
}),
panel({
templates: {
header: () => 'Duration',
},
})(numericMenu)({
container: '#duration-menu',
numericMenu({
container: '#duration-menu div:empty',
attribute: 'duration',
items: [
{ label: 'Any' },
Expand All @@ -101,21 +84,12 @@ search.addWidgets([
{ label: '45+ minutes', start: 2700 },
],
}),
panel({
templates: {
header: (options, { html }) => html`
<span>Initiating Guru(s)</span>
<p class="text-xs font-normal lowercase">
[Sorted by decreasing count of matching records]
</p>
`,
},
})(refinementList)({
container: '#gurus-list',
refinementList({
container: '#gurus-list div:empty',
attribute: 'gurus.fullName',
showMore: true,
showMoreLimit: 20,
sortBy: ['gurus:desc'],
anantakrishna marked this conversation as resolved.
Show resolved Hide resolved
sortBy: ['count:desc'],
}),
hits({
container: '#hits',
Expand Down
Loading