forked from buefy/buefy
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TypeScript Rollout Tier 9 - Colorpicker & color (#374)
* feat(lib): rewrite utils/color in TS Rewrites `src/utils/color.js` in TypeScript. Unrolls the loops to dynamically define the following Color components as pairs of `get` and `set` methods: - `red` - `green` - `blue` - `alpha` - `hue` - `saturation` - `lightness` My attempt to augment the `Color` class with an ambient module did not work when all the Buefy types were bundled in a single `.dts` file; i.e., it won't work in users' environments. Replaces `get [Symbol.toString]` with `get [Symbol.toStringTag]` to suppress a type error, although, I am not 100% confident about this solutation because I was not able to identify the intention of the original code. `color.ts` exports color model types: `Hsl`, `Hsla`, `Rgb`, and `Rgba` * test(lib): rewrite spec for utils/color in TS Rewrites `src/utils/color.spec.js→ts` in TypeScript. Imports the spec building blocks from the `vitest` package. * feat(lib): rewrite colorpicker in TS Rewrites the colorpicker components in the `src/components/colorpicker` in TypeScript. In `Colorpicker.vue`: - The `modelValue` prop, and its emitted value on "update:modelValue" have different types; `string | Rgb` vs `Color`. A user of `Colorpicker` may specify a string or an `Rgb` object to the prop unless `v-model` is necessary. - Introduces a new type `IColorpicker` which represents a partial interface of `Colorpicker` to avoid circular references between `Colorpicker`, and `ColorFormatter` or `ColorParser` - Introduces new types: - `ColorFormatter`: type of the `colorFormatter` prop - `ColorParser`: type of the `colorParser` prop - No longer imports `Icon` and `Select`, because they are not used - I found the following methods were not used but decided to leave them until we come back to deal with the `open-on-focus` and `close-on-click` props: - `handleOnFocus` - `toggle`: commented out because it contains an unfixable type error - `onInputClick` - `keyPress` - `togglePicker`: only called in `handleOnFocus` and `keyPress` In `ColorpickerHSLRepresentationSquare.vue`, fixes a bug that the `precision` custom template literal function tried to round `values` instead of `values[i]`, while fixing the type error In `ColorpickerHSLRepresentationSquare/Triangle.vue, the `value` prop, and its emitted value on "input" have different types; `Hsl` vs `Color` In `Colorpicker.vue`, and `ColorpickerAlphaSlider.vue`: - Directly names Buefy components when they are registered so that they are type-checked. Note no type-checking is performed for components indirectly registered using the `name` field. Replaces JSDoc-style comments with ordinary ones so that `@microsoft/api-extractor` won't pick them up for documentation. * test(lib): rewrite specs for colorpicker in TS Rewrites the specs for the colorpicker components in the `src/components/colorpicker` folder in TypeScript. All the changes are straightforward. Imports the spec building blocks from the `vitest` package. In the `__snapshots__` folder, replaces the snapshots produced by Jest with those by Vitest. * chore(lib): bundle colorpicker in TS `rollup.config.mjs` removes "colorpicker" from `JS_COMPONENTS`. * feat(docs): rewrite colorpicker docs in TS Rewrites the documentation for the colorpicker components in the `src/pages/components/colorpicker` folder in TypeScript. All the changes are straightforward. Here is a TypeScript migration tip: - Explicitly import and register components so that they are type checked. No type-checking is performed for globally registered components.
- Loading branch information
Showing
28 changed files
with
503 additions
and
347 deletions.
There are no files selected for viewing
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
3 changes: 2 additions & 1 deletion
3
...omponents/colorpicker/Colorpicker.spec.js → ...omponents/colorpicker/Colorpicker.spec.ts
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
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
3 changes: 2 additions & 1 deletion
3
...olorpicker/ColorpickerAlphaSlider.spec.js → ...olorpicker/ColorpickerAlphaSlider.spec.ts
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.