Skip to content

Commit 61b713a

Browse files
authored
PLU-470: add learning resources to sidebar (#966)
## Details - Added an external link to the learning resources because right now, there is no way to access it from our plumber app. - Made it responsive for mobile and smaller screens too - Moved the new badge from `Templates` to `Learn` button instead ## Before & After Screenshots **BEFORE**: https://github.com/user-attachments/assets/fd0467d3-8cb3-4192-81a0-83e66dcf1c53 **AFTER**: https://github.com/user-attachments/assets/9df27e15-4ed8-42b9-be48-0f526301e525 ## Tests - Check that all pages can still be accessed e.g. pipes, tiles - Check that learning resource page is accessed as a new tab
1 parent 19ca977 commit 61b713a

File tree

4 files changed

+45
-26
lines changed

4 files changed

+45
-26
lines changed

packages/frontend/src/components/Layout/NavigationDrawer.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,8 @@ export default function NavigationDrawer() {
3333
<Drawer placement="left" onClose={closeDrawer} isOpen={isDrawerOpen}>
3434
<DrawerOverlay />
3535
<DrawerContent>
36-
<DrawerCloseButton
37-
pos="relative"
38-
mt={8}
39-
ml={4}
40-
color="base.content.strong"
41-
/>
42-
<DrawerBody p={4}>
36+
<DrawerCloseButton pos="absolute" color="base.content.strong" />
37+
<DrawerBody p={4} mt={6}>
4338
<NavigationSidebar />
4439
</DrawerBody>
4540
</DrawerContent>

packages/frontend/src/components/Layout/NavigationSidebar.tsx

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useContext } from 'react'
22
import { Link, matchPath, useLocation } from 'react-router-dom'
3-
import { Box, Text } from '@chakra-ui/react'
3+
import { Box, Divider, Text } from '@chakra-ui/react'
44
import {
55
Badge,
66
SidebarContainer,
@@ -22,7 +22,7 @@ function NavigationSidebarItem({
2222
}: NavigationSidebarItemProps): JSX.Element {
2323
const { pathname } = useLocation()
2424

25-
const { to, Icon: icon, text, otherLinks } = link
25+
const { to, Icon: icon, text, otherLinks, isExternal } = link
2626
const selected = [to, ...(otherLinks || [])].some((link) =>
2727
matchPath(link, pathname),
2828
)
@@ -34,7 +34,8 @@ function NavigationSidebarItem({
3434
icon={icon}
3535
as={Link}
3636
to={to}
37-
onClick={closeDrawer}
37+
target={isExternal ? '_blank' : undefined}
38+
onClick={isExternal ? undefined : closeDrawer}
3839
isActive={!!selected}
3940
color="base.content.default"
4041
_hover={{
@@ -69,23 +70,31 @@ export default function NavigationSidebar() {
6970
return (
7071
// top sidebar items
7172
<SidebarContainer variant="sticky">
72-
{links.map(
73-
(link, index) =>
74-
!link.isBottom && (
75-
<NavigationSidebarItem
76-
key={index}
77-
link={link}
78-
closeDrawer={closeDrawer}
79-
/>
80-
),
81-
)}
73+
<Box p={0}>
74+
{links.map(
75+
(link, index) =>
76+
!link.isBottom && (
77+
<NavigationSidebarItem
78+
key={index}
79+
link={link}
80+
closeDrawer={closeDrawer}
81+
/>
82+
),
83+
)}
84+
</Box>
8285

83-
{/* bottom sidebar items */}
84-
<Box
85-
position="fixed"
86-
bottom={2}
87-
w={{ base: 'calc(100% - 2rem)', sm: 'inherit' }}
86+
<Text
87+
p={4}
88+
display={{ sm: 'none', lg: 'block' }}
89+
ml={{ sm: 0, lg: 2 }}
90+
textStyle="caption-3"
8891
>
92+
Resources
93+
</Text>
94+
<Divider my={2} hideFrom="lg" hideBelow="sm" />
95+
96+
{/* bottom sidebar items */}
97+
<Box>
8998
{links.map(
9099
(link, index) =>
91100
link.isBottom && (

packages/frontend/src/components/Layout/index.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { useMemo, useState } from 'react'
2-
import { BiBookOpen, BiHistory, BiSolidGrid, BiTable } from 'react-icons/bi'
2+
import {
3+
BiBookOpen,
4+
BiBookReader,
5+
BiHistory,
6+
BiSolidGrid,
7+
BiTable,
8+
} from 'react-icons/bi'
39
import { Box, Divider, Show } from '@chakra-ui/react'
410

511
import AppBar from '@/components/AppBar'
@@ -26,6 +32,7 @@ export type DrawerLink = {
2632
otherLinks?: string[]
2733
isBottom?: boolean
2834
badge?: string
35+
isExternal?: boolean
2936
}
3037

3138
const drawerLinks = [
@@ -55,7 +62,14 @@ const drawerLinks = [
5562
text: 'Templates',
5663
to: URLS.TEMPLATES,
5764
isBottom: true,
65+
},
66+
{
67+
Icon: BiBookReader,
68+
text: 'Learn',
69+
to: URLS.LEARN_LINK,
70+
isBottom: true,
5871
badge: 'New',
72+
isExternal: true,
5973
},
6074
]
6175

packages/frontend/src/config/urls.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,4 @@ export const SGID_CHECK_ELIGIBILITY_URL =
8484
'https://docs.id.gov.sg/faq-users#as-a-government-officer-why-am-i-not-able-to-login-to-my-work-tool-using-sgid'
8585
export const TEMPLATES_FORM_LINK = 'https://go.gov.sg/request-template'
8686
export const SUPPORT_FORM_LINK = 'https://go.gov.sg/plumber-support'
87+
export const LEARN_LINK = 'https://go.gov.sg/learn-plumber'

0 commit comments

Comments
 (0)