mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
closing sidebar on click
This commit is contained in:
parent
237f978cbd
commit
2e0ad878a3
3 changed files with 9 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
|||
import React, { FC } from 'react';
|
||||
import React, { FC, MouseEventHandler } from 'react';
|
||||
import { INode } from '~/types';
|
||||
import styles from './styles.module.scss';
|
||||
import { URLS } from '~/constants/urls';
|
||||
|
@ -11,11 +11,12 @@ import { Anchor } from '~/components/common/Anchor';
|
|||
interface IProps {
|
||||
node: Partial<INode>;
|
||||
has_new?: boolean;
|
||||
onClick?: MouseEventHandler;
|
||||
}
|
||||
|
||||
const FlowRecentItem: FC<IProps> = ({ node, has_new }) => {
|
||||
const FlowRecentItem: FC<IProps> = ({ node, has_new, onClick }) => {
|
||||
return (
|
||||
<Anchor key={node.id} className={styles.item} href={URLS.NODE_URL(node.id)}>
|
||||
<Anchor key={node.id} className={styles.item} href={URLS.NODE_URL(node.id)} onClick={onClick}>
|
||||
<div
|
||||
className={classNames(styles.thumb, {
|
||||
[styles.new]: has_new,
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
import React, { FC } from 'react';
|
||||
import React, { FC, MouseEventHandler } from 'react';
|
||||
import { INode } from '~/types';
|
||||
import styles from './styles.module.scss';
|
||||
import { FlowRecentItem } from '~/components/flow/FlowRecentItem';
|
||||
|
||||
interface IProps {
|
||||
nodes: INode[];
|
||||
onClick?: MouseEventHandler;
|
||||
}
|
||||
|
||||
const TagSidebarList: FC<IProps> = ({ nodes }) => (
|
||||
const TagSidebarList: FC<IProps> = ({ nodes, onClick }) => (
|
||||
<div className={styles.list}>
|
||||
{nodes.map(node => (
|
||||
<FlowRecentItem node={node} key={node.id} />
|
||||
<FlowRecentItem node={node} key={node.id} onClick={onClick} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -53,7 +53,7 @@ const TagSidebar: VFC<TagSidebarProps> = ({ tag, onRequestClose }) => {
|
|||
</div>
|
||||
) : (
|
||||
<InfiniteScroll hasMore={hasMore} loadMore={loadMore} className={styles.list}>
|
||||
<TagSidebarList nodes={nodes} />
|
||||
<TagSidebarList nodes={nodes} onClick={onRequestClose} />
|
||||
</InfiniteScroll>
|
||||
)}
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue