Skip to content

Commit bb53ac5

Browse files
dreyfus9243081j
andauthored
Apply suggestions from @43081j's code review.
Co-authored-by: James Garbutt <[email protected]>
1 parent b7f132f commit bb53ac5

File tree

12 files changed

+18
-21
lines changed

12 files changed

+18
-21
lines changed

packages/core/src/prompts/autocomplete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default class AutocompletePrompt<T extends OptionLike> extends Prompt<
7171

7272
get userInputWithCursor() {
7373
if (!this.userInput) {
74-
return styleText('inverse', styleText('hidden', '_'));
74+
return styleText(['inverse', 'hidden'], '_');
7575
}
7676
if (this._cursor >= this.userInput.length) {
7777
return `${this.userInput}█`;

packages/core/src/prompts/password.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class PasswordPrompt extends Prompt<string> {
1818
}
1919
const userInput = this.userInput;
2020
if (this.cursor >= userInput.length) {
21-
return `${this.masked}${styleText('inverse', styleText('hidden', '_'))}`;
21+
return `${this.masked}${styleText(['inverse', 'hidden'], '_')}`;
2222
}
2323
const masked = this.masked;
2424
const s1 = masked.slice(0, this.cursor);

packages/core/src/prompts/text.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// import color from 'picocolors';
21
import { styleText } from 'node:util';
32
import Prompt, { type PromptOptions } from './prompt.js';
43

packages/core/test/prompts/password.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('PasswordPrompt', () => {
6666
instance.prompt();
6767
input.emit('keypress', 'x', { name: 'x' });
6868
expect(instance.userInputWithCursor).to.equal(
69-
`•${styleText('inverse', styleText('hidden', '_'))}`
69+
`•${styleText(['inverse', 'hidden'], '_')}`
7070
);
7171
});
7272

@@ -95,7 +95,7 @@ describe('PasswordPrompt', () => {
9595
instance.prompt();
9696
input.emit('keypress', 'x', { name: 'x' });
9797
expect(instance.userInputWithCursor).to.equal(
98-
`X${styleText('inverse', styleText('hidden', '_'))}`
98+
`X${styleText(['inverse', 'hidden'], '_')}`
9999
);
100100
});
101101
});

packages/prompts/src/autocomplete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const autocomplete = <Value>(opts: AutocompleteOptions<Value>) => {
108108

109109
case 'cancel': {
110110
const userInputText = userInput
111-
? ` ${styleText('strikethrough', styleText('dim', userInput))}`
111+
? ` ${styleText(['strikethrough', 'dim'], userInput)}`
112112
: '';
113113
return `${headings.join('\n')}\n${styleText('gray', S_BAR)}${userInputText}`;
114114
}

packages/prompts/src/confirm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export const confirm = (opts: ConfirmOptions) => {
3434
return `${title}${styleText('gray', S_BAR)} ${styleText('dim', value)}`;
3535
case 'cancel':
3636
return `${title}${styleText('gray', S_BAR)} ${styleText(
37-
'strikethrough',
38-
styleText('dim', value)
37+
['strikethrough', 'dim'],
38+
value
3939
)}\n${styleText('gray', S_BAR)}`;
4040
default: {
4141
return `${title}${styleText('cyan', S_BAR)} ${

packages/prompts/src/group-multi-select.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// import color from 'picocolors';
21
import { styleText } from 'node:util';
32
import { GroupMultiSelectPrompt } from '@clack/core';
43

@@ -67,7 +66,7 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
6766
}`;
6867
}
6968
if (state === 'cancelled') {
70-
return `${styleText('strikethrough', styleText('dim', label))}`;
69+
return `${styleText(['strikethrough', 'dim'], label)}`;
7170
}
7271
if (state === 'active-selected') {
7372
return `${spacingPrefix}${styleText('dim', prefix)}${styleText('green', S_CHECKBOX_SELECTED)} ${label}${
@@ -98,9 +97,9 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
9897
'reset',
9998
styleText(
10099
'dim',
101-
`Press ${styleText('gray', styleText('bgWhite', styleText('inverse', ' space ')))} to select, ${styleText(
100+
`Press ${styleText(['gray', 'bgWhite', 'inverse'], ' space ')} to select, ${styleText(
102101
'gray',
103-
styleText('bgWhite', styleText('inverse', ' enter '))
102+
styleText(['bgWhite', 'inverse'], ' enter ')
104103
)} to submit`
105104
)
106105
)}`;

packages/prompts/src/multi-select.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
7777
'reset',
7878
styleText(
7979
'dim',
80-
`Press ${styleText('gray', styleText('bgWhite', styleText('inverse', ' space ')))} to select, ${styleText(
80+
`Press ${styleText(['gray', 'bgWhite', 'inverse'], ' space ')} to select, ${styleText(
8181
'gray',
8282
styleText('bgWhite', styleText('inverse', ' enter '))
8383
)} to submit`

packages/prompts/src/password.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export const password = (opts: PasswordOptions) => {
1616
input: opts.input,
1717
output: opts.output,
1818
render() {
19-
// const title = `${color.gray(S_BAR)}\n${symbol(this.state)} ${opts.message}\n`;
2019
const title = `${styleText('gray', S_BAR)}\n${symbol(this.state)} ${opts.message}\n`;
2120
const userInput = this.userInputWithCursor;
2221
const masked = this.masked;
@@ -38,7 +37,7 @@ export const password = (opts: PasswordOptions) => {
3837
}
3938
case 'cancel': {
4039
const maskedText = masked
41-
? ` ${styleText('strikethrough', styleText('dim', masked))}`
40+
? ` ${styleText(['strikethrough', 'dim'], masked)}`
4241
: '';
4342
return `${title}${styleText('gray', S_BAR)}${maskedText}${
4443
masked ? `\n${styleText('gray', S_BAR)}` : ''

packages/prompts/src/select-key.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ export const selectKey = <Value extends string>(opts: SelectOptions<Value>) => {
1313
return `${styleText('dim', label)}`;
1414
}
1515
if (state === 'cancelled') {
16-
return `${styleText('strikethrough', styleText('dim', label))}`;
16+
return `${styleText(['strikethrough', 'dim'], label)}`;
1717
}
1818
if (state === 'active') {
19-
return `${styleText('bgCyan', styleText('gray', ` ${option.value} `))} ${label} ${
19+
return `${styleText(['bgCyan', 'gray'], ` ${option.value} `)} ${label} ${
2020
option.hint ? styleText('dim', `(${option.hint})`) : ''
2121
}`;
2222
}
23-
return `${styleText('gray', styleText('bgWhite', styleText('inverse', ` ${option.value} `)))} ${label} ${
23+
return `${styleText(['gray', 'bgWhite', 'inverse'], ` ${option.value} `)} ${label} ${
2424
option.hint ? styleText('dim', `(${option.hint})`) : ''
2525
}`;
2626
};

0 commit comments

Comments
 (0)