mue/src/components/modals/main/marketplace/Items.jsx

119 lines
4.3 KiB
React
Raw Normal View History

import variables from 'modules/variables';
import React, { memo } from 'react';
2022-11-06 11:59:59 +00:00
import { MdAutoFixHigh, MdOutlineArrowForward, MdOutlineOpenInNew } from 'react-icons/md';
2022-10-30 16:56:26 +00:00
function Items({
type,
items,
collection,
toggleFunction,
collectionFunction,
onCollection,
2022-10-21 21:33:30 +00:00
filter,
}) {
return (
<>
2022-11-06 11:59:59 +00:00
{(type === 'all' && !onCollection && (filter === null || filter === '')) ||
(type === 'collections' && !onCollection && (filter === null || filter === '')) ? (
<>
2022-08-03 09:42:04 +00:00
<div
className="collection"
2022-08-21 11:41:05 +00:00
style={
collection.news
? { backgroundColor: collection.background_colour }
: {
backgroundImage: `linear-gradient(to right, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7), transparent, rgba(0, 0, 0, 0.7), rgba(0 ,0, 0, 0.9)), url('${collection.img}')`,
2022-08-21 11:41:05 +00:00
}
}
2022-08-03 09:42:04 +00:00
>
<div className="content">
<span className="title">{collection.display_name}</span>
<span className="subtitle">{collection.description}</span>
</div>
2022-08-08 14:21:35 +00:00
{collection.news === true ? (
<a
className="collectionButton"
href={collection.news_link}
target="_blank"
rel="noopener noreferrer"
>
2022-08-29 20:07:52 +00:00
{variables.getMessage('modals.main.marketplace.learn_more')} <MdOutlineOpenInNew />
2022-08-08 14:21:35 +00:00
</a>
) : (
<button
className="collectionButton"
onClick={() => collectionFunction(collection.name)}
>
<MdOutlineArrowForward />
{variables.getMessage('modals.main.marketplace.explore_collection')}
2022-08-08 14:21:35 +00:00
</button>
)}
2022-08-03 09:42:04 +00:00
</div>
</>
) : null}
<div className="items">
2022-11-06 11:59:59 +00:00
{items
?.filter(
(item) =>
item.name.toLowerCase().includes(filter.toLowerCase()) ||
filter === '' ||
item.author.toLowerCase().includes(filter.toLowerCase()) ||
item.type.toLowerCase().includes(filter.toLowerCase()),
)
2023-01-21 12:10:40 +00:00
.map((item) => (
<div className="item" onClick={() => toggleFunction(item)} key={item.name}>
2023-01-21 12:10:40 +00:00
<img
className="item-back"
alt=""
draggable="false"
src={variables.constants.DDG_IMAGE_PROXY + item.icon_url}
aria-hidden="true"
/>
<img
className="item-icon"
alt="icon"
draggable="false"
src={variables.constants.DDG_IMAGE_PROXY + item.icon_url}
/>
<div className="card-details">
<span className="card-title">{item.display_name || item.name}</span>
<span className="card-subtitle">{variables.getMessage('modals.main.marketplace.by', { author: item.author })}</span>
{
type === 'all' && !onCollection
? <span className="card-type">
2023-01-21 12:10:40 +00:00
{variables.getMessage(`modals.main.addons.create.types.${item.type.split('_')[0] === "preset"
? "settings"
: item.type.split('_')[0] + 's'
}`)}
2023-01-21 12:10:40 +00:00
</span>
: null
}
</div>
</div>
2023-01-21 12:10:40 +00:00
))}
</div>
<div className="loader"></div>
{type === 'all' && !onCollection ? (
<div className="createYourOwn">
<MdAutoFixHigh />
<span className="title">{variables.getMessage('modals.main.marketplace.cant_find')}</span>
<span className="subtitle">
2022-12-23 11:11:28 +00:00
{variables.getMessage('modals.main.marketplace.knowledgebase_one') + ' '}
<a
className="link"
target="_blank"
href={variables.constants.KNOWLEDGEBASE}
rel="noreferrer"
>
{variables.getMessage('modals.main.marketplace.knowledgebase_two')}
</a>
2022-12-23 11:11:28 +00:00
{' ' + variables.getMessage('modals.main.marketplace.knowledgebase_three')}
</span>
</div>
) : null}
</>
);
}
2022-10-30 16:56:26 +00:00
2022-11-06 11:59:59 +00:00
export default memo(Items);