Skip to content

Commit 43aed55

Browse files
authored
feat: change disabled multi-select options to have strikethrough (#419)
1 parent 703f55f commit 43aed55

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

.changeset/dirty-areas-sin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clack/prompts": patch
3+
---
4+
5+
Change styling of disabled multi-select options to have strikethrough.

packages/prompts/src/multi-select.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
4242
) => {
4343
const label = option.label ?? String(option.value);
4444
if (state === 'disabled') {
45-
return `${color.gray(S_CHECKBOX_INACTIVE)} ${computeLabel(label, color.gray)}${
45+
return `${color.gray(S_CHECKBOX_INACTIVE)} ${computeLabel(label, (str) => color.strikethrough(color.gray(str)))}${
4646
option.hint ? ` ${color.dim(`(${option.hint ?? 'disabled'})`)}` : ''
4747
}`;
4848
}

packages/prompts/test/__snapshots__/multi-select.test.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ exports[`multiselect (isCI = false) > renders disabled options 1`] = `
245245
"<cursor.hide>",
246246
"│
247247
◆ foo
248-
[36m│[39m [90m◻[39m [90mopt0[39m
248+
[36m│[39m [90m◻[39m [9m[90mopt0[39m[29m
249249
│ ◻ opt1
250-
[36m│[39m [90m◻[39m [90mopt2[39m [2m(Hint 2)[22m
250+
[36m│[39m [90m◻[39m [9m[90mopt2[39m[29m [2m(Hint 2)[22m
251251
└
252252
",
253253
"<cursor.backward count=999><cursor.up count=6>",
@@ -979,9 +979,9 @@ exports[`multiselect (isCI = true) > renders disabled options 1`] = `
979979
"<cursor.hide>",
980980
"│
981981
◆ foo
982-
[36m│[39m [90m◻[39m [90mopt0[39m
982+
[36m│[39m [90m◻[39m [9m[90mopt0[39m[29m
983983
│ ◻ opt1
984-
[36m│[39m [90m◻[39m [90mopt2[39m [2m(Hint 2)[22m
984+
[36m│[39m [90m◻[39m [9m[90mopt2[39m[29m [2m(Hint 2)[22m
985985
└
986986
",
987987
"<cursor.backward count=999><cursor.up count=6>",

0 commit comments

Comments
 (0)