mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +07:00
using lab icon on recent posts
This commit is contained in:
parent
0dfc334274
commit
dfcf0a541d
3 changed files with 49 additions and 13 deletions
|
@ -11,7 +11,6 @@ import { getPrettyDate } from '~/utils/dom';
|
||||||
|
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
node: Partial<INode>;
|
node: Partial<INode>;
|
||||||
has_new?: boolean;
|
has_new?: boolean;
|
||||||
|
@ -20,7 +19,12 @@ interface IProps {
|
||||||
|
|
||||||
const FlowRecentItem: FC<IProps> = ({ node, has_new, onClick }) => {
|
const FlowRecentItem: FC<IProps> = ({ node, has_new, onClick }) => {
|
||||||
return (
|
return (
|
||||||
<Anchor key={node.id} className={styles.item} href={URLS.NODE_URL(node.id)} onClick={onClick}>
|
<Anchor
|
||||||
|
key={node.id}
|
||||||
|
className={styles.item}
|
||||||
|
href={URLS.NODE_URL(node.id)}
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
className={classNames(styles.thumb, {
|
className={classNames(styles.thumb, {
|
||||||
[styles.new]: has_new,
|
[styles.new]: has_new,
|
||||||
|
@ -34,7 +38,6 @@ const FlowRecentItem: FC<IProps> = ({ node, has_new, onClick }) => {
|
||||||
<div className={styles.title}>{node.title || '...'}</div>
|
<div className={styles.title}>{node.title || '...'}</div>
|
||||||
|
|
||||||
<div className={styles.comment}>
|
<div className={styles.comment}>
|
||||||
{!node.is_promoted && <Icon icon="lab" size={14} />}
|
|
||||||
<span>{getPrettyDate(node.created_at)}</span>
|
<span>{getPrettyDate(node.created_at)}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import classNames from 'classnames';
|
||||||
|
|
||||||
import { ImageWithSSRLoad } from '~/components/common/ImageWithSSRLoad';
|
import { ImageWithSSRLoad } from '~/components/common/ImageWithSSRLoad';
|
||||||
import { Square } from '~/components/common/Square';
|
import { Square } from '~/components/common/Square';
|
||||||
|
import { Icon } from '~/components/input/Icon';
|
||||||
import { ImagePresets } from '~/constants/urls';
|
import { ImagePresets } from '~/constants/urls';
|
||||||
import { useColorGradientFromString } from '~/hooks/color/useColorGradientFromString';
|
import { useColorGradientFromString } from '~/hooks/color/useColorGradientFromString';
|
||||||
import { useGotoNode } from '~/hooks/node/useGotoNode';
|
import { useGotoNode } from '~/hooks/node/useGotoNode';
|
||||||
|
@ -26,7 +27,7 @@ const getTitleLetters = (title?: string): string => {
|
||||||
return words.length > 1
|
return words.length > 1
|
||||||
? words
|
? words
|
||||||
.slice(0, 2)
|
.slice(0, 2)
|
||||||
.map(word => word[0])
|
.map((word) => word[0])
|
||||||
.join('')
|
.join('')
|
||||||
.toUpperCase()
|
.toUpperCase()
|
||||||
: words[0].substr(0, 2).toUpperCase();
|
: words[0].substr(0, 2).toUpperCase();
|
||||||
|
@ -39,8 +40,11 @@ const NodeRelatedItem: FC<IProps> = memo(({ item }) => {
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const thumb = useMemo(
|
const thumb = useMemo(
|
||||||
() => (item.thumbnail ? getURL({ url: item.thumbnail }, ImagePresets.avatar) : ''),
|
() =>
|
||||||
[item]
|
item.thumbnail
|
||||||
|
? getURL({ url: item.thumbnail }, ImagePresets.avatar)
|
||||||
|
: '',
|
||||||
|
[item],
|
||||||
);
|
);
|
||||||
|
|
||||||
const background = useColorGradientFromString(!thumb ? item.title : '');
|
const background = useColorGradientFromString(!thumb ? item.title : '');
|
||||||
|
@ -63,13 +67,16 @@ const NodeRelatedItem: FC<IProps> = memo(({ item }) => {
|
||||||
return 'small';
|
return 'small';
|
||||||
}, [width]);
|
}, [width]);
|
||||||
|
|
||||||
const image = useMemo(() => getURL({ url: item.thumbnail }, ImagePresets.avatar), [
|
const image = useMemo(
|
||||||
item.thumbnail,
|
() => getURL({ url: item.thumbnail }, ImagePresets.avatar),
|
||||||
]);
|
[item.thumbnail],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(styles.item, styles[size], { [styles.is_loaded]: is_loaded })}
|
className={classNames(styles.item, styles[size], {
|
||||||
|
[styles.is_loaded]: is_loaded,
|
||||||
|
})}
|
||||||
key={item.id}
|
key={item.id}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
@ -78,8 +85,16 @@ const NodeRelatedItem: FC<IProps> = memo(({ item }) => {
|
||||||
<Square
|
<Square
|
||||||
image={getURLFromString(item.thumbnail, 'avatar')}
|
image={getURLFromString(item.thumbnail, 'avatar')}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
className={classNames(styles.thumb, { [styles.is_loaded]: is_loaded })}
|
className={classNames(styles.thumb, {
|
||||||
/>
|
[styles.is_loaded]: is_loaded,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{!item.is_promoted && (
|
||||||
|
<div className={styles.suffix}>
|
||||||
|
<Icon icon="lab" size={12} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Square>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!item.thumbnail && size === 'small' && (
|
{!item.thumbnail && size === 'small' && (
|
||||||
|
@ -94,7 +109,11 @@ const NodeRelatedItem: FC<IProps> = memo(({ item }) => {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<ImageWithSSRLoad src={image} alt="loader" onLoad={() => setIsLoaded(true)} />
|
<ImageWithSSRLoad
|
||||||
|
src={image}
|
||||||
|
alt="loader"
|
||||||
|
onLoad={() => setIsLoaded(true)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -64,3 +64,17 @@ div.thumb {
|
||||||
font: $font_12_bold;
|
font: $font_12_bold;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.suffix {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
background: var(--content_bg);
|
||||||
|
height: 16px;
|
||||||
|
width: 16px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: $cell_radius 0 $cell_radius 0;
|
||||||
|
fill: var(--gray_25);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue