From c54c25d7bbbdc055d2df97396c3b73e66f8b3b78 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Mon, 30 May 2022 09:05:25 -0600 Subject: [PATCH] Improved distinction between selected and unselected prompt items (#811) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Improve distinction bewtween selected and unselected prompt items Fixes #809 * Create green-meals-cough.md Co-authored-by: Mateusz BurzyƄski --- .changeset/green-meals-cough.md | 5 +++++ packages/cli/package.json | 1 + packages/cli/src/utils/cli-utilities.ts | 10 +++++++++- yarn.lock | 10 ++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 .changeset/green-meals-cough.md diff --git a/.changeset/green-meals-cough.md b/.changeset/green-meals-cough.md new file mode 100644 index 000000000..79d60af1b --- /dev/null +++ b/.changeset/green-meals-cough.md @@ -0,0 +1,5 @@ +--- +"@changesets/cli": patch +--- + +Improved accessibility of the CLI prompts by using selected/unselected indicators that don't rely solely on the colors. diff --git a/packages/cli/package.json b/packages/cli/package.json index 5551f23f5..4affcfd14 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -47,6 +47,7 @@ "@manypkg/get-packages": "^1.1.3", "@types/is-ci": "^3.0.0", "@types/semver": "^6.0.0", + "ansi-colors": "^4.1.3", "chalk": "^2.1.0", "enquirer": "^2.3.0", "external-editor": "^3.1.0", diff --git a/packages/cli/src/utils/cli-utilities.ts b/packages/cli/src/utils/cli-utilities.ts index bafb45bda..603bc61d9 100644 --- a/packages/cli/src/utils/cli-utilities.ts +++ b/packages/cli/src/utils/cli-utilities.ts @@ -3,6 +3,7 @@ import termSize from "term-size"; import { error, prefix, success } from "@changesets/logger"; import { prompt } from "enquirer"; import { edit } from "external-editor"; +import { symbols } from "ansi-colors"; // those types are not exported from `enquirer` so we extract them here // so we can make type assertions using them because `enquirer` types do no support `prefix` right now @@ -60,7 +61,14 @@ async function askCheckboxPlus( choices, format, limit, - onCancel: cancelFlow + onCancel: cancelFlow, + symbols: { + indicator: symbols.radioOff, + checked: symbols.radioOn + }, + indicator(state: any, choice: any) { + return choice.enabled ? state.symbols.checked : state.symbols.indicator; + } } as ArrayPromptOptions) .then((responses: any) => responses[name]) .catch((err: unknown) => { diff --git a/yarn.lock b/yarn.lock index 6514d7bf4..5817814dd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1075,6 +1075,11 @@ resolved "https://registry.yarnpkg.com/@changesets/types/-/types-0.4.0.tgz#3413badb2c3904357a36268cb9f8c7e0afc3a804" integrity sha512-TclHHKDVYQ8rJGZgVeWiF7c91yWzTTWdPagltgutelGu/Psup5PQlUq6svx7S8suj+jXcaE34yEEsfIvzXXB2Q== +"@changesets/types@^4.0.1": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@changesets/types/-/types-4.1.0.tgz#fb8f7ca2324fd54954824e864f9a61a82cb78fe0" + integrity sha512-LDQvVDv5Kb50ny2s25Fhm3d9QSZimsoUGBsUioj6MC3qbMUCuC8GPIvk/M6IvXx3lYhAs0lwWUQLb+VIEUCECw== + "@cnakazawa/watch@^1.0.3": version "1.0.3" resolved "https://registry.yarnpkg.com/@cnakazawa/watch/-/watch-1.0.3.tgz#099139eaec7ebf07a27c1786a3ff64f39464d2ef" @@ -1920,6 +1925,11 @@ ansi-colors@^4.1.1: resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== +ansi-colors@^4.1.3: + version "4.1.3" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.3.tgz#37611340eb2243e70cc604cad35d63270d48781b" + integrity sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw== + ansi-escapes@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b"