From d262f586fcfd4b69f28a468425ae3a3c53bd45f1 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Mon, 4 Dec 2023 21:45:59 +1300 Subject: [PATCH] Add basic selected tags display to List Page --- .../pages/basePages/listPage/listPage.jsx | 20 +++++- .../pages/basePages/listPage/listPage.less | 69 ++++++++++++++++++- 2 files changed, 85 insertions(+), 4 deletions(-) diff --git a/client/homebrew/pages/basePages/listPage/listPage.jsx b/client/homebrew/pages/basePages/listPage/listPage.jsx index 475172d5a..441fb828f 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.jsx +++ b/client/homebrew/pages/basePages/listPage/listPage.jsx @@ -158,7 +158,12 @@ const ListPage = createClass({ } } urlParams.delete('tag'); + // Add tags to URL in the order they were clicked filterTags.forEach((tag)=>{ urlParams.append('tag', tag); }); + // Sort tags before updating state + filterTags.sort((a, b)=>{ + return a.indexOf(':') - b.indexOf(':') != 0 ? a.indexOf(':') - b.indexOf(':') : a.toLowerCase().localeCompare(b.toLowerCase()); + }); this.setState({ filterTags @@ -187,6 +192,17 @@ const ListPage = createClass({ ; }, + renderTagsOptions : function(){ + if(this.state.filterTags?.length == 0) return; + console.log('renderTags'); + return
+ {_.map(this.state.filterTags, (tag, idx)=>{ + const matches = tag.match(/^(?:([^:]+):)?([^:]+)$/); + return {this.updateListFilter('tag', tag);}}>{matches[2]}; + })} +
; + }, + renderSortOptions : function(){ return
Sort by :
@@ -197,9 +213,6 @@ const ListPage = createClass({ {/* {this.renderSortOption('Latest', 'latest')} */} {this.renderFilterOption()} - - -
; }, @@ -258,6 +271,7 @@ const ListPage = createClass({ {this.props.navItems} {this.renderSortOptions()} + {this.renderTagsOptions()}
diff --git a/client/homebrew/pages/basePages/listPage/listPage.less b/client/homebrew/pages/basePages/listPage/listPage.less index bcffbf3e7..e2e079f24 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.less +++ b/client/homebrew/pages/basePages/listPage/listPage.less @@ -52,7 +52,7 @@ } } } - .sort-container{ + .sort-container { font-family : 'Open Sans', sans-serif; position : sticky; top : 0; @@ -124,4 +124,71 @@ } + .tags-container { + font-family : 'Open Sans', sans-serif; + position : sticky; + top : 0; + left : 0; + width : 100%; + height : 30px; + background-color : #555; + border-top : 1px solid #666; + border-bottom : 1px solid #666; + color : white; + text-align : center; + z-index : 1; + display : flex; + justify-content : center; + align-items : center; + column-gap : 15px; + row-gap : 5px; + flex-wrap : wrap; + span { + text-transform : uppercase; + font-family : 'Open Sans', sans-serif; + font-size : 11px; + font-weight : bold; + border : 1px solid; + border-radius : 3px; + padding : 3px; + cursor : pointer; + &:before { + font-family: 'Font Awesome 5 Free'; + font-size: 12px; + margin-right: 3px; + } + &.type { + background-color: #0080003b; + color: #008000; + border-color: #008000; + &:before{ + content: '\f0ad'; + } + } + &.group { + background-color: #5050503b; + color: #000000; + border-color: #000000; + &:before{ + content: '\f500'; + } + } + &.meta { + background-color: #0000803b; + color: #000080; + border-color: #000080; + &:before{ + content: '\f05a'; + } + } + &.system { + background-color: #8000003b; + color: #800000; + border-color: #800000; + &:before{ + content: '\f518'; + } + } + } + } }