-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Export Styles] Add download button to variable export (#28)
- Loading branch information
Showing
6 changed files
with
88 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#root, | ||
.appRoot, | ||
.saltFlexLayout { | ||
.viewRoot { | ||
height: 100%; | ||
} | ||
|
||
|
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,29 @@ | ||
export const downloadDataUri = (dataUri: string, fileName: string) => { | ||
const link = document.createElement("a"); | ||
link.href = dataUri; | ||
link.download = fileName; | ||
// some browser needs the anchor to be in the doc | ||
document.body.append(link); | ||
link.click(); | ||
link.remove(); | ||
// in case the Blob uses a log of memory | ||
setTimeout(() => { | ||
URL.revokeObjectURL(link.href); | ||
}, 7000); | ||
}; | ||
|
||
/** | ||
* This is much more efficient than manually converting a Blob or Uint8Array (e.g. `new Blob([uint8Array])`) to string / dataUri. | ||
*/ | ||
export const downloadBlob = (blob: Blob, fileName: string) => { | ||
const link = document.createElement("a"); | ||
// create a blobURI pointing to our Blob | ||
link.href = URL.createObjectURL(blob); | ||
link.download = fileName; | ||
// some browser needs the anchor to be in the doc | ||
document.body.append(link); | ||
link.click(); | ||
link.remove(); | ||
// in case the Blob uses a lot of memory | ||
setTimeout(() => URL.revokeObjectURL(link.href), 7000); | ||
}; |
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