mirror of
https://github.com/pawelmalak/flame.git
synced 2024-12-24 10:42:40 +03:00
commit
c1b61f9cd9
@ -43,3 +43,10 @@
|
|||||||
margin-left: 2px;
|
margin-left: 2px;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.CustomIcon {
|
||||||
|
width: 90%;
|
||||||
|
height: 90%;
|
||||||
|
margin-top: 2px;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@ import classes from './BookmarkCard.module.css';
|
|||||||
|
|
||||||
import Icon from '../../UI/Icons/Icon/Icon';
|
import Icon from '../../UI/Icons/Icon/Icon';
|
||||||
import { iconParser, urlParser, searchConfig } from '../../../utility';
|
import { iconParser, urlParser, searchConfig } from '../../../utility';
|
||||||
|
import { Fragment } from 'react';
|
||||||
|
|
||||||
interface ComponentProps {
|
interface ComponentProps {
|
||||||
category: Category;
|
category: Category;
|
||||||
@ -16,45 +17,48 @@ const BookmarkCard = (props: ComponentProps): JSX.Element => {
|
|||||||
{props.category.bookmarks.map((bookmark: Bookmark) => {
|
{props.category.bookmarks.map((bookmark: Bookmark) => {
|
||||||
const redirectUrl = urlParser(bookmark.url)[1];
|
const redirectUrl = urlParser(bookmark.url)[1];
|
||||||
|
|
||||||
let iconEl: JSX.Element;
|
let iconEl: JSX.Element = <Fragment></Fragment>;
|
||||||
const { icon, name } = bookmark;
|
|
||||||
|
|
||||||
if (/.(jpeg|jpg|png)$/i.test(icon)) {
|
if (bookmark.icon) {
|
||||||
iconEl = (
|
const { icon, name } = bookmark;
|
||||||
<div className={classes.BookmarkIcon}>
|
|
||||||
<img
|
if (/.(jpeg|jpg|png)$/i.test(icon)) {
|
||||||
src={`/uploads/${icon}`}
|
iconEl = (
|
||||||
alt={`${name} icon`}
|
<div className={classes.BookmarkIcon}>
|
||||||
className={classes.CustomIcon}
|
<img
|
||||||
/>
|
src={`/uploads/${icon}`}
|
||||||
</div>
|
alt={`${name} icon`}
|
||||||
);
|
className={classes.CustomIcon}
|
||||||
} else if (/.(svg)$/i.test(icon)) {
|
/>
|
||||||
iconEl = (
|
</div>
|
||||||
<div className={classes.BookmarkIcon}>
|
);
|
||||||
<svg
|
} else if (/.(svg)$/i.test(icon)) {
|
||||||
data-src={`/uploads/${icon}`}
|
iconEl = (
|
||||||
fill='var(--color-primary)'
|
<div className={classes.BookmarkIcon}>
|
||||||
className={classes.BookmarkIconSvg}
|
<svg
|
||||||
></svg>
|
data-src={`/uploads/${icon}`}
|
||||||
</div>
|
fill="var(--color-primary)"
|
||||||
);
|
className={classes.BookmarkIconSvg}
|
||||||
} else {
|
></svg>
|
||||||
iconEl = (
|
</div>
|
||||||
<div className={classes.BookmarkIcon}>
|
);
|
||||||
<Icon icon={iconParser(icon)} />
|
} else {
|
||||||
</div>
|
iconEl = (
|
||||||
);
|
<div className={classes.BookmarkIcon}>
|
||||||
|
<Icon icon={iconParser(icon)} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
href={redirectUrl}
|
href={redirectUrl}
|
||||||
target={searchConfig('bookmarksSameTab', false) ? '' : '_blank'}
|
target={searchConfig('bookmarksSameTab', false) ? '' : '_blank'}
|
||||||
rel='noreferrer'
|
rel="noreferrer"
|
||||||
key={`bookmark-${bookmark.id}`}
|
key={`bookmark-${bookmark.id}`}
|
||||||
>
|
>
|
||||||
{icon && iconEl}
|
{bookmark.icon && iconEl}
|
||||||
{bookmark.name}
|
{bookmark.name}
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user