mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-11-13 03:22:37 +05:30
feat: import from file button 삭제
This commit is contained in:
parent
9760bdf159
commit
51f8cdaba8
3 changed files with 19 additions and 6 deletions
|
|
@ -9,15 +9,18 @@ export default function InputFooter({
|
||||||
handleCopy,
|
handleCopy,
|
||||||
handleClear
|
handleClear
|
||||||
}: {
|
}: {
|
||||||
handleImport: () => void;
|
handleImport?: () => void;
|
||||||
handleCopy?: () => void;
|
handleCopy?: () => void;
|
||||||
handleClear?: () => void;
|
handleClear?: () => void;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Stack mt={1} direction={'row'} spacing={2}>
|
<Stack mt={1} direction={'row'} spacing={2}>
|
||||||
<Button onClick={handleImport} startIcon={<PublishIcon />}>
|
{handleImport && (
|
||||||
Import from file
|
<Button onClick={handleImport} startIcon={<PublishIcon />}>
|
||||||
</Button>
|
Import from file
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
{handleCopy && (
|
{handleCopy && (
|
||||||
<Button onClick={handleCopy} startIcon={<ContentPasteIcon />}>
|
<Button onClick={handleCopy} startIcon={<ContentPasteIcon />}>
|
||||||
Copy to clipboard
|
Copy to clipboard
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,13 @@ import InputFooter from './InputFooter';
|
||||||
export default function ToolTextInput({
|
export default function ToolTextInput({
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
title = 'Input text'
|
title = 'Input text',
|
||||||
|
hideFileImport = false
|
||||||
}: {
|
}: {
|
||||||
title?: string;
|
title?: string;
|
||||||
value: string;
|
value: string;
|
||||||
onChange: (value: string) => void;
|
onChange: (value: string) => void;
|
||||||
|
hideFileImport?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { showSnackBar } = useContext(CustomSnackBarContext);
|
const { showSnackBar } = useContext(CustomSnackBarContext);
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
@ -24,6 +26,7 @@ export default function ToolTextInput({
|
||||||
showSnackBar('Failed to copy: ' + err, 'error');
|
showSnackBar('Failed to copy: ' + err, 'error');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const file = event.target.files?.[0];
|
const file = event.target.files?.[0];
|
||||||
if (file) {
|
if (file) {
|
||||||
|
|
@ -41,6 +44,7 @@ export default function ToolTextInput({
|
||||||
const handleImportClick = () => {
|
const handleImportClick = () => {
|
||||||
fileInputRef.current?.click();
|
fileInputRef.current?.click();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<InputHeader title={title} />
|
<InputHeader title={title} />
|
||||||
|
|
@ -59,7 +63,12 @@ export default function ToolTextInput({
|
||||||
'data-testid': 'text-input'
|
'data-testid': 'text-input'
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<InputFooter handleCopy={handleCopy} handleImport={handleImportClick} />
|
|
||||||
|
<InputFooter
|
||||||
|
handleCopy={handleCopy}
|
||||||
|
handleImport={hideFileImport ? undefined : handleImportClick}
|
||||||
|
/>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
type="file"
|
type="file"
|
||||||
accept="*"
|
accept="*"
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ export default function QRGeneratorTool({
|
||||||
title="QR 코드에 들어갈 텍스트"
|
title="QR 코드에 들어갈 텍스트"
|
||||||
value={input}
|
value={input}
|
||||||
onChange={setInput}
|
onChange={setInput}
|
||||||
|
hideFileImport
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
resultComponent={
|
resultComponent={
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue