diff --git a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx index 90f9d32f23..0369305d5e 100644 --- a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx +++ b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx @@ -20,7 +20,8 @@ const BrewItem = createClass({ authors : [], stubbed : true }, - reportError : ()=>{} + updateListFilter : ()=>{}, + reportError : ()=>{} }; }, @@ -44,6 +45,10 @@ const BrewItem = createClass({ }); }, + updateFilter : function(type, term){ + this.props.updateListFilter(type, term); + }, + renderDeleteBrewLink : function(){ if(!this.props.brew.editId) return; @@ -109,6 +114,9 @@ const BrewItem = createClass({ const brew = this.props.brew; if(Array.isArray(brew.tags)) { // temporary fix until dud tags are cleaned brew.tags = brew.tags?.filter((tag)=>tag); //remove tags that are empty strings + brew.tags.sort((a, b)=>{ + return a.indexOf(':') - b.indexOf(':') != 0 ? a.indexOf(':') - b.indexOf(':') : a.toLowerCase().localeCompare(b.toLowerCase()); + }); } const dateFormatString = 'YYYY-MM-DD HH:mm:ss'; @@ -129,7 +137,7 @@ const BrewItem = createClass({ {brew.tags.map((tag, idx)=>{ const matches = tag.match(/^(?:([^:]+):)?([^:]+)$/); - return {matches[2]}; + return {this.updateFilter(tag);}}>{matches[2]}; })} : <> diff --git a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less index 5a1bb3d922..9bee4e5ebd 100644 --- a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less +++ b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less @@ -63,6 +63,41 @@ white-space: nowrap; display: inline-block; font-weight: bold; + border-color: currentColor; + cursor : pointer; + &:before { + font-family: 'Font Awesome 5 Free'; + font-size: 12px; + margin-right: 3px; + } + &.type { + background-color: #0080003b; + color: #008000; + &:before{ + content: '\f0ad'; + } + } + &.group { + background-color: #5050503b; + color: #000000; + &:before{ + content: '\f500'; + } + } + &.meta { + background-color: #0000803b; + color: #000080; + &:before{ + content: '\f05a'; + } + } + &.system { + background-color: #8000003b; + color: #800000; + &:before{ + content: '\f518'; + } + } } &:hover{ .links{ diff --git a/client/homebrew/pages/basePages/listPage/listPage.jsx b/client/homebrew/pages/basePages/listPage/listPage.jsx index d0cd11ec6b..2385b4490f 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.jsx +++ b/client/homebrew/pages/basePages/listPage/listPage.jsx @@ -36,6 +36,7 @@ const ListPage = createClass({ return { filterString : this.props.query?.filter || '', + filterTags : [], sortType : this.props.query?.sort || null, sortDir : this.props.query?.dir || null, query : this.props.query, @@ -82,7 +83,7 @@ const ListPage = createClass({ if(!brews || !brews.length) return
No Brews.
; return _.map(brews, (brew, idx)=>{ - return ; + return { this.updateUrl(this.state.filterString, this.state.sortType, this.state.sortDir, tag); }}/>; }); }, @@ -136,13 +137,33 @@ const ListPage = createClass({ return; }, - updateUrl : function(filterTerm, sortType, sortDir){ + updateUrl : function(filterTerm, sortType, sortDir, filterTag=''){ const url = new URL(window.location.href); const urlParams = new URLSearchParams(url.search); urlParams.set('sort', sortType); urlParams.set('dir', sortDir); + let filterTags = urlParams.getAll('tag'); + if(filterTag != '') { + if(filterTags.findIndex((tag)=>{return tag.toLowerCase()==filterTag.toLowerCase();}) == -1){ + filterTags.push(filterTag); + } else { + filterTags = filterTags.filter((tag)=>{ return tag.toLowerCase() != filterTag.toLowerCase(); }); + } + } + 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 + }); + if(!filterTerm) urlParams.delete('filter'); else @@ -166,6 +187,16 @@ const ListPage = createClass({ ; }, + renderTagsOptions : function(){ + if(this.state.filterTags?.length == 0) return; + return
+ {_.map(this.state.filterTags, (tag, idx)=>{ + const matches = tag.match(/^(?:([^:]+):)?([^:]+)$/); + return { this.updateUrl(this.state.filterString, this.state.sortType, this.state.sortDir, tag); }}>{matches[2]}; + })} +
; + }, + renderSortOptions : function(){ return
Sort by :
@@ -176,9 +207,6 @@ const ListPage = createClass({ {/* {this.renderSortOption('Latest', 'latest')} */} {this.renderFilterOption()} - - -
; }, @@ -186,14 +214,28 @@ const ListPage = createClass({ const testString = _.deburr(this.state.filterString).toLowerCase(); brews = _.filter(brews, (brew)=>{ + // Filter by user entered text const brewStrings = _.deburr([ brew.title, brew.description, brew.tags].join('\n') .toLowerCase()); - return brewStrings.includes(testString); + const filterTextTest = brewStrings.includes(testString); + + // Filter by user selected tags + let filterTagTest = true; + if(this.state.filterTags.length > 0){ + filterTagTest = Array.isArray(brew.tags) && this.state.filterTags?.every((tag)=>{ + return brew.tags.findIndex((brewTag)=>{ + return brewTag.toLowerCase() == tag.toLowerCase(); + }) >= 0; + }); + } + + return filterTextTest && filterTagTest; }); + return _.orderBy(brews, (brew)=>{ return this.sortBrewOrder(brew); }, this.state.sortDir); }, @@ -224,6 +266,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 00d753429a..0aa4a278df 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.less +++ b/client/homebrew/pages/basePages/listPage/listPage.less @@ -53,7 +53,7 @@ } } } - .sort-container{ + .sort-container { font-family : 'Open Sans', sans-serif; position : sticky; top : 0; @@ -125,4 +125,66 @@ } + .tags-container { + height : 30px; + background-color : #555; + border-top : 1px solid #666; + border-bottom : 1px solid #666; + color : white; + display : flex; + justify-content : center; + align-items : center; + column-gap : 15px; + row-gap : 5px; + flex-wrap : wrap; + span { + font-family : 'Open Sans', sans-serif; + font-size : 11px; + font-weight : bold; + border : 1px solid; + border-radius : 3px; + padding : 3px; + cursor : pointer; + color: #dfdfdf; + &:before { + font-family: 'Font Awesome 5 Free'; + font-size: 12px; + margin-right: 3px; + } + &:after { + content: '\f00d'; + font-family: 'Font Awesome 5 Free'; + font-size: 12px; + margin-left: 3px; + } + &.type { + background-color: #008000; + border-color: #00a000; + &:before{ + content: '\f0ad'; + } + } + &.group { + background-color: #505050; + border-color: #000000; + &:before{ + content: '\f500'; + } + } + &.meta { + background-color: #000080; + border-color: #0000a0; + &:before{ + content: '\f05a'; + } + } + &.system { + background-color: #800000; + border-color: #a00000; + &:before{ + content: '\f518'; + } + } + } + } } diff --git a/package-lock.json b/package-lock.json index 770ff67168..9f39b3bd58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ "vitreum": "git+https://git@github.com/calculuschild/vitreum.git" }, "devDependencies": { - "eslint": "^8.56.0", + "eslint": "^8.57.0", "eslint-plugin-jest": "^27.9.0", "eslint-plugin-react": "^7.33.2", "jest": "^29.7.0", @@ -1958,9 +1958,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.56.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.56.0.tgz", - "integrity": "sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", + "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1978,13 +1978,13 @@ } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.13", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", - "integrity": "sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==", + "version": "0.11.14", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", + "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^2.0.1", - "debug": "^4.1.1", + "@humanwhocodes/object-schema": "^2.0.2", + "debug": "^4.3.1", "minimatch": "^3.0.5" }, "engines": { @@ -2005,9 +2005,9 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", - "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", + "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", "dev": true }, "node_modules/@istanbuljs/load-nyc-config": { @@ -5588,16 +5588,16 @@ } }, "node_modules/eslint": { - "version": "8.56.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.56.0.tgz", - "integrity": "sha512-Go19xM6T9puCOWntie1/P997aXxFsOi37JIHRWI514Hc6ZnaHGKY9xFhrU65RT6CcBEzZoGG1e6Nq+DT04ZtZQ==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", + "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", "@eslint/eslintrc": "^2.1.4", - "@eslint/js": "8.56.0", - "@humanwhocodes/config-array": "^0.11.13", + "@eslint/js": "8.57.0", + "@humanwhocodes/config-array": "^0.11.14", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "@ungap/structured-clone": "^1.2.0", diff --git a/package.json b/package.json index 884d293ec5..b44d1cc4dc 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "vitreum": "git+https://git@github.com/calculuschild/vitreum.git" }, "devDependencies": { - "eslint": "^8.56.0", + "eslint": "^8.57.0", "eslint-plugin-jest": "^27.9.0", "eslint-plugin-react": "^7.33.2", "jest": "^29.7.0", diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index 23c3992fd2..c155d1c093 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -307,7 +307,6 @@ margin-left : -0.16cm; background-color : var(--HB_Color_MonsterStatBackground); background-image : @monsterBlockBackground; - background-attachment : unset; background-blend-mode : overlay; border-style : solid; border-width : 7px 6px;