From d4850f64fda0f4799782346293775a5628ffad2b Mon Sep 17 00:00:00 2001 From: CNCF-bot Date: Mon, 17 Apr 2023 13:41:29 +0100 Subject: [PATCH] allow x large --- src/components/GuideRenderer.js | 6 +++--- src/components/Item.js | 10 +++++----- src/style.css | 14 +++++++++++++- src/utils/landscapeCalculations.js | 19 +++++++++---------- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/components/GuideRenderer.js b/src/components/GuideRenderer.js index b68f0a4a..81d909c8 100644 --- a/src/components/GuideRenderer.js +++ b/src/components/GuideRenderer.js @@ -1,6 +1,6 @@ const _ = require('lodash'); -const { isLargeFn } = require('../utils/landscapeCalculations'); +const { sizeFn } = require('../utils/landscapeCalculations'); const { renderItem } = require('./Item.js'); const { h } = require('../utils/format'); const { assetPath } = require('../utils/assetPath'); @@ -17,7 +17,7 @@ module.exports.render = function({settings, items, guide}) { const title = `

${h(settings.global.short_name)} Landscape Guide

`; const renderSubcategoryMetadata = ({ node, entries }) => { - const orderedEntries = _.orderBy(entries, (x) => !x.isLarge); + const orderedEntries = _.orderBy(entries, (x) => -x.size); const projectEntries = entries.filter(entry => entry.project) return ` ${ (node.buzzwords.length > 0 || projectEntries.length > 0) ? `
@@ -110,7 +110,7 @@ module.exports.render = function({settings, items, guide}) { return null; } const enhanced = { ...entry, categoryAttrs } - return { ...enhanced, isLarge: isLargeFn(enhanced) } + return { ...enhanced, size: sizeFn(enhanced) } }).filter( (x) => !!x); return ` diff --git a/src/components/Item.js b/src/components/Item.js index 387c221d..a518485f 100644 --- a/src/components/Item.js +++ b/src/components/Item.js @@ -21,7 +21,7 @@ const largeItem = function(item) { if (isMember) { return ` -
+
${item.name} +
${item.name} - ${isLarge ? largeItem({isMember, ...item}) : smallItem({...item})} + ${size > 1 ? largeItem({isMember, ...item}) : smallItem({...item})}
`; } diff --git a/src/style.css b/src/style.css index cb7ddbaa..d30a0534 100644 --- a/src/style.css +++ b/src/style.css @@ -1463,6 +1463,13 @@ html.ios.has-selected-item, html.ios.has-selected-item body { height: 63px; } +.inner-landscape .large-item.large-item-16, .items .large-item.large-item-16 { + cursor: pointer; + position: relative; + width: 145px; + height: 128px; +} + .inner-landscape .small-item, .items .small-item { cursor: pointer; position: relative; @@ -1481,11 +1488,16 @@ html.ios.has-selected-item, html.ios.has-selected-item body { grid-row-end: span 1; } -.inner-landscape .item-wrapper.wrapper-large, .items .item-wrapper.wrapper-large { +.inner-landscape .item-wrapper.wrapper-large-4, .items .item-wrapper.wrapper-large-4 { grid-column-end: span 2; grid-row-end: span 2; } +.inner-landscape .item-wrapper.wrapper-large-16, .items .item-wrapper.wrapper-large-16 { + grid-column-end: span 4; + grid-row-end: span 4; +} + @media (max-width: var(--sm-screen)) { diff --git a/src/utils/landscapeCalculations.js b/src/utils/landscapeCalculations.js index 491252c4..626b9348 100644 --- a/src/utils/landscapeCalculations.js +++ b/src/utils/landscapeCalculations.js @@ -17,19 +17,19 @@ const headerHeight = module.exports.headerHeight = 40; /* eslint-enable */ // Check if item is large -const isLargeFn = module.exports.isLargeFn = ({ relation, category, member, categoryAttrs }) => { - if (settings.global.flags?.only_large_items) { - return true; - } +const sizeFn = module.exports.sizeFn = ({ relation, category, member, categoryAttrs }) => { const relationInfo = fields.relation.valuesMap[relation] if (!relationInfo) { console.error(`No relation with name ${relation}`); } + if (relationInfo.x4) { + return 16; + } if (category === settings.global.membership) { const membershipInfo = settings.membership[member]; - return membershipInfo && !!membershipInfo.is_large; + return (membershipInfo && !!membershipInfo.is_large) ? 4 : 1; } - return !!categoryAttrs.isLarge || !!relationInfo.big_picture_order; + return (!!categoryAttrs.isLarge || !!relationInfo.big_picture_order) ? 4 : 1; } // Compute if items are large and/or visible. @@ -38,10 +38,9 @@ const isLargeFn = module.exports.isLargeFn = ({ relation, category, member, cate const computeItems = (subcategories, addInfoIcon = false) => { return subcategories.map(subcategory => { const filteredItems = subcategory.items.reduce((acc, { id }) => ({ ...acc, [id]: true }), {}) - const allItems = subcategory.allItems.map(item => ({ ...item, isLarge: isLargeFn(item), isVisible: filteredItems[item.id] })) - const itemsCount = allItems.reduce((count, item) => count + (item.isLarge ? 4 : 1), 0) + (addInfoIcon ? 1 : 0) - const largeItemsCount = allItems.reduce((count, item) => count + (item.isLarge ? 1 : 0), 0) - + const allItems = subcategory.allItems.map(item => ({ ...item, size: sizeFn(item), isVisible: filteredItems[item.id] })) + const itemsCount = allItems.reduce((count, item) => count + item.size, 0) + (addInfoIcon ? 1 : 0) + const largeItemsCount = allItems.reduce((count, item) => count + (item.size === 16 ? 4 : item.size === 4 ? 1 : 0), 0) return { ...subcategory, allItems, itemsCount, largeItemsCount } }) }