Skip to content

Commit 6deca88

Browse files
committed
feat: enhance CommandBar with CommandGroup integration and type definitions
1 parent 90bc497 commit 6deca88

File tree

4 files changed

+66
-11
lines changed

4 files changed

+66
-11
lines changed

src/Pages/Shared/CommandBar/CommandBar.component.tsx

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { useEffect, useState } from 'react'
22

33
import { Backdrop, KeyboardShortcut, SearchBar, useRegisterShortcut } from '@devtron-labs/devtron-fe-common-lib'
44

5-
import { SHORT_CUTS } from './constants'
5+
import CommandGroup from './CommandGroup'
6+
import { NAVIGATION_GROUPS, SHORT_CUTS } from './constants'
67

78
import './CommandBar.scss'
89

@@ -39,15 +40,26 @@ const CommandBar = () => {
3940
<Backdrop onEscape={handleClose}>
4041
<div className="dc__mxw-800 mxh-450 flexbox-col dc__overflow-auto dc__content-space br-12 bg__modal--primary command-bar__container w-100 h-100">
4142
<div className="flexbox-col dc__overflow-auto">
42-
<SearchBar
43-
inputProps={{
44-
autoFocus: true,
45-
placeholder: 'Search or jump to…',
46-
}}
47-
noBackgroundAndBorder
48-
/>
49-
50-
<div className="flexbox-col dc__overflow-auto border__primary--top pt-8" />
43+
<div className="px-16">
44+
<SearchBar
45+
inputProps={{
46+
autoFocus: true,
47+
placeholder: 'Search or jump to…',
48+
}}
49+
noBackgroundAndBorder
50+
/>
51+
</div>
52+
53+
<div
54+
className="flexbox-col dc__overflow-auto border__primary--top pt-8"
55+
role="listbox"
56+
aria-label="Command Menu"
57+
// TODO: aria-activedescendant for the currently focused item
58+
>
59+
{NAVIGATION_GROUPS.map((group) => (
60+
<CommandGroup key={group.id} groupDetails={group} />
61+
))}
62+
</div>
5163
</div>
5264

5365
<div className="flexbox dc__content-space dc__align-items-center px-20 py-12 border__primary--top bg__secondary">
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
.command-bar {
22
&__container {
33
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.04), 0 2px 8px 0 rgba(0, 0, 0, 0.04), 0 3px 17px 0 rgba(0, 0, 0, 0.04), 0 4px 30px 0 rgba(0, 0, 0, 0.13), 0 8px 48px 0 rgba(0, 0, 0, 0.15);
4+
5+
.search-bar {
6+
&:focus-within {
7+
border: none !important;
8+
}
9+
10+
&:hover {
11+
background: transparent !important;
12+
}
13+
}
414
}
515
}
Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1-
const CommandGroup = () => <div />
1+
import { Icon } from '@devtron-labs/devtron-fe-common-lib'
2+
3+
import { CommandGroupProps } from './types'
4+
5+
const CommandGroup = ({ groupDetails }: CommandGroupProps) => (
6+
<div className="flexbox-col p-8">
7+
<div className="flexbox px-16 py-6 dc__gap-4">
8+
<h2 className="m-0 cn-7 fs-13 fw-6 lh-20 dc__uppercase font-ibm-plex-mono" id={groupDetails.id}>
9+
{groupDetails.title}
10+
</h2>
11+
</div>
12+
13+
{/* TODO: Empty/Loading/Error state */}
14+
<div className="flexbox-col" key={groupDetails.id} role="group" aria-labelledby={groupDetails.id}>
15+
{groupDetails.items.map((item) => (
16+
<div
17+
className="flexbox px-16 py-12 dc__align-items-center dc__gap-8"
18+
role="option"
19+
// TODO: Fix later
20+
aria-selected="false"
21+
>
22+
<div className="flexbox dc__align-items-center dc__gap-12">
23+
<Icon name={item.icon} size={24} color="N700" />
24+
<h3 className="m-0 cn-9 fs-14 fw-4 lh-20 dc__truncate">{item.title}</h3>
25+
</div>
26+
</div>
27+
))}
28+
</div>
29+
</div>
30+
)
231

332
export default CommandGroup

src/Pages/Shared/CommandBar/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,7 @@ export interface CommandBarGroupType {
126126
title: string
127127
items: CommandBarItemType[]
128128
}
129+
130+
export interface CommandGroupProps {
131+
groupDetails: CommandBarGroupType
132+
}

0 commit comments

Comments
 (0)