mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
proper cell links
This commit is contained in:
parent
603e78b5ba
commit
e38a046eb7
4 changed files with 13 additions and 7 deletions
|
@ -1,8 +1,10 @@
|
||||||
import React, { FC, useState, useCallback } from 'react';
|
import React, { FC, useState, useCallback } from 'react';
|
||||||
|
import { NavLink } from 'react-router-dom';
|
||||||
import { INode } from '~/redux/types';
|
import { INode } from '~/redux/types';
|
||||||
import * as styles from './styles.scss';
|
import * as styles from './styles.scss';
|
||||||
import { getImageSize } from '~/utils/dom';
|
import { getImageSize } from '~/utils/dom';
|
||||||
import classNames = require('classnames');
|
import classNames = require('classnames');
|
||||||
|
import { URLS } from '~/constants/urls';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
node: INode;
|
node: INode;
|
||||||
|
@ -14,7 +16,7 @@ interface IProps {
|
||||||
is_text?: boolean;
|
is_text?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Cell: FC<IProps> = ({ node: { title, brief }, is_text = false }) => {
|
const Cell: FC<IProps> = ({ node: { id, title, brief }, is_text = false }) => {
|
||||||
const [is_loaded, setIsLoaded] = useState(false);
|
const [is_loaded, setIsLoaded] = useState(false);
|
||||||
|
|
||||||
const onImageLoad = useCallback(() => {
|
const onImageLoad = useCallback(() => {
|
||||||
|
@ -22,7 +24,10 @@ const Cell: FC<IProps> = ({ node: { title, brief }, is_text = false }) => {
|
||||||
}, [setIsLoaded]);
|
}, [setIsLoaded]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(styles.cell, 'vert-1', 'hor-1', { is_text: false })}>
|
<NavLink
|
||||||
|
to={URLS.NODE_URL(id)}
|
||||||
|
className={classNames(styles.cell, 'vert-1', 'hor-1', { is_text: false })}
|
||||||
|
>
|
||||||
<div className={styles.face}>{title && <div className={styles.title}>{title}</div>}</div>
|
<div className={styles.face}>{title && <div className={styles.title}>{title}</div>}</div>
|
||||||
|
|
||||||
{brief && brief.thumbnail && (
|
{brief && brief.thumbnail && (
|
||||||
|
@ -36,7 +41,7 @@ const Cell: FC<IProps> = ({ node: { title, brief }, is_text = false }) => {
|
||||||
<img src={getImageSize(brief.thumbnail, 'medium')} onLoad={onImageLoad} alt="" />
|
<img src={getImageSize(brief.thumbnail, 'medium')} onLoad={onImageLoad} alt="" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</NavLink>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
border-radius: $cell_radius;
|
border-radius: $cell_radius;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
cursor: pointer;
|
||||||
|
color: white;
|
||||||
|
|
||||||
&:global(.is_hero) {
|
&:global(.is_hero) {
|
||||||
.title {
|
.title {
|
||||||
|
@ -56,14 +58,12 @@
|
||||||
|
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
max-height: 2em;
|
max-height: 2.6em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text_title {
|
.text_title {
|
||||||
|
|
|
@ -7,4 +7,5 @@ export const URLS = {
|
||||||
EDITOR: '/examples/edit',
|
EDITOR: '/examples/edit',
|
||||||
IMAGE: '/examples/image',
|
IMAGE: '/examples/image',
|
||||||
},
|
},
|
||||||
|
NODE_URL: (id: number) => `/cell/${id}`,
|
||||||
};
|
};
|
||||||
|
|
|
@ -84,7 +84,7 @@ export interface IBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface INode {
|
export interface INode {
|
||||||
id?: UUID;
|
id?: number;
|
||||||
user_id: UUID;
|
user_id: UUID;
|
||||||
|
|
||||||
title: string;
|
title: string;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue