Skip to content

Commit

Permalink
feat: Adjust library home filter styles
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuf-musleh committed Jun 26, 2024
1 parent 3a67927 commit 2ff49f7
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@import "textbooks/Textbooks";
@import "content-tags-drawer/ContentTagsDropDownSelector";
@import "content-tags-drawer/ContentTagsCollapsible";
@import "search-modal/SearchModal";
@import "search-modal";
@import "certificates/scss/Certificates";
@import "group-configurations/GroupConfigurations";
@import "library-authoring";
Expand Down
2 changes: 1 addition & 1 deletion src/library-authoring/LibraryAuthoringPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ const LibraryAuthoringPage = () => {
/>
<SearchKeywordsField className="w-50" />
<div className="d-flex mt-3 align-items-center">
<FilterByBlockType />
<FilterByTags />
<FilterByBlockType />
<ClearFiltersButton />
<div className="flex-grow-1" />
<div className="text-muted x-small align-middle"><Stats /></div>
Expand Down
7 changes: 7 additions & 0 deletions src/search-modal/FilterBy.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Options for the "filter by tag/block type" menu
.pgn__menu.filter-by-refinement-menu {
.pgn__menu-item {
// Make the "filter by tag/block type" menu expand to fit the tags hierarchy and longer block type names
width: 100%;
}
}
1 change: 1 addition & 0 deletions src/search-modal/FilterByBlockType.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const FilterByBlockType = () => {
<SearchFilterWidget
appliedFilters={blockTypesFilter.map(blockType => ({ label: <BlockTypeLabel type={blockType} /> }))}
label={<FormattedMessage {...messages.blockTypeFilter} />}
filterType="blockType"
>
<Form.Group>
<Form.CheckboxSet
Expand Down
3 changes: 2 additions & 1 deletion src/search-modal/FilterByTags.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const FilterByTags = () => {
<SearchFilterWidget
appliedFilters={tagsFilter.map(tf => ({ label: tf.split(TAG_SEP).pop() }))}
label={<FormattedMessage {...messages.blockTagsFilter} />}
filterType="tags"
>
<Form.Group className="pt-3">
<SearchField
Expand All @@ -199,7 +200,7 @@ const FilterByTags = () => {
placeholder={intl.formatMessage(messages.searchTagsByKeywordPlaceholder)}
className="mx-3 mb-1"
/>
<Menu className="tags-refinement-menu" style={{ boxShadow: 'none' }}>
<Menu className="filter-by-refinement-menu" style={{ boxShadow: 'none' }}>
<TagOptions
tagSearchKeywords={tagSearchKeywords}
toggleTagChildren={toggleTagChildren}
Expand Down
15 changes: 13 additions & 2 deletions src/search-modal/SearchFilterWidget.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/prop-types */
// @ts-check
import React from 'react';
import { ArrowDropDown } from '@openedx/paragon/icons';
import { ArrowDropDown, Tag, FilterList } from '@openedx/paragon/icons';
import {
Badge,
Button,
Expand All @@ -20,12 +20,22 @@ import {
* When clicked, the button will display a dropdown menu containing this
* element's `children`. So use this to wrap a <RefinementList> etc.
*
* @type {React.FC<{appliedFilters: {label: React.ReactNode}[], label: React.ReactNode, children: React.ReactNode}>}
* @type {React.FC<{
* appliedFilters: {label: React.ReactNode}[],
* label: React.ReactNode,
* children: React.ReactNode,
* filterType?: string
* }>}
*/
const SearchFilterWidget = ({ appliedFilters, ...props }) => {
const [isOpen, open, close] = useToggle(false);
const [target, setTarget] = React.useState(null);

const iconMap = {
blockType: FilterList,
tags: Tag,
};

return (
<>
<div className="d-flex mr-3">
Expand All @@ -34,6 +44,7 @@ const SearchFilterWidget = ({ appliedFilters, ...props }) => {
variant={appliedFilters.length ? 'light' : 'outline-primary'}
size="sm"
onClick={open}
iconBefore={iconMap[props.filterType]}
iconAfter={ArrowDropDown}
>
{props.label}
Expand Down
16 changes: 0 additions & 16 deletions src/search-modal/SearchModal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,6 @@
}
}

// Options for the "filter by tag" menu
.pgn__menu.tags-refinement-menu {
.pgn__menu-item {
// Make the "filter by tag" menu much wider than normal, because we need the space to display the tags hierarchy
width: 100%;
}
}

// Options for the "filter by block type" menu
.pgn__menu.block-type-refinement-menu {
.pgn__menu-item {
// Make the "filter by block type" menu expand to fit longer block types names
width: 100%;
}
}

.pgn__menu-item {
// Fix a bug in Paragon menu dropdowns: the checkbox currently shrinks if the text is too long.
// https://github.com/openedx/paragon/pull/3019
Expand Down
2 changes: 2 additions & 0 deletions src/search-modal/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import "search-modal/SearchModal";
@import "search-modal/FilterBy";

0 comments on commit 2ff49f7

Please sign in to comment.