From 6f00e7d13820205ffd7ea3a7f0c4222edfeff35c Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Tue, 18 Jul 2023 12:07:46 +0800 Subject: [PATCH] Fix Lynx rendering Properly specify input labels layout on Lynx. --- TODO.md | 9 +- categories/choice/react/package.json | 14 +- categories/choice/react/scripts/build.ts | 22 --- .../react/src/components/ComboBox/index.tsx | 53 +++--- .../DropdownSelect/DropdownSelect.css | 17 -- .../src/components/DropdownSelect/index.tsx | 78 +++++--- .../src/components/MenuSelect/MenuSelect.css | 17 -- .../react/src/components/MenuSelect/index.tsx | 78 +++++--- .../components/RadioButton/RadioButton.css | 7 - .../src/components/RadioButton/index.tsx | 16 +- .../components/RadioTickBox/RadioTickBox.css | 7 - .../src/components/RadioTickBox/index.tsx | 16 +- categories/color/react/.eslintrc | 1 + categories/color/react/package.json | 11 +- categories/color/react/scripts/build.ts | 19 -- .../components/ColorPicker/ColorPicker.css | 7 - .../src/components/ColorPicker/index.tsx | 14 ++ .../react/src/components/EmailInput/index.tsx | 53 +++--- .../src/components/PatternTextInput/index.tsx | 53 +++--- .../src/components/PhoneNumberInput/index.tsx | 53 +++--- .../react/src/components/UrlInput/index.tsx | 53 +++--- .../src/components/MaskedTextInput/index.tsx | 53 +++--- .../components/MultilineTextInput/index.tsx | 53 +++--- .../react/src/components/TextInput/index.tsx | 53 +++--- categories/multichoice/react/package.json | 15 +- categories/multichoice/react/scripts/build.ts | 23 --- .../MenuMultiSelect/MenuMultiSelect.css | 17 -- .../src/components/MenuMultiSelect/index.tsx | 78 +++++--- .../src/components/TagInput/TagInput.css | 109 ----------- .../react/src/components/TagInput/index.tsx | 177 +++++++++++++++--- .../components/ToggleButton/ToggleButton.css | 15 -- .../src/components/ToggleButton/index.tsx | 22 ++- .../components/ToggleSwitch/ToggleSwitch.css | 118 ------------ .../src/components/ToggleSwitch/index.tsx | 124 +++++++++++- .../ToggleTickBox/ToggleTickBox.css | 15 -- .../src/components/ToggleTickBox/index.tsx | 22 ++- categories/number/react/package.json | 12 +- categories/number/react/scripts/build.ts | 20 -- .../NumberSpinner/NumberSpinner.css | 12 -- .../src/components/NumberSpinner/index.tsx | 73 +++++--- .../react/src/components/Slider/Slider.css | 157 ---------------- .../react/src/components/Slider/index.tsx | 165 +++++++++++++++- .../src/components/DateDropdown/index.tsx | 53 +++--- pnpm-lock.yaml | 24 +-- .../components/temporal/TimeSpinner/index.tsx | 53 +++--- .../components/temporal/WeekInput/index.tsx | 53 +++--- .../temporal/YearMonthInput/index.tsx | 53 +++--- .../src/pages/_app.tsx | 16 -- .../src/pages/categories/color/index.tsx | 17 ++ .../src/pages/categories/option/index.tsx | 4 +- .../src/styles/globals.css | 1 + .../tailwind.config.js | 37 +++- 52 files changed, 1152 insertions(+), 1090 deletions(-) delete mode 100644 categories/choice/react/scripts/build.ts delete mode 100644 categories/choice/react/src/components/DropdownSelect/DropdownSelect.css delete mode 100644 categories/choice/react/src/components/MenuSelect/MenuSelect.css delete mode 100644 categories/choice/react/src/components/RadioButton/RadioButton.css delete mode 100644 categories/choice/react/src/components/RadioTickBox/RadioTickBox.css delete mode 100644 categories/color/react/scripts/build.ts delete mode 100644 categories/color/react/src/components/ColorPicker/ColorPicker.css delete mode 100644 categories/multichoice/react/scripts/build.ts delete mode 100644 categories/multichoice/react/src/components/MenuMultiSelect/MenuMultiSelect.css delete mode 100644 categories/multichoice/react/src/components/TagInput/TagInput.css delete mode 100644 categories/multichoice/react/src/components/ToggleButton/ToggleButton.css delete mode 100644 categories/multichoice/react/src/components/ToggleSwitch/ToggleSwitch.css delete mode 100644 categories/multichoice/react/src/components/ToggleTickBox/ToggleTickBox.css delete mode 100644 categories/number/react/scripts/build.ts delete mode 100644 categories/number/react/src/components/NumberSpinner/NumberSpinner.css delete mode 100644 categories/number/react/src/components/Slider/Slider.css diff --git a/TODO.md b/TODO.md index e35574c..05c16e9 100644 --- a/TODO.md +++ b/TODO.md @@ -12,7 +12,7 @@ - [X] RadioTickBox - Color - [ ] ColorPicker - - [X] Swatch + - [X] Swatch (unify with color picker? Swatch is basically a readonly color picker with click-to-copy behavior) - Code - [ ] CodeInput (extract to own package) - [X] CodeBlock (`react-refractor`) @@ -24,7 +24,7 @@ - Freeform - [X] MaskedTextInput - [X] MultilineTextInput - - [X] TextInput + - [X] TextInput (add click-to-copy prop) - Geo - [ ] Map - Information @@ -66,4 +66,9 @@ # Others - [X] Add `select-none` to input labels, etc. +- [ ] Add indicators to components (select, datetime input etc) - [ ] Test all components! +- [ ] Where to put the "click-to-copy" textboxes? Does `Swatch` + belong to this category? +- [ ] Add `aria-*` attributes to all components +- [ ] react-refractor, fix rendering on Lynx! diff --git a/categories/choice/react/package.json b/categories/choice/react/package.json index 46c5050..d261e0d 100644 --- a/categories/choice/react/package.json +++ b/categories/choice/react/package.json @@ -28,7 +28,6 @@ "react-dom": "^18.2.0", "react-test-renderer": "^18.2.0", "tslib": "^2.5.0", - "tsx": "^3.12.7", "typescript": "^4.9.5", "vitest": "^0.33.0" }, @@ -38,7 +37,7 @@ }, "scripts": { "prepublishOnly": "pridepack clean && pridepack build", - "build": "pridepack build && tsx scripts/build.ts", + "build": "pridepack build", "type-check": "pridepack check", "lint": "pridepack lint", "clean": "pridepack clean", @@ -63,7 +62,8 @@ }, "dependencies": { "@tesseract-design/web-base": "workspace:*", - "clsx": "^1.2.1" + "clsx": "^1.2.1", + "tailwindcss": "3.3.2" }, "types": "./dist/types/index.d.ts", "main": "./dist/cjs/production/index.js", @@ -77,13 +77,9 @@ "require": "./dist/cjs/production/index.js", "import": "./dist/esm/production/index.js", "types": "./dist/types/index.d.ts" - }, - "./dist/DropdownSelect.css": "./dist/DropdownSelect.css", - "./dist/MenuSelect.css": "./dist/MenuSelect.css", - "./dist/RadioButton.css": "./dist/RadioButton.css", - "./dist/RadioTickBox.css": "./dist/RadioTickBox.css" + } }, "typesVersions": { "*": {} } -} \ No newline at end of file +} diff --git a/categories/choice/react/scripts/build.ts b/categories/choice/react/scripts/build.ts deleted file mode 100644 index cda40be..0000000 --- a/categories/choice/react/scripts/build.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { copyFileSync, readFileSync, writeFileSync } from 'fs'; -import { resolve } from 'path'; - -const doCopy = (src: string, dest: string) => { - const trueSrc = resolve(src); - const trueDest = resolve(dest); - console.log('Copying...'); - console.log(`${trueSrc} -> ${trueDest}`); - copyFileSync(trueSrc, trueDest); - const packageJsonContents = readFileSync('./package.json', 'utf-8'); - const packageJson = JSON.parse(packageJsonContents); - packageJson.exports[dest] = dest; - const newPackageJsonContents = JSON.stringify(packageJson, null, 2); - console.log('Updating package.json...'); - writeFileSync('./package.json', newPackageJsonContents); - console.log('Done'); -} - -doCopy('./src/components/DropdownSelect/DropdownSelect.css', './dist/DropdownSelect.css'); -doCopy('./src/components/MenuSelect/MenuSelect.css', './dist/MenuSelect.css'); -doCopy('./src/components/RadioButton/RadioButton.css', './dist/RadioButton.css'); -doCopy('./src/components/RadioTickBox/RadioTickBox.css', './dist/RadioTickBox.css'); diff --git a/categories/choice/react/src/components/ComboBox/index.tsx b/categories/choice/react/src/components/ComboBox/index.tsx index 49bd0ab..9ed76ab 100644 --- a/categories/choice/react/src/components/ComboBox/index.tsx +++ b/categories/choice/react/src/components/ComboBox/index.tsx @@ -115,6 +115,34 @@ export const ComboBox = React.forwardRef( style={style} data-testid="base" > + {label && ( + <> + + {' '} + + )} ( }, )} /> - {label && ( - - )} {hint && (
option { - color: rgb(var(--color-positive)); - text-transform: none; - font-size: 1.333333em; -} - -.tesseract-design-dropdown-select option { - user-select: none; -} diff --git a/categories/choice/react/src/components/DropdownSelect/index.tsx b/categories/choice/react/src/components/DropdownSelect/index.tsx index a1b021b..ce53192 100644 --- a/categories/choice/react/src/components/DropdownSelect/index.tsx +++ b/categories/choice/react/src/components/DropdownSelect/index.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; import { TextControl } from '@tesseract-design/web-base'; +import plugin from 'tailwindcss/plugin'; import clsx from 'clsx'; /** @@ -45,6 +46,28 @@ export interface DropdownSelectProps extends Omit { + addComponents({ + '.dropdown-select': { + '& optgroup': { + 'color': 'rgb(var(--color-positive) / 50%)', + 'text-transform': 'uppercase', + 'font-size': '0.75em', + 'margin-top': '0.5rem', + 'user-select': 'none', + }, + '& optgroup > option': { + 'color': 'rgb(var(--color-positive))', + 'text-transform': 'none', + 'font-size': '1.333333em', + }, + '& option': { + 'user-select': 'none', + }, + }, + }); +}); + /** * Component for selecting a single value from a dropdown. */ @@ -84,6 +107,34 @@ export const DropdownSelect = React.forwardRef + {label && ( + <> + + {' '} + + )} - {label && ( - - )} {hint && (
option { - color: rgb(var(--color-positive)); - text-transform: none; - font-size: 1.333333em; -} - -.tesseract-design-menu-select option { - user-select: none; -} diff --git a/categories/choice/react/src/components/MenuSelect/index.tsx b/categories/choice/react/src/components/MenuSelect/index.tsx index 583244d..e681f72 100644 --- a/categories/choice/react/src/components/MenuSelect/index.tsx +++ b/categories/choice/react/src/components/MenuSelect/index.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import { TextControl } from '@tesseract-design/web-base'; import clsx from 'clsx'; +import plugin from 'tailwindcss/plugin'; /** * Derived HTML element of the {@link MenuSelect} component. @@ -49,6 +50,28 @@ export interface MenuSelectProps extends Omit { + addComponents({ + '.menu-select': { + '& optgroup': { + 'color': 'rgb(var(--color-positive) / 50%)', + 'text-transform': 'uppercase', + 'font-size': '0.75em', + 'margin-top': '0.5rem', + 'user-select': 'none', + }, + '& optgroup > option': { + 'color': 'rgb(var(--color-positive))', + 'text-transform': 'none', + 'font-size': '1.333333em', + }, + '& option': { + 'user-select': 'none', + }, + }, + }); +}); + /** * Component for selecting a single value from a menu. */ @@ -86,6 +109,34 @@ export const MenuSelect = React.forwardRef + {label && ( + <> + + {' '} + + )} - {label && ( - - )} {hint && (
+ {label && ( + <> + + {' '} + + )} - {label && ( - - )} {hint && (
+ {label && ( + <> + + {' '} + + )} )} - {label && ( - - )} {hint && (
( style={style} data-testid="base" > + {label && ( + <> + + {' '} + + )} ( }, )} /> - {label && ( - - )} {hint && (
+ {label && ( + <> + + {' '} + + )} - {label && ( - - )} {hint && (
+ {label && ( + <> + + {' '} + + )}