-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6755502
commit 17fb395
Showing
18 changed files
with
395 additions
and
321 deletions.
There are no files selected for viewing
Binary file added
BIN
+119 KB
.yarn/cache/@create-figma-plugin-utilities-npm-3.0.2-c5288d79d0-2b8b42b092.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,32 +1,7 @@ | ||
export const ACTION = { | ||
GET_USER_INFO: "get-user-info", | ||
export const FRAME_NAME = "icona-frame"; | ||
|
||
GET_GITHUB_REPO_URL: "get-github-repo-url", | ||
GET_GITHUB_API_KEY: "get-github-api-key", | ||
GET_ICON_PREVIEW: "get-icon-preview", | ||
GET_DEPLOY_WITH_PNG: "get-deploy-with-png", | ||
|
||
SET_GITHUB_REPO_URL: "set-github-repo-url", | ||
SET_GITHUB_API_KEY: "set-github-api-key", | ||
SET_DEPLOY_WITH_PNG: "set-deploy-with-png", | ||
|
||
DEPLOY_ICON: "deploy-icon", | ||
DEPLOY_ICON_STATUS: "deploy-icon-status", | ||
DEPLOY_ICON_ERROR_MESSAGE: "deploy-icon-error-message", | ||
} as const; | ||
|
||
export const DATA = { | ||
export const KEY = { | ||
GITHUB_API_KEY: "github-api-key", | ||
GITHUB_REPO_URL: "github-repo-url", | ||
|
||
ICON_FRAME_ID: "icona-frame", | ||
|
||
DEPLOY_WITH_PNG: "deploy-with-png", | ||
} as const; | ||
|
||
export const STATUS = { | ||
IDLE: "idle", | ||
LOADING: "loading", | ||
SUCCESS: "success", | ||
ERROR: "error", | ||
} as const; | ||
}; |
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,72 @@ | ||
import { emit as e, on as o } from "@create-figma-plugin/utilities"; | ||
import type { IconaIconData } from "@icona/types"; | ||
|
||
interface UserInfoPayload { | ||
name: string; | ||
id: string; | ||
} | ||
|
||
interface GetGithubRepoUrlPayload { | ||
repoUrl?: string; | ||
} | ||
|
||
interface GetGithubApiKeyPayload { | ||
apiKey?: string; | ||
} | ||
|
||
interface GetDeployWithPngPayload { | ||
deployWithPng?: boolean; | ||
} | ||
|
||
interface GetIconPreviewPayload { | ||
icons: Record<string, IconaIconData>; | ||
} | ||
|
||
export type Events = { | ||
GET_USER_INFO: { | ||
name: "GET_USER_INFO"; | ||
payload: UserInfoPayload; | ||
handler: (props: UserInfoPayload) => void; | ||
}; | ||
GET_GITHUB_REPO_URL: { | ||
name: "GET_GITHUB_REPO_URL"; | ||
payload: GetGithubRepoUrlPayload; | ||
handler: (props: GetGithubRepoUrlPayload) => void; | ||
}; | ||
GET_GITHUB_API_KEY: { | ||
name: "GET_GITHUB_API_KEY"; | ||
payload: GetGithubApiKeyPayload; | ||
handler: (props: GetGithubApiKeyPayload) => void; | ||
}; | ||
GET_DEPLOY_WITH_PNG: { | ||
name: "GET_DEPLOY_WITH_PNG"; | ||
payload: GetDeployWithPngPayload; | ||
handler: (props: GetDeployWithPngPayload) => void; | ||
}; | ||
GET_ICON_PREVIEW: { | ||
name: "GET_ICON_PREVIEW"; | ||
payload: GetIconPreviewPayload; | ||
handler: (props: GetIconPreviewPayload) => void; | ||
}; | ||
DEPLOY_DONE: { | ||
name: "DEPLOY_DONE"; | ||
payload: null; | ||
handler: () => void; | ||
}; | ||
}; | ||
|
||
type EventName = keyof Events; | ||
|
||
export const emit = <T extends EventName>( | ||
name: T, | ||
payload: Events[T]["payload"], | ||
) => { | ||
return e(name, payload); | ||
}; | ||
|
||
export const on = <T extends keyof Events>( | ||
name: T, | ||
handler: Events[T]["handler"], | ||
) => { | ||
if (handler) return o(name, handler); | ||
}; |
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,64 @@ | ||
import { emit as e, on as o } from "@create-figma-plugin/utilities"; | ||
|
||
interface GithubData { | ||
owner: string; | ||
name: string; | ||
apiKey: string; | ||
} | ||
|
||
interface IconaMetaData { | ||
githubData: GithubData; | ||
options?: { | ||
withPng?: boolean; | ||
}; | ||
} | ||
|
||
interface SetPngOptionPayload { | ||
withPng: boolean; | ||
} | ||
|
||
interface SetGithubUrlPayload { | ||
url: string; | ||
} | ||
interface SetGithubApiKeyPayload { | ||
apiKey: string; | ||
} | ||
|
||
export type Events = { | ||
SET_GITHUB_URL: { | ||
name: "SET_GITHUB_URL"; | ||
payload: SetGithubUrlPayload; | ||
handler: (props: SetGithubUrlPayload) => void; | ||
}; | ||
SET_GITHUB_API_KEY: { | ||
name: "SET_GITHUB_API_KEY"; | ||
payload: SetGithubApiKeyPayload; | ||
handler: (props: SetGithubApiKeyPayload) => void; | ||
}; | ||
SET_PNG_OPTION: { | ||
name: "SET_PNG_OPTION"; | ||
payload: SetPngOptionPayload; | ||
handler: (props: SetPngOptionPayload) => void; | ||
}; | ||
DEPLOY_ICON: { | ||
name: "DEPLOY_ICON"; | ||
payload: IconaMetaData; | ||
handler: (props: IconaMetaData) => void; | ||
}; | ||
}; | ||
|
||
type EventName = keyof Events; | ||
|
||
export const emit = <T extends EventName>( | ||
name: T, | ||
payload: Events[T]["payload"], | ||
) => { | ||
return e(name, payload); | ||
}; | ||
|
||
export const on = <T extends keyof Events>( | ||
name: T, | ||
handler: Events[T]["handler"], | ||
) => { | ||
return o(name, handler); | ||
}; |
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
File renamed without changes.
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
Oops, something went wrong.