Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
},
extends: [
'standard-with-typescript',
'plugin:react/recommended',
'plugin:solid/typescript',
'prettier',
'plugin:perfectionist/recommended-alphabetical',
'plugin:tailwindcss/recommended',
Expand All @@ -27,12 +27,14 @@ module.exports = {
ecmaVersion: 'latest',
sourceType: 'module',
project: './tsconfig.json',
jsxPragma: "Solid"
},
plugins: ['react', 'prettier', 'jsx-a11y', 'boundaries'],
plugins: ['solid', 'prettier', 'jsx-a11y', 'boundaries'],
rules: {
'import/no-default-export': 'error',
'func-style': ['error', 'expression'],
'react/react-in-jsx-scope': 'off',
'solid/react-in-jsx-scope': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'boundaries/element-types': [
2,
{
Expand Down Expand Up @@ -67,7 +69,7 @@ module.exports = {
['~test-utils', './src/test-utils'],
],
},
react: {
solid: {
version: 'detect',
},
'boundaries/elements': [
Expand Down
12 changes: 12 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://shadcn-solid.com/schema.json",
"tailwind": {
"config": "tailwind.config.js",
"css": {
"path": "src/app.css",
"variable": false
},
"color": "slate",
"prefix": ""
}
}
36 changes: 14 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,27 @@
"lint:size": "size-limit"
},
"dependencies": {
"@figma/plugin-typings": "^1.79.0",
"@floating-ui/react": "^0.25.2",
"@nanostores/react": "^0.7.1",
"@testing-library/react": "^14.0.0",
"@figma/plugin-typings": "^1.116.0",
"@kobalte/core": "^0.13.11",
"@nanostores/solid": "^1.0.0",
"@types/apca-w3": "^0.1.0",
"@types/culori": "^2.0.0",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@vitejs/plugin-react": "^4.0.1",
"@vitest/coverage-v8": "^0.34.1",
"apca-w3": "^0.1.9",
"apcach": "^0.6.0",
"autoprefixer": "^10.4.14",
"bigint-conversion": "^2.4.2",
"clsx": "^2.0.0",
"copy-to-clipboard": "^3.3.3",
"culori": "^3.2.0",
"eslint-plugin-boundaries": "^3.4.0",
"nanoid": "^4.0.2",
"nanoid": "5.0.9",
"nanostores": "^0.9.3",
"postcss": "^8.4.24",
"postcss-loader": "^7.3.3",
"postcss-preset-env": "^9.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-use-clipboard": "^1.0.9",
"solid-js": "^1.9.7",
"tailwindcss": "^3.3.2",
"typescript": "^5.0.2",
"uint8-to-hex": "^2.0.0",
"vite": "^4.4.0",
"vite-plugin-singlefile": "^0.13.5",
"vite-plugin-svgr": "^3.2.0",
"vitest": "^0.34.1"
"uint8-to-hex": "^2.0.0"
},
"devDependencies": {
"@size-limit/preset-small-lib": "^11.2.0",
Expand All @@ -60,20 +49,23 @@
"eslint-config-prettier": "^8.8.0",
"eslint-config-standard-with-typescript": "^36.0.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-boundaries": "^3.4.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-n": "^15.0.0",
"eslint-plugin-perfectionist": "^1.4.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.1",
"eslint-plugin-solid": "^0.14.5",
"eslint-plugin-tailwindcss": "^3.13.0",
"jsdom": "^22.1.0",
"prettier": "^3.0.2",
"size-limit": "^11.2.0",
"terser": "^5.19.0"
"vite": "^4.4.0",
"vite-plugin-singlefile": "^0.13.5",
"vite-plugin-solid": "^2.11.8",
"vite-plugin-solid-svg": "^0.8.1",
"vitest": "^0.34.1"
},
"size-limit": [
{
Expand Down
6 changes: 6 additions & 0 deletions src/ui/assets/icons/help-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions src/ui/assets/icons/lurkers-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/ui/assets/icons/settings-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 17 additions & 20 deletions src/ui/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,63 +1,60 @@
import { useStore } from '@nanostores/react';
import { useStore } from '@nanostores/solid';
import { MessageTypes } from '~types/messages.ts';
import { AppContent } from '~ui/components/AppContent.tsx';
import { HelpLink } from '~ui/components/HelpLink.tsx';
import { LurkersLink } from '~ui/components/LurkersLink.tsx';
import { SettingsButton } from '~ui/components/SettingsButton.tsx';
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from '~ui/components/Tooltip.tsx';
import React, { useEffect } from 'react';
import { Tooltip, TooltipContent, TooltipTrigger } from '~ui/components/Tooltip.tsx';
import { type JSX, onMount } from 'solid-js';

import { $isP3 } from '../stores/selected-nodes';

export const App: React.FC = () => {
export const App = (): JSX.Element => {
const isP3 = useStore($isP3);

useEffect(() => {
onMount(() => {
parent.postMessage(
{
pluginMessage: {
type: MessageTypes.UiReady,
},
},
'*'
'*',
);
}, []);
});

return (
<div className="relative flex min-h-full w-full select-none flex-col items-center p-1 pb-0 font-martianMono">
<div class="relative flex min-h-full w-full select-none flex-col items-center p-1 pb-0 font-martianMono">
<AppContent />

<div className="mb-2 mt-auto flex w-full items-end px-1">
<div class="mb-2 mt-auto flex w-full items-end px-1">
<HelpLink />

<div className="ml-auto flex items-center">
{isP3 && (
<div class="ml-auto flex items-center">
{isP3() && (
<Tooltip>
<TooltipTrigger>
<div
style={{
mixBlendMode: 'difference',
'mix-blend-mode': 'difference',
}}
className="flex items-center"
class="flex items-center"
>
<p className="mr-3 rounded border-0.5 border-secondary-75 p-1 text-xxxs font-medium leading-[8px] text-secondary-75">
<p
class="mr-3 rounded border-0.5 border-secondary-75 p-1 text-xxxs font-medium leading-[8px] text-secondary-75">
P3
</p>
</div>
</TooltipTrigger>
<TooltipContent>File color profile</TooltipContent>
<TooltipContent><span>File color profile</span></TooltipContent>
</Tooltip>
)}

<SettingsButton />
</div>
</div>

<div className="absolute bottom-0 left-1/2 -translate-x-1/2">
<div class="absolute bottom-0 left-1/2 -translate-x-1/2">
<LurkersLink />
</div>
</div>
Expand Down
82 changes: 43 additions & 39 deletions src/ui/components/AppContent.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
import { useStore } from '@nanostores/react';
import { EmptySelectionMessage } from '~ui/components/EmptySelectionMessage.tsx';
import { InvalidBackgroundSelectionMessage } from '~ui/components/InvalidBackgroundSelectionMessage.tsx';
import { Selection } from '~ui/components/Selection.tsx';
import { SelectionsList } from '~ui/components/SelectionsList.tsx';
import { UnprocessedBlendModesSelectionMessage } from '~ui/components/UnprocessedBlendModesSelectionMessage.tsx';
import { useStore } from '@nanostores/solid';
import { EmptySelectionMessage } from '~ui/components/infoMessages/EmptySelectionMessage';
import { InvalidBackgroundSelectionMessage } from '~ui/components/infoMessages/InvalidBackgroundSelectionMessage';
import {
UnprocessedBlendModesSelectionMessage,
} from '~ui/components/infoMessages/UnprocessedBlendModesSelectionMessage';
import { Selection } from '~ui/components/Selection';
import { SelectionsList } from '~ui/components/SelectionsList';
import {
$contrastConclusion,
$isEmptySelection,
$isInvalidBackground,
$isMultiSelection,
$isMultiSelection, $isSingleSelection,
$isUnprocessedBlendModes,
} from '~ui/stores/selected-nodes.ts';
} from '~ui/stores/selected-nodes';
import { isEmpty } from '~utils/not-empty.ts';
import { type ReactElement } from 'react';
import { createMemo, type JSX, Match, Show, Switch } from 'solid-js';

export const AppContent = (): ReactElement => {
export const AppContent = (): JSX.Element => {
const isInvalidBackground = useStore($isInvalidBackground);
const isEmptySelection = useStore($isEmptySelection);
const isMultiSelection = useStore($isMultiSelection);
const isUnprocessedBlendModes = useStore($isUnprocessedBlendModes);
const isMultiSelection = useStore($isMultiSelection);
const isSingleSelection = useStore($isSingleSelection);
const isEmptySelection = useStore($isEmptySelection);
const contrastConclusion = useStore($contrastConclusion);

if (isInvalidBackground) {
return <InvalidBackgroundSelectionMessage />;
}

if (isUnprocessedBlendModes) {
return <UnprocessedBlendModesSelectionMessage />;
}

if (isEmptySelection) {
return <EmptySelectionMessage />;
}

if (isEmpty(contrastConclusion)) {
return <EmptySelectionMessage />;
}

if (isMultiSelection) {
return <SelectionsList contrastConclusion={contrastConclusion} />;
} else {
const pair = contrastConclusion[0];

if (isEmpty(pair)) {
return <EmptySelectionMessage />;
}

return <Selection id={pair.id} isLast size="large" userSelection={pair} />;
}
const pair = createMemo(() => contrastConclusion()[0]);

return (
<Switch>
<Match when={isInvalidBackground()}>
<InvalidBackgroundSelectionMessage />
</Match>
<Match when={isUnprocessedBlendModes()}>
<UnprocessedBlendModesSelectionMessage />
</Match>
<Match when={isMultiSelection()}>
<SelectionsList contrastConclusion={contrastConclusion()} />
</Match>
<Match when={isSingleSelection()}>
<Show fallback={<EmptySelectionMessage />} when={!isEmpty(pair())}>
<Selection
id={pair()!.id}
isLast
size="large"
userSelection={pair()!}
/>
</Show>
</Match>
<Match when={isEmptySelection()}>
<EmptySelectionMessage />
</Match>
</Switch>
);
};
Loading
Loading