mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
fixed delete button on tags
This commit is contained in:
parent
7bac04d2fe
commit
5c9cd8c020
7 changed files with 47 additions and 43 deletions
|
@ -1,14 +1,8 @@
|
||||||
import React, { FC, HTMLAttributes } from 'react';
|
import React, { FC, HTMLAttributes } from 'react';
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
type IProps = HTMLAttributes<HTMLDivElement> & {}
|
type IProps = HTMLAttributes<HTMLDivElement> & {};
|
||||||
|
|
||||||
const TagField: FC<IProps> = ({
|
const TagField: FC<IProps> = ({ children }) => <div className={styles.wrap}>{children}</div>;
|
||||||
children,
|
|
||||||
}) => (
|
|
||||||
<div className={styles.wrap}>
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
export { TagField };
|
export { TagField };
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
@import "src/styles/variables";
|
@import "src/styles/variables";
|
||||||
|
@import "src/styles/colors";
|
||||||
|
|
||||||
.wrap {
|
.wrap {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -10,3 +11,8 @@
|
||||||
margin: $gap / 2;
|
margin: $gap / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.edit {
|
||||||
|
opacity: 0.5;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.mini {
|
.mini {
|
||||||
height: 28px;
|
height: 26px;
|
||||||
border-radius: $radius / 2;
|
border-radius: $radius / 2;
|
||||||
|
|
||||||
&:global(.round) {
|
&:global(.round) {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
import { NodeTags } from '~/components/node/NodeTags';
|
import { NodeTags } from '~/components/node/NodeTags';
|
||||||
import { useTagContext } from '~/utils/context/TagsContextProvider';
|
import { useTagContext } from '~/utils/context/TagsContextProvider';
|
||||||
|
import { Group } from '~/components/containers/Group';
|
||||||
|
import { Button } from '~/components/input/Button';
|
||||||
|
|
||||||
interface IProps {}
|
interface IProps {}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,17 @@ const TagWrapper: FC<IProps> = ({
|
||||||
title = '',
|
title = '',
|
||||||
}) => {
|
}) => {
|
||||||
const deletable = is_deletable && !is_editing && !has_input;
|
const deletable = is_deletable && !is_editing && !has_input;
|
||||||
|
const onDeletePress = useCallback(
|
||||||
|
event => {
|
||||||
|
if (!onDelete) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.stopPropagation();
|
||||||
|
onDelete();
|
||||||
|
},
|
||||||
|
[onDelete]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@ -39,16 +50,18 @@ const TagWrapper: FC<IProps> = ({
|
||||||
input: has_input,
|
input: has_input,
|
||||||
clickable: onClick,
|
clickable: onClick,
|
||||||
})}
|
})}
|
||||||
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
<div className={styles.content} onClick={onClick}>
|
<div className={styles.hole} />
|
||||||
<div className={styles.hole} />
|
|
||||||
|
<div className={styles.text}>
|
||||||
<div className={styles.title}>{title}</div>
|
<div className={styles.title}>{title}</div>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{deletable && (
|
{deletable && (
|
||||||
<button type="button" className={styles.delete} onClick={onDelete}>
|
<button type="button" className={styles.delete} onClick={onDeletePress}>
|
||||||
<Icon icon="close" size={20} />
|
<Icon icon="close" size={12} />
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -12,10 +12,15 @@ $big: 1.2;
|
||||||
border-radius: ($tag_height / 2) 3px 3px ($tag_height / 2);
|
border-radius: ($tag_height / 2) 3px 3px ($tag_height / 2);
|
||||||
font: $font_14_semibold;
|
font: $font_14_semibold;
|
||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
padding: 0 8px 0 0;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 12;
|
z-index: 12;
|
||||||
|
|
||||||
|
display: inline-flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: stretch;
|
||||||
|
min-width: 0;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
z-index: 40;
|
z-index: 40;
|
||||||
}
|
}
|
||||||
|
@ -98,19 +103,6 @@ $big: 1.2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: stretch;
|
|
||||||
width: 100%;
|
|
||||||
transition: transform 250ms;
|
|
||||||
|
|
||||||
:hover:global(.deletable) > & {
|
|
||||||
transform: translate(-32px, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.hole {
|
.hole {
|
||||||
width: $tag_height;
|
width: $tag_height;
|
||||||
height: $tag_height;
|
height: $tag_height;
|
||||||
|
@ -137,27 +129,23 @@ $big: 1.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
button.delete {
|
button.delete {
|
||||||
@include inner_shadow;
|
box-shadow: inset transparentize(white, 0.9) 1px 0, transparentize(black, 0.7) -1px 0;
|
||||||
|
width: 24px;
|
||||||
width: 32px;
|
height: $tag_height;
|
||||||
height: 100%;
|
background: transparentize($content_bg, 0.75);
|
||||||
z-index: 24;
|
z-index: 24;
|
||||||
background: $red;
|
|
||||||
border: none;
|
border: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0 0 0 -5px;
|
border-radius: 0 3px 3px 0;
|
||||||
border-radius: 0;
|
flex: 0 0 24px;
|
||||||
position: absolute;
|
|
||||||
right: -32px;
|
|
||||||
top: 0;
|
|
||||||
transition: transform 250ms;
|
|
||||||
transform: translate(0, 0);
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
:hover > & {
|
|
||||||
transform: translate(-32px, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
padding-right: $gap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import { uniq } from 'ramda';
|
||||||
import { Tag } from '~/components/tags/Tag';
|
import { Tag } from '~/components/tags/Tag';
|
||||||
import { TagInput } from '~/components/tags/TagInput';
|
import { TagInput } from '~/components/tags/TagInput';
|
||||||
import { separateTags } from '~/utils/tag';
|
import { separateTags } from '~/utils/tag';
|
||||||
|
import { Button } from '~/components/input/Button';
|
||||||
|
|
||||||
type IProps = HTMLAttributes<HTMLDivElement> & {
|
type IProps = HTMLAttributes<HTMLDivElement> & {
|
||||||
tags: Partial<ITag>[];
|
tags: Partial<ITag>[];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue