Skip to content

Commit ca92573

Browse files
notification for missing tokens
1 parent e4958c7 commit ca92573

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/ui/components/FileExportSettings.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,21 @@ export const FileExportSettings = () => {
5555
"*"
5656
);
5757
// prepare token json
58+
if (!tokens || !tokens.length) {
59+
figmaUIApi.postMessage(
60+
{
61+
pluginMessage: {
62+
command: commands.closePlugin,
63+
payload: {
64+
notification: "❌ No tokens to export!",
65+
},
66+
},
67+
// @ts-ignore
68+
},
69+
"*"
70+
);
71+
return;
72+
}
5873

5974
const tokensToExport = prepareExport(tokens, pluginSettings);
6075

src/utilities/prepareExport.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const createTypographyTokens = (tokens: internalTokenInterface[], settings) => {
3232
}
3333

3434
export const prepareExport = (tokens: string, settings: Settings) => {
35-
if (tokens.length === 0) tokens = '{}'
35+
if (tokens.length === 0) tokens = '[{}]'
3636
// parse json string
3737
let tokenArray: internalTokenInterface[] = JSON.parse(tokens)
3838
// duplicate font if typography is true && format = standard

0 commit comments

Comments
 (0)