-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- option to change the file name. - option to compress before exporting the file. - option to force include the data,info and meta object. - option to format the exported data to be easy to read.
- Loading branch information
1 parent
6b319ad
commit 60e6430
Showing
7 changed files
with
180 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/** @jsxImportSource @emotion/react */ | ||
import { css } from '@emotion/react'; | ||
import { useCallback, useRef } from 'react'; | ||
|
||
import CloseButton from '../elements/CloseButton'; | ||
import FormikCheckBox from '../elements/formik/FormikCheckBox'; | ||
import FormikForm from '../elements/formik/FormikForm'; | ||
import FormikInput from '../elements/formik/FormikInput'; | ||
|
||
import { ModalStyles } from './ModalStyle'; | ||
|
||
const styles = css` | ||
.row { | ||
align-items: center; | ||
} | ||
.inner-content { | ||
flex: 1; | ||
} | ||
.custom-label { | ||
width: 80px; | ||
} | ||
.name { | ||
width: 100% !important; | ||
text-align: left !important; | ||
} | ||
`; | ||
|
||
const INITIAL_VALUE = { | ||
name: '', | ||
compressed: false, | ||
pretty: false, | ||
includeData: false, | ||
}; | ||
|
||
function SaveAsModal({ onClose, onSave, name }) { | ||
const refForm = useRef(); | ||
|
||
const handleSave = useCallback(() => { | ||
refForm.current.submitForm(); | ||
}, []); | ||
|
||
const submitHandler = useCallback( | ||
(values) => { | ||
onSave(values); | ||
onClose(); | ||
}, | ||
[onClose, onSave], | ||
); | ||
|
||
return ( | ||
<div css={[ModalStyles, styles]}> | ||
<div className="header handle"> | ||
<span>Save as ... </span> | ||
<CloseButton onClick={onClose} className="close-bt" /> | ||
</div> | ||
<div className="inner-content"> | ||
<FormikForm | ||
ref={refForm} | ||
initialValues={{ ...INITIAL_VALUE, name }} | ||
onSubmit={submitHandler} | ||
> | ||
<div className="row margin-10"> | ||
<span className="custom-label">Name</span> | ||
<FormikInput | ||
label="" | ||
name="name" | ||
className="name" | ||
style={{ | ||
container: { width: '100%' }, | ||
}} | ||
/> | ||
</div> | ||
|
||
<div className="row margin-10"> | ||
<span className="custom-label">Compressed</span> | ||
<FormikCheckBox name="compressed" /> | ||
</div> | ||
<div className="row margin-10"> | ||
<span className="custom-label">Pretty Format</span> | ||
<FormikCheckBox name="pretty" /> | ||
</div> | ||
<div className="row margin-10"> | ||
<span className="custom-label">Include Data</span> | ||
<FormikCheckBox name="includeData" /> | ||
</div> | ||
</FormikForm> | ||
</div> | ||
<div className="footer-container"> | ||
<button type="button" onClick={handleSave} className="save-button"> | ||
Save | ||
</button> | ||
<button type="button" onClick={onClose} className="save-button"> | ||
Close | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default SaveAsModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters