mirror of
https://github.com/plankanban/planka.git
synced 2025-08-09 15:35:29 +02:00
copy-button-added
This commit is contained in:
parent
9108dc5b3e
commit
f06a99e581
1 changed files with 11 additions and 7 deletions
|
@ -3,17 +3,14 @@ import PropTypes from 'prop-types';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import TextareaAutosize from 'react-textarea-autosize';
|
import TextareaAutosize from 'react-textarea-autosize';
|
||||||
import { Button, Form, TextArea } from 'semantic-ui-react';
|
import { Button, Form, TextArea, Icon } from 'semantic-ui-react';
|
||||||
import { useDidUpdate, useToggle } from '../../lib/hooks';
|
import { useDidUpdate, useToggle } from '../../lib/hooks';
|
||||||
|
|
||||||
import { useClosableForm, useForm } from '../../hooks';
|
import { useClosableForm, useForm } from '../../hooks';
|
||||||
|
|
||||||
import styles from './CardAdd.module.scss';
|
import styles from './CardAdd.module.scss';
|
||||||
|
|
||||||
const DEFAULT_DATA = {
|
const DEFAULT_DATA = {
|
||||||
name: '',
|
name: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
const CardAdd = React.memo(({ isOpened, onCreate, onClose }) => {
|
const CardAdd = React.memo(({ isOpened, onCreate, onClose }) => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const [data, handleFieldChange, setData] = useForm(DEFAULT_DATA);
|
const [data, handleFieldChange, setData] = useForm(DEFAULT_DATA);
|
||||||
|
@ -62,17 +59,17 @@ const CardAdd = React.memo(({ isOpened, onCreate, onClose }) => {
|
||||||
const handleSubmit = useCallback(() => {
|
const handleSubmit = useCallback(() => {
|
||||||
submit();
|
submit();
|
||||||
}, [submit]);
|
}, [submit]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isOpened) {
|
if (isOpened) {
|
||||||
nameField.current.ref.current.focus();
|
nameField.current.ref.current.focus();
|
||||||
}
|
}
|
||||||
}, [isOpened]);
|
}, [isOpened]);
|
||||||
|
|
||||||
useDidUpdate(() => {
|
useDidUpdate(() => {
|
||||||
nameField.current.ref.current.focus();
|
nameField.current.ref.current.focus();
|
||||||
}, [focusNameFieldState]);
|
}, [focusNameFieldState]);
|
||||||
|
const copyfun = () => {
|
||||||
|
navigator.clipboard.writeText(data.name);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
className={classNames(styles.wrapper, !isOpened && styles.wrapperClosed)}
|
className={classNames(styles.wrapper, !isOpened && styles.wrapperClosed)}
|
||||||
|
@ -94,6 +91,13 @@ const CardAdd = React.memo(({ isOpened, onCreate, onClose }) => {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.controls}>
|
<div className={styles.controls}>
|
||||||
|
<Button
|
||||||
|
onClick={copyfun}
|
||||||
|
onMouseOver={handleControlMouseOver}
|
||||||
|
onMouseOut={handleControlMouseOut}
|
||||||
|
>
|
||||||
|
<Icon fitted name="copy" size="small" />
|
||||||
|
</Button>
|
||||||
{/* eslint-disable-next-line jsx-a11y/mouse-events-have-key-events */}
|
{/* eslint-disable-next-line jsx-a11y/mouse-events-have-key-events */}
|
||||||
<Button
|
<Button
|
||||||
positive
|
positive
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue