From a9803afe22194c03b8e052374d5bb7e691be8bed Mon Sep 17 00:00:00 2001 From: Yuri Mikhin Date: Wed, 27 Sep 2023 11:00:16 +0300 Subject: [PATCH] More using of notEmpty helper. --- Readme.md | 5 +++++ src/api/services/figma/nodes/collect-node-parents.ts | 4 +++- src/api/services/payload/build-pair-selection-payload.ts | 2 +- src/ui/components/ContrastSample.tsx | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index 45aa998..59d70ae 100644 --- a/Readme.md +++ b/Readme.md @@ -24,16 +24,19 @@ Read more: [APCA in a Nutshell](https://git.apcacontrast.com/documentation/APCA_ ## Installation Clone the repository: + ```bash git clone https://github.com/evil-martians/figma-polychrom.git ``` Navigate to the project directory: + ```bash cd figma-polychrom ``` Install the dependencies: + ```bash pnpm install ``` @@ -41,6 +44,7 @@ pnpm install ## Development Run the development server: + ```bash pnpm dev ``` @@ -48,6 +52,7 @@ pnpm dev ## Build Build the plugin: + ```bash pnpm build ``` diff --git a/src/api/services/figma/nodes/collect-node-parents.ts b/src/api/services/figma/nodes/collect-node-parents.ts index 844c9d9..526aafd 100644 --- a/src/api/services/figma/nodes/collect-node-parents.ts +++ b/src/api/services/figma/nodes/collect-node-parents.ts @@ -1,8 +1,10 @@ +import { notEmpty } from '~utils/not-empty.ts'; + export const collectNodeParents = ( node: PageNode | SceneNode, parents: SceneNode[] = [] ): SceneNode[] => { - if (node.parent != null) { + if (notEmpty(node.parent)) { if (node.parent.type === 'PAGE' || node.parent.type === 'DOCUMENT') return parents; diff --git a/src/api/services/payload/build-pair-selection-payload.ts b/src/api/services/payload/build-pair-selection-payload.ts index 2b12914..9bda250 100644 --- a/src/api/services/payload/build-pair-selection-payload.ts +++ b/src/api/services/payload/build-pair-selection-payload.ts @@ -36,7 +36,7 @@ export const buildPairSelectionPayload = ( const nodePairPayload = buildColorsPair(fg.id, fgFill, bgFill); - return nodePairPayload != null + return notEmpty(nodePairPayload) ? { selectedNodePairs: [nodePairPayload], selectedNodes: selection } : buildEmptyPayload(); }; diff --git a/src/ui/components/ContrastSample.tsx b/src/ui/components/ContrastSample.tsx index d998680..95a90ce 100644 --- a/src/ui/components/ContrastSample.tsx +++ b/src/ui/components/ContrastSample.tsx @@ -1,3 +1,4 @@ +import { notEmpty } from '~utils/not-empty.ts'; import clsx from 'clsx'; import { type ReactElement } from 'react'; @@ -23,7 +24,7 @@ export const ContrastSample = ({ className={clsx( size === 'small' ? 'h-9 w-9 text-xxs' : 'h-13 w-13 text-base', 'flex items-center justify-center rounded-lg text-base', - borderColor != null ? 'border-0.5' : null + notEmpty(borderColor) ? 'border-0.5' : null )} style={{ backgroundColor: bgColor,