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 { NavLink } from 'react-router-dom';
|
||||
import { INode } from '~/redux/types';
|
||||
import * as styles from './styles.scss';
|
||||
import { getImageSize } from '~/utils/dom';
|
||||
import classNames = require('classnames');
|
||||
import { URLS } from '~/constants/urls';
|
||||
|
||||
interface IProps {
|
||||
node: INode;
|
||||
|
@ -14,7 +16,7 @@ interface IProps {
|
|||
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 onImageLoad = useCallback(() => {
|
||||
|
@ -22,7 +24,10 @@ const Cell: FC<IProps> = ({ node: { title, brief }, is_text = false }) => {
|
|||
}, [setIsLoaded]);
|
||||
|
||||
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>
|
||||
|
||||
{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="" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</NavLink>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
border-radius: $cell_radius;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
|
||||
&:global(.is_hero) {
|
||||
.title {
|
||||
|
@ -56,14 +58,12 @@
|
|||
|
||||
text-transform: uppercase;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.title {
|
||||
max-height: 2em;
|
||||
max-height: 2.6em;
|
||||
}
|
||||
|
||||
.text_title {
|
||||
|
|
|
@ -7,4 +7,5 @@ export const URLS = {
|
|||
EDITOR: '/examples/edit',
|
||||
IMAGE: '/examples/image',
|
||||
},
|
||||
NODE_URL: (id: number) => `/cell/${id}`,
|
||||
};
|
||||
|
|
|
@ -84,7 +84,7 @@ export interface IBlock {
|
|||
}
|
||||
|
||||
export interface INode {
|
||||
id?: UUID;
|
||||
id?: number;
|
||||
user_id: UUID;
|
||||
|
||||
title: string;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue