From 34b1834cd76282b70f9a342559a61ad712dd65f7 Mon Sep 17 00:00:00 2001 From: alexsparkes Date: Mon, 17 Oct 2022 21:41:00 +0100 Subject: [PATCH] feat: search for marketplace --- .../modals/main/marketplace/Items.jsx | 25 ++++++++++++++++--- .../main/settings/sections/QuickLinks.jsx | 24 +++--------------- .../widgets/quicklinks/QuickLinks.jsx | 11 +++++--- .../widgets/quicklinks/quicklinks.scss | 2 +- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/components/modals/main/marketplace/Items.jsx b/src/components/modals/main/marketplace/Items.jsx index e3a17d14..aeb31c0c 100644 --- a/src/components/modals/main/marketplace/Items.jsx +++ b/src/components/modals/main/marketplace/Items.jsx @@ -1,4 +1,5 @@ import variables from 'modules/variables'; +import TextField from '@mui/material/TextField'; import React, { useState } from 'react'; import { MdAutoFixHigh, @@ -16,6 +17,7 @@ export default function Items({ onCollection, }) { const [count, setCount] = useState(8); + const [filter, setFilter] = useState(''); const incrementCount = () => { if (count !== items.length && count <= items.length) { if (count + 8 > items.length) { @@ -30,6 +32,9 @@ export default function Items({ <> {(type === 'all' && !onCollection) || (type === 'collections' && !onCollection) ? ( <> + setFilter(event.target.value)}/> +
) : null} -
+
+ {items.filter(item => item.name.includes(filter) || filter === '') + .map(item =>
toggleFunction(item)} key={item.name}> + icon +
+ {item.display_name || item.name} + {item.author} +
+
)} +
+ {/*
{items.slice(0, count).map((item) => (
toggleFunction(item)} key={item.name}>
))} -
+
{count !== items.length && items.length >= 8 ? ( @@ -97,7 +116,7 @@ export default function Items({ {items.length} )} -
+
*/}
{type === 'all' && !onCollection ? (
diff --git a/src/components/modals/main/settings/sections/QuickLinks.jsx b/src/components/modals/main/settings/sections/QuickLinks.jsx index 680f2e61..495b08a7 100644 --- a/src/components/modals/main/settings/sections/QuickLinks.jsx +++ b/src/components/modals/main/settings/sections/QuickLinks.jsx @@ -84,10 +84,11 @@ export default class QuickLinks extends PureComponent { variables.stats.postEvent('feature', 'Quicklink add'); - this.toggleAdd(); + this.setState({ + showAddLink: false, + }); - // make sure image is correct size - this.setZoom(this.quicklinksContainer.current); + this.toggleAdd(); }; toggleAdd = () => { @@ -96,20 +97,6 @@ export default class QuickLinks extends PureComponent { }); }; - // widget zoom - setZoom(element) { - const zoom = localStorage.getItem('zoomQuicklinks') || 100; - if (localStorage.getItem('quicklinksText')) { - for (const link of element.getElementsByTagName('a')) { - link.style.fontSize = `${1.4 * Number(zoom / 100)}em`; - } - } else { - for (const img of element.getElementsByTagName('img')) { - img.style.height = `${1.4 * Number(zoom / 100)}em`; - } - } - } - componentDidMount() { EventBus.on('refresh', (data) => { if (data === 'quicklinks') { @@ -118,15 +105,12 @@ export default class QuickLinks extends PureComponent { } this.quicklinksContainer.current.style.display = 'block'; - this.setZoom(this.quicklinksContainer.current); this.setState({ items: JSON.parse(localStorage.getItem('quicklinks')), }); } }); - - this.setZoom(this.quicklinksContainer.current); } // allows you to add a link by pressing enter diff --git a/src/components/widgets/quicklinks/QuickLinks.jsx b/src/components/widgets/quicklinks/QuickLinks.jsx index 2e78448b..c61abb33 100644 --- a/src/components/widgets/quicklinks/QuickLinks.jsx +++ b/src/components/widgets/quicklinks/QuickLinks.jsx @@ -95,14 +95,17 @@ export default class QuickLinks extends PureComponent { // widget zoom setZoom(element) { const zoom = localStorage.getItem('zoomQuicklinks') || 100; - if (localStorage.getItem('quicklinksText')) { - for (const link of element.getElementsByTagName('a')) { - link.style.fontSize = `${1.4 * Number(zoom / 100)}em`; + if (localStorage.getItem('quickLinksStyle') !== "text") { + for (const link of element.getElementsByTagName('span')) { + link.style.fontSize = `${14 * Number(zoom / 100)}px`; } - } else { for (const img of element.getElementsByTagName('img')) { img.style.height = `${30 * Number(zoom / 100)}px`; } + } else { + for (const link of element.getElementsByTagName('span')) { + link.style.fontSize = `${14 * Number(zoom / 100)}px`; + } } } diff --git a/src/components/widgets/quicklinks/quicklinks.scss b/src/components/widgets/quicklinks/quicklinks.scss index d51802d2..767407c8 100644 --- a/src/components/widgets/quicklinks/quicklinks.scss +++ b/src/components/widgets/quicklinks/quicklinks.scss @@ -191,7 +191,7 @@ button.quicklinks { display: flex; flex-flow: column; align-items: center; - width: 100px; + min-width: 100px; background-image: linear-gradient(to left, rgb(0, 0, 0), transparent, rgb(0, 0, 0)), url('https://media.cntraveller.com/photos/615ee85…/16:9/w_2580,c_limit/Best%20Cities%20in%20the%20World%20-%20Grid.jpg'); transition: 0.8s;