-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from anc95/fix-shadowdom
chore: export instructions
- Loading branch information
Showing
14 changed files
with
171 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const download = (url: string, filename: string) => { | ||
const a = document.createElement('a') as HTMLAnchorElement | ||
a.href = url | ||
a.download = filename | ||
|
||
a.click() | ||
} |
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,18 @@ | ||
import { SVGProps } from 'react' | ||
|
||
export function MaterialSymbolsArrowUpward(props: SVGProps<SVGSVGElement>) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="1em" | ||
height="1em" | ||
viewBox="0 0 24 24" | ||
{...props} | ||
> | ||
<path | ||
fill="currentColor" | ||
d="M11 20V7.825l-5.6 5.6L4 12l8-8l8 8l-1.4 1.425l-5.6-5.6V20h-2Z" | ||
></path> | ||
</svg> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { download } from '@/common/file' | ||
import { getSetting } from '@/common/store/settings' | ||
import { Button, message, Popover } from 'antd' | ||
import i18next from 'i18next' | ||
import { useCallback } from 'react' | ||
|
||
export const Export: React.FC = () => { | ||
const handleExport = useCallback(async () => { | ||
const settings = await getSetting() | ||
const instructions = settings.customInstructions | ||
|
||
if (!instructions || !instructions?.length) { | ||
message.error(i18next.t('No data')) | ||
return | ||
} | ||
|
||
const blob = new Blob([JSON.stringify(instructions)]) | ||
const url = URL.createObjectURL(blob) | ||
|
||
download(url, 'writely-instructions.json') | ||
}, []) | ||
|
||
return ( | ||
<Popover content={i18next.t('Export instructions as JSON')}> | ||
<Button onClick={handleExport}>{i18next.t('Export')}</Button> | ||
</Popover> | ||
) | ||
} |
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,22 @@ | ||
import { Button, Popover, Upload } from 'antd' | ||
import i18next from 'i18next' | ||
import { useModalState } from '../modal-state' | ||
|
||
export const Import: React.FC = () => { | ||
const { setIsOpen } = useModalState() | ||
|
||
return ( | ||
<Popover content={i18next.t('Import instructions')}> | ||
<Upload | ||
disabled | ||
accept=".json" | ||
showUploadList={false} | ||
onChange={async ({ file }) => { | ||
console.log(await file.originFileObj.text()) | ||
}} | ||
> | ||
<Button onClick={() => setIsOpen(true)}>{i18next.t('Import')}</Button> | ||
</Upload> | ||
</Popover> | ||
) | ||
} |
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