Skip to content

Commit

Permalink
notification for missing tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Jul 25, 2023
1 parent e4958c7 commit ca92573
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/ui/components/FileExportSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ export const FileExportSettings = () => {
"*"
);
// prepare token json
if (!tokens || !tokens.length) {
figmaUIApi.postMessage(
{
pluginMessage: {
command: commands.closePlugin,
payload: {
notification: "❌ No tokens to export!",
},
},
// @ts-ignore
},
"*"
);
return;
}

const tokensToExport = prepareExport(tokens, pluginSettings);

Expand Down
2 changes: 1 addition & 1 deletion src/utilities/prepareExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const createTypographyTokens = (tokens: internalTokenInterface[], settings) => {
}

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

0 comments on commit ca92573

Please sign in to comment.