Skip to content

Commit

Permalink
Fix: add check next to active workspace (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
jared-dickman authored Mar 14, 2024
1 parent eb54749 commit 786f7af
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 12 deletions.
7 changes: 7 additions & 0 deletions src/assets/svg/check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/components/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import ChartLineIcon from 'src/assets/svg/chart-line.svg?react'
import ConnectionsIcon from 'src/assets/svg/connections.svg?react'
import DatabaseIcon from 'src/assets/svg/database.svg?react'
import GridIcon from 'src/assets/svg/grid.svg?react'
import CheckIcon from 'src/assets/svg/check.svg?react'
import ShieldKeyholeIcon from 'src/assets/svg/shield-keyhole.svg?react'
import UsersIcon from 'src/assets/svg/users.svg?react'
import WrenchIcon from 'src/assets/svg/wrench.svg?react'
Expand All @@ -27,6 +28,7 @@ export {
LockIcon,
MpLogoIcon,
SearchIcon,
CheckIcon,
ChartLineIcon,
ConnectionsIcon,
DatabaseIcon,
Expand All @@ -46,4 +48,4 @@ export {
CircleNodesIcon,
CloudIcon,
FolderClosedIcon,
}
}
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export {
LockIcon,
MpLogoIcon,
SearchIcon,
CheckIcon,
ChartLineIcon,
ConnectionsIcon,
DatabaseIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ const indOrgs: INavigationOrg[] = [
workspaces: [
{
id: 'project 2',
label: 'Project 2',
label: 'Project2Project2Project2Project2Project2Project2',
isActive: true,
onClick: () => {
alert('Selected project 2')
Expand Down Expand Up @@ -914,4 +914,4 @@ export const Cortex: Story = {
alert('going to overview map')
},
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
type IWorkspaceSelectorDisplayItem,
Popover,
} from 'src/components'
import { Flex } from 'src/components'
import { CheckIcon } from 'src/components'
import React, { type ChangeEvent, useRef, useState } from 'react'
import { useCallback } from 'react'
import { useEffect } from 'react'
Expand Down Expand Up @@ -184,7 +186,12 @@ export function WorkspaceSelector(props: IWorkspaceSelectorProps) {
className:
'workspaceSelector__workspaceName' +
(workspace.isActive ? ' workspaceSelector__workspaceName--active' : ''),
label: workspace.label,
label: (
<Flex justify="space-between" align="center">
{workspace.label}
{workspace.isActive && <CheckIcon className="workspaceSelector__activeIcon" />}
</Flex>
),
id: workspace.id,
key: `${workspace.id}_${workspace.label}`,
onClick: workspace.onClick,
Expand Down Expand Up @@ -248,4 +255,4 @@ export function WorkspaceSelector(props: IWorkspaceSelectorProps) {
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type MenuItemType } from 'src/components/navigation/Menu/Menu'
import { type ReactNode } from 'react'

interface IWorkspaceSelectorItem {
label: string
Expand All @@ -23,10 +24,10 @@ export interface INavigationWorkspace extends IWorkspaceSelectorItem {
export interface IWorkspaceSelectorDisplayItem extends MenuItemType {
type: 'org' | 'account' | 'workspace'
className: string
label: string
label: ReactNode
id: string

accounts?: INavigationAccount[]
workspaces?: INavigationWorkspace[]
isActive?: boolean
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,29 @@
.workspaceSelector__workspaceName {
padding-top: var(--padding-xs);
padding-bottom: var(--padding-xs);
cursor: pointer;
padding-left: calc(var(--padding-sm) + var(--padding)) !important;
border-radius: var(--border-radius-sm);
cursor: pointer;
}

.workspaceSelector__workspaceName:hover {
background-color: var(--color-bg-text-hover);
background-color: var(--control-item-bg-hover);
}

.workspaceSelector__workspaceName.workspaceSelector__workspaceName--active {
border-radius: var(--border-radius-sm);
.workspaceSelector__workspaceName.workspaceSelector__workspaceName--active,
.workspaceSelector__workspaceName:active {
background: var(--control-item-bg-active) !important;
}

.workspaceSelector__activeIcon {
padding-right: var(--padding);
padding-left: var(--padding-xs);
width: var(--size-sm);
min-width: var(--size-sm);
height: var(--size-sm);
}


.workspaceSelector__orgName,
.workspaceSelector__accountName {
pointer-events: none; /* only workspaces are clickable */
Expand All @@ -97,6 +107,7 @@
.workspaceSelector__workspaceName {
margin-top: 0 !important;
margin-bottom: 0 !important;
overflow-wrap: anywhere;
}

.workspaceSelector__signout {
Expand All @@ -119,4 +130,4 @@

.workspaceSelector__signoutButton {
width: 100%;
}
}

0 comments on commit 786f7af

Please sign in to comment.