mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
fix tag input on firefox, do refactor on it
This commit is contained in:
parent
a2a60aee8e
commit
29ed51b831
4 changed files with 34 additions and 31 deletions
|
@ -7,30 +7,30 @@ import { Icon } from '~/components/input/Icon';
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
|
className?: string;
|
||||||
size?: string;
|
size?: string;
|
||||||
color?: 'primary' | 'danger' | 'info' | 'black' | 'default';
|
color?: 'primary' | 'danger' | 'info' | 'black' | 'default';
|
||||||
deletable?: boolean;
|
deletable?: boolean;
|
||||||
hoverable?: boolean;
|
hoverable?: boolean;
|
||||||
editing?: boolean;
|
editing?: boolean;
|
||||||
hasInput?: boolean;
|
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
onDelete?: () => void;
|
onDelete?: () => void;
|
||||||
title?: string;
|
title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TagWrapper: FC<IProps> = ({
|
const TagWrapper: FC<IProps> = ({
|
||||||
|
className,
|
||||||
color = 'default',
|
color = 'default',
|
||||||
children,
|
children,
|
||||||
size,
|
size,
|
||||||
deletable,
|
deletable,
|
||||||
hoverable,
|
hoverable,
|
||||||
editing,
|
editing,
|
||||||
hasInput,
|
|
||||||
onClick,
|
onClick,
|
||||||
onDelete,
|
onDelete,
|
||||||
title = '',
|
title = '',
|
||||||
}) => {
|
}) => {
|
||||||
const canBeDeleted = deletable && !editing && !hasInput;
|
const canBeDeleted = deletable && !editing;
|
||||||
const onDeletePress = useCallback(
|
const onDeletePress = useCallback(
|
||||||
(event) => {
|
(event) => {
|
||||||
if (!onDelete) {
|
if (!onDelete) {
|
||||||
|
@ -53,9 +53,9 @@ const TagWrapper: FC<IProps> = ({
|
||||||
[styles.hoverable]: hoverable,
|
[styles.hoverable]: hoverable,
|
||||||
[styles.editing]: editing,
|
[styles.editing]: editing,
|
||||||
[styles.deletable]: canBeDeleted,
|
[styles.deletable]: canBeDeleted,
|
||||||
[styles.input]: hasInput,
|
|
||||||
[styles.clickable]: onClick,
|
[styles.clickable]: onClick,
|
||||||
},
|
},
|
||||||
|
className,
|
||||||
)}
|
)}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
|
|
|
@ -34,11 +34,6 @@ $big: 1.2;
|
||||||
background-color: $content_bg;
|
background-color: $content_bg;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.input {
|
|
||||||
color: transparent !important;
|
|
||||||
min-width: 100px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.clickable {
|
&.clickable {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
@ -76,26 +71,6 @@ $big: 1.2;
|
||||||
height: $tag_height * $big;
|
height: $tag_height * $big;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
input {
|
|
||||||
background: none;
|
|
||||||
border: none;
|
|
||||||
color: white;
|
|
||||||
outline: none;
|
|
||||||
display: inline-flex;
|
|
||||||
position: absolute;
|
|
||||||
font: inherit;
|
|
||||||
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
min-width: 100px;
|
|
||||||
padding-left: $tag_height;
|
|
||||||
padding-right: 5px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.hole {
|
.hole {
|
||||||
|
|
|
@ -130,10 +130,12 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
||||||
<div className={styles.wrap} ref={wrapper}>
|
<div className={styles.wrap} ref={wrapper}>
|
||||||
<TagWrapper
|
<TagWrapper
|
||||||
title={input || placeholder}
|
title={input || placeholder}
|
||||||
hasInput={true}
|
|
||||||
color={isAlbumTag ? 'primary' : undefined}
|
color={isAlbumTag ? 'primary' : undefined}
|
||||||
|
deletable={false}
|
||||||
|
className={styles.tag}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
|
className={styles.input}
|
||||||
type="text"
|
type="text"
|
||||||
value={input}
|
value={input}
|
||||||
size={1}
|
size={1}
|
||||||
|
|
|
@ -1,6 +1,32 @@
|
||||||
@import "src/styles/variables";
|
@import 'src/styles/variables';
|
||||||
|
|
||||||
.wrap {
|
.wrap {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 20;
|
z-index: 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
color: transparent !important;
|
||||||
|
min-width: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
outline: none;
|
||||||
|
display: inline-flex;
|
||||||
|
position: absolute;
|
||||||
|
font: inherit;
|
||||||
|
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
min-width: 100px;
|
||||||
|
padding-left: $tag_height;
|
||||||
|
padding-right: 5px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue