Skip to content

Commit

Permalink
feat: add new label to swaps button [SWAP-86] (#3763)
Browse files Browse the repository at this point in the history
* feat: add new label to swaps button
  • Loading branch information
compojoom authored May 29, 2024
1 parent 050e58b commit 3da9a4e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/components/sidebar/SidebarNavigation/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import AppsIcon from '@/public/images/apps/apps-icon.svg'
import SettingsIcon from '@/public/images/sidebar/settings.svg'
import SwapIcon from '@/public/images/common/swap.svg'
import { SvgIcon } from '@mui/material'
import Chip from '@mui/material/Chip'

export type NavItem = {
label: string
icon?: ReactElement
href: string
tag?: ReactElement
}

export const navItems: NavItem[] = [
Expand All @@ -31,6 +33,7 @@ export const navItems: NavItem[] = [
label: 'Swap',
icon: <SvgIcon component={SwapIcon} inheritViewBox />,
href: AppRoutes.swap,
tag: <Chip label="New" color="success" sx={{ ml: 1 }} />,
},
{
label: 'Transactions',
Expand Down
15 changes: 7 additions & 8 deletions src/components/sidebar/SidebarNavigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ const Navigation = (): ReactElement => {
}
}

const getCounter = (item: NavItem) => {
// Indicate qeueued txs
if (item.href === AppRoutes.transactions.history) {
return queueSize
}
}

// Route Transactions to Queue if there are queued txs, otherwise to History
const getRoute = (href: string) => {
if (href === AppRoutes.transactions.history && queueSize) {
Expand All @@ -75,6 +68,12 @@ const Navigation = (): ReactElement => {
{enabledNavItems.map((item) => {
const isSelected = currentSubdirectory === getSubdirectory(item.href)

let ItemTag = item.tag ? item.tag : null

if (item.href === AppRoutes.transactions.history) {
ItemTag = queueSize ? <SidebarListItemCounter count={queueSize} /> : null
}

return (
<ListItem
key={item.href}
Expand All @@ -91,7 +90,7 @@ const Navigation = (): ReactElement => {
<SidebarListItemText data-testid="sidebar-list-item" bold>
{item.label}

<SidebarListItemCounter count={getCounter(item)} />
{ItemTag}
</SidebarListItemText>
</SidebarListItemButton>
</ListItem>
Expand Down
2 changes: 1 addition & 1 deletion src/components/theme/darkPalette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const darkPalette = {
secondary: {
dark: '#636669',
main: '#FFFFFF',
light: '#12FF80',
light: '#B0FFC9',
background: '#1B2A22',
},
border: {
Expand Down
11 changes: 11 additions & 0 deletions src/components/theme/safeTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ declare module '@mui/material/styles' {
backdrop: Palette['primary']
static: Palette['primary']
}

export interface PaletteOptions {
border: PaletteOptions['primary']
logo: PaletteOptions['primary']
Expand All @@ -33,6 +34,7 @@ declare module '@mui/material/styles' {
export interface PaletteColor {
background?: string
}

export interface SimplePaletteColorOptions {
background?: string
}
Expand All @@ -52,6 +54,7 @@ declare module '@mui/material/Button' {
export interface ButtonPropsColorOverrides {
background: true
}

export interface ButtonPropsVariantOverrides {
danger: true
}
Expand Down Expand Up @@ -279,6 +282,14 @@ const createSafeTheme = (mode: PaletteMode): Theme => {
},
},
},
MuiChip: {
styleOverrides: {
colorSuccess: ({ theme }) => ({
backgroundColor: theme.palette.secondary.light,
height: '24px',
}),
},
},
MuiAlert: {
styleOverrides: {
standardError: ({ theme }) => ({
Expand Down

0 comments on commit 3da9a4e

Please sign in to comment.