Skip to content

Commit 7f2ed9f

Browse files
committed
FEATURE: Show current command in footer
1 parent c37bd2f commit 7f2ed9f

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

packages/commandbar/src/components/CommandBarFooter/CommandBarFooter.tsx

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,47 @@ import * as styles from './CommandBarFooter.module.css';
1010

1111
const CommandBarFooter: React.FC = () => {
1212
const {
13-
state: { activeCommandId, activeCommandMessage, commands, result, selectedCommandGroup, expanded },
14-
Icon,
13+
state: {
14+
activeCommandId,
15+
resultCommandId,
16+
activeCommandMessage,
17+
commands,
18+
result,
19+
selectedCommandGroup,
20+
expanded
21+
},
22+
Icon
1523
} = useCommandBarState();
1624

17-
const runningCommand = useComputed<Command>(() => {
18-
if (!activeCommandId.value) return null;
25+
const commandForContext = useComputed<Command>(() => {
26+
const commandId = activeCommandId.value ?? resultCommandId.value;
27+
if (!commandId) return null;
1928
// FIXME: This will not be correct when a command and an option in the result have the same id
20-
return activeCommandId.value
21-
? commands.value[activeCommandId.value] ?? result.value.options[activeCommandId.value]
29+
return commandId
30+
? commands.value[commandId] ?? result.value.options[commandId]
2231
: null;
2332
});
2433

34+
const isRunning = activeCommandId.value !== null;
35+
2536
if (!expanded.value) return null;
2637

2738
return (
2839
<footer className={styles.commandBarFooter}>
29-
{activeCommandId.value ? (
40+
{isRunning ? (
3041
<span className={styles.activity}>
3142
<IconWrapper>
3243
<IconSpinner />
3344
</IconWrapper>
3445
<em>
35-
{runningCommand.value.name}{activeCommandMessage}
46+
{commandForContext.value.name}{activeCommandMessage.value ? '﹘' + activeCommandMessage.value : ''}
3647
</em>
3748
</span>
49+
) : commandForContext.value ? (
50+
<span className={styles.breadcrumb}>
51+
<Icon icon={commandForContext.value.icon} />
52+
<small>{commandForContext.value.name}</small>
53+
</span>
3854
) : selectedCommandGroup.value ? (
3955
<span className={styles.breadcrumb}>
4056
<Icon icon={commands.value[selectedCommandGroup.value].icon} />

0 commit comments

Comments
 (0)