Skip to content

Commit

Permalink
feat: remove Docker, enhance DX
Browse files Browse the repository at this point in the history
  • Loading branch information
Prorupak committed Aug 28, 2024
1 parent 2f7d01d commit b71b573
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 85 deletions.
30 changes: 0 additions & 30 deletions docker-compose.yaml

This file was deleted.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"scripts": {
"start-plugin": "cd plugin && pnpm watch",
"start-server": "cd server && pnpm dev",
"start-server-prod": "cd server && pnpm prod",
"build-plugin": "cd plugin && pnpm build",
"build-server": "cd server && pnpm build",
"lint-plugin": "cd plugin && pnpm lint",
"lint-server": "cd server && pnpm lint",
"start": "concurrently \"pnpm start-server\" \"pnpm start-plugin\"",
"lint": "concurrently \"pnpm lint-server\" \"pnpm lint-plugin\"",
"build": "concurrently \"pnpm build-server\" \"pnpm build-plugin\"",
Expand Down
1 change: 1 addition & 0 deletions plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"lint:format": "prettier --write \"src/**/*.{ts,tsx}\""
},
"dependencies": {
"@figma/plugin-typings": "^1.99.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"ts-loader": "^6.0.4",
Expand Down
8 changes: 8 additions & 0 deletions plugin/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions plugin/src/code.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import "figma-plugin-types";

const width = 400;
const height = 500;
let timer: number | ReturnType<typeof setTimeout>;
Expand Down Expand Up @@ -68,7 +66,7 @@ figma.ui.onmessage = async (msg: MessageData) => {

case "show":
if (isShowMessage(msg)) {
const node = figma.getNodeById(msg.show);
const node = await figma.getNodeByIdAsync(msg.show);
if (node?.type !== "DOCUMENT" && node?.type !== "PAGE") {
figma.currentPage.selection = [node as SceneNode];
figma.viewport.scrollAndZoomIntoView([node as SceneNode]);
Expand All @@ -86,7 +84,7 @@ function* walkTree(node: BaseNode): Generator<BaseNode, void, unknown> {
yield node;
if ("children" in node) {
for (const child of node.children) {
yield * walkTree(child);
yield* walkTree(child);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/hooks/useDebounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function useDebounceCallback<T extends (...args: any[]) => void>(
callback: T,
delay: number
) {
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);

const debouncedCallback = useCallback(
(...args: Parameters<T>) => {
Expand Down
34 changes: 28 additions & 6 deletions plugin/src/ui/components/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ interface LoginPageProps {
}

const LoginPage: React.FC<LoginPageProps> = ({ loading, startOAuthFlow }) => {
const cancelLogin = () => {
parent.postMessage({ pluginMessage: { type: "quit" } }, "*");
};
return (
<div
className="login-container"
Expand All @@ -21,13 +24,32 @@ const LoginPage: React.FC<LoginPageProps> = ({ loading, startOAuthFlow }) => {
<p className="login-subtitle">
Please login to start using plugin again.
</p>
<button
className={`login-button ${loading ? "loading" : ""}`}
onClick={startOAuthFlow}
disabled={loading}
<div
style={{ display: "flex", flexDirection: "column", gap: "0.75rem" }}
>
{loading ? <span className="spinner"></span> : "Log in with Figma"}
</button>
<button
className={`login-button ${loading ? "loading" : ""}`}
onClick={startOAuthFlow}
disabled={loading}
>
{loading ? <span className="spinner"></span> : "Log in with Figma"}
</button>
{loading && (
<button
type="button"
style={{
cursor: "pointer",
backgroundColor: "transparent",
border: "none",
fontSize: "1rem",
color: "var(--purple-color)",
}}
onClick={cancelLogin}
>
Cancel
</button>
)}
</div>
</div>
</div>
);
Expand Down
6 changes: 3 additions & 3 deletions plugin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"lib": ["dom", "es2017"],
"module": "commonjs",
"target": "ES2015",
"jsx": "react"
"jsx": "react",
"typeRoots": ["./node_modules/@types", "./node_modules/@figma"]
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
"include": ["src/**/*.ts"]
}
41 changes: 0 additions & 41 deletions server/Dockerfile

This file was deleted.

0 comments on commit b71b573

Please sign in to comment.