Show descriptions for generated commands, make them look better and sort better (#3023)

This commit is contained in:
Frank Noirot
2024-07-12 17:48:38 -04:00
committed by GitHub
parent e81b614523
commit 29bf77bb82
5 changed files with 16 additions and 8 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -72,17 +72,21 @@ function CommandComboBox({
<Combobox.Option <Combobox.Option
key={option.groupId + option.name + (option.displayName || '')} key={option.groupId + option.name + (option.displayName || '')}
value={option} value={option}
className="flex items-center gap-2 px-4 py-1 first:mt-2 last:mb-2 ui-active:bg-primary/10 dark:ui-active:bg-chalkboard-90" className="flex items-center gap-4 px-4 py-1.5 first:mt-2 last:mb-2 ui-active:bg-primary/10 dark:ui-active:bg-chalkboard-90"
> >
{'icon' in option && option.icon && ( {'icon' in option && option.icon && (
<CustomIcon name={option.icon} className="w-5 h-5" /> <CustomIcon name={option.icon} className="w-5 h-5" />
)} )}
<p className="flex-grow">{option.displayName || option.name} </p> <div className="flex-grow flex flex-col">
<p className="my-0 leading-tight">
{option.displayName || option.name}{' '}
</p>
{option.description && ( {option.description && (
<p className="text-xs text-chalkboard-60 dark:text-chalkboard-40"> <p className="my-0 text-xs text-chalkboard-60 dark:text-chalkboard-50">
{option.description} {option.description}
</p> </p>
)} )}
</div>
</Combobox.Option> </Combobox.Option>
))} ))}
</Combobox.Options> </Combobox.Options>

View File

@ -124,6 +124,7 @@ export function createSettingsCommand({
displayName: `Settings · ${decamelize(type.replaceAll('.', ' · '), { displayName: `Settings · ${decamelize(type.replaceAll('.', ' · '), {
separator: ' ', separator: ' ',
})}`, })}`,
description: settingConfig.description,
groupId: 'settings', groupId: 'settings',
icon: 'settings', icon: 'settings',
needsReview: false, needsReview: false,

View File

@ -81,6 +81,7 @@ export function createMachineCommand<
name: type, name: type,
groupId, groupId,
icon, icon,
description: commandConfig.description,
needsReview: commandConfig.needsReview || false, needsReview: commandConfig.needsReview || false,
onSubmit: (data?: S[typeof type]) => { onSubmit: (data?: S[typeof type]) => {
if (data !== undefined && data !== null) { if (data !== undefined && data !== null) {

View File

@ -514,7 +514,9 @@ export const commandBarMachine = createMachine(
) )
function sortCommands(a: Command, b: Command) { function sortCommands(a: Command, b: Command) {
if (b.groupId === 'auth') return -1 if (b.groupId === 'auth' && !(a.groupId === 'auth')) return -2
if (a.groupId === 'auth') return 1 if (a.groupId === 'auth' && !(b.groupId === 'auth')) return 2
if (b.groupId === 'settings' && !(a.groupId === 'settings')) return -1
if (a.groupId === 'settings' && !(b.groupId === 'settings')) return 1
return a.name.localeCompare(b.name) return a.name.localeCompare(b.name)
} }