Skip to content

Commit aebfa69

Browse files
committed
feat(ui-top-nav-bar): add stuff
1 parent dc70df5 commit aebfa69

File tree

2 files changed

+58
-54
lines changed

2 files changed

+58
-54
lines changed

packages/__docs__/src/App/index.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class App extends Component<AppProps, AppState> {
6363
}
6464

6565
isCoursePage() {
66-
return location.pathname.startsWith('/courses')
66+
return location.pathname.startsWith('/course')
6767
}
6868

6969
componentDidMount() {
@@ -172,24 +172,14 @@ class App extends Component<AppProps, AppState> {
172172
id: 'courses1',
173173
label: 'Courses1',
174174
onClick: () => {
175-
this.props.navigate('/courses/course1', { replace: true })
176-
setTimeout(() => {
177-
window.location.reload()
178-
}, 50) // Small delay ensures React updates before reloading
179-
180-
// window.location.reload()
175+
this.props.navigate('/course1', { replace: true })
181176
}
182177
},
183178
{
184179
id: 'courses2',
185180
label: 'Courses2',
186181
onClick: () => {
187-
this.props.navigate('/courses/course2', { replace: true })
188-
setTimeout(() => {
189-
window.location.reload()
190-
}, 50) // Small delay ensures React updates before reloading
191-
192-
// window.location.reload()
182+
this.props.navigate('/course2', { replace: true })
193183
}
194184
}
195185
]
@@ -226,12 +216,16 @@ class App extends Component<AppProps, AppState> {
226216
<SideNavBar.Item
227217
icon={<IconUserLine />}
228218
label="Account"
229-
href="/account"
219+
onClick={() =>
220+
this.props.navigate('/account', { replace: true })
221+
}
230222
/>
231223
<SideNavBar.Item
232224
icon={<IconCoursesLine />}
233225
label="Courses"
234-
href="/courses"
226+
onClick={() =>
227+
this.props.navigate('/course1', { replace: true })
228+
}
235229
/>
236230
<SideNavBar.Item
237231
icon={<IconDashboardLine />}
@@ -243,7 +237,7 @@ class App extends Component<AppProps, AppState> {
243237
<SideNavBar.Item
244238
icon={<IconQuestionLine />}
245239
label="Help"
246-
href="#"
240+
onClick={() => alert('Help clicked')}
247241
/>
248242
</SideNavBar>
249243
)}
@@ -254,6 +248,7 @@ class App extends Component<AppProps, AppState> {
254248
<CanvasTopNav
255249
brand={brandSvg}
256250
lti={false}
251+
showDesktopView={this.isCoursePage()}
257252
buttons={[
258253
{
259254
label: 'AddLine',
@@ -269,11 +264,12 @@ class App extends Component<AppProps, AppState> {
269264
breadcrumb={{
270265
label: 'You are here:',
271266
links: [
272-
{ href: '#', label: 'Student Forecast' },
273-
{ href: '#', label: 'University of Utah' },
274-
{ label: 'University of Colleges' }
267+
{ href: '#', label: 'Crumb 1' },
268+
{ href: '#', label: 'Crumb 2' },
269+
{ label: 'Home' }
275270
]
276271
}}
272+
hamburgerLabel="Open the main menu"
277273
hamburgerOnClick={() => alert('Hamburger clicked')}
278274
mobileButtons={[
279275
{
@@ -311,8 +307,12 @@ class App extends Component<AppProps, AppState> {
311307
element={<h1>This is the account page</h1>}
312308
/>
313309
<Route
314-
path="/courses"
315-
element={<h1>This is a course home page</h1>}
310+
path="/course1"
311+
element={<h1>This is the first course home page</h1>}
312+
/>
313+
<Route
314+
path="/course2"
315+
element={<h1>This is the second course home page</h1>}
316316
/>
317317
</Routes>
318318
</div>

packages/ui-top-nav-bar/src/CanvasTopNav/index.tsx

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ const CanvasTopNav = ({
5151
mobileButtons = [],
5252
mobileMenu = [],
5353
hamburgerOnClick,
54+
hamburgerLabel,
55+
showDesktopView,
5456
styles
5557
}: any) => {
5658
const [isSmallScreen, setIsSmallScreen] = useState(false)
@@ -135,39 +137,41 @@ const CanvasTopNav = ({
135137
</MobileTopNav.Menu>
136138
</MobileTopNav>
137139
) : (
138-
<DesktopTopNav lightMode={lti}>
139-
<DesktopTopNav.Start>
140-
<IconButton
141-
withBackground={false}
142-
withBorder={false}
143-
screenReaderLabel="burgir"
144-
onClick={hamburgerOnClick}
145-
// color={lti ? 'secondary' : 'primary-inverse'}
146-
>
147-
<IconHamburgerLine />
148-
</IconButton>
149-
<div style={{ minWidth: '100%' }}>
150-
<Breadcrumb label={breadcrumb.label}>
151-
{breadcrumb.links.map((link: any, index: any) =>
152-
link.href ? (
153-
<Breadcrumb.Link key={index} href={link.href}>
154-
{link.label}
155-
</Breadcrumb.Link>
156-
) : (
157-
<Breadcrumb.Link key={index}>{link.label}</Breadcrumb.Link>
158-
)
159-
)}
160-
</Breadcrumb>
161-
</div>
162-
</DesktopTopNav.Start>
163-
<DesktopTopNav.End>
164-
{buttons.map((button: any) => (
165-
<Button key={button.label} renderIcon={button.icon}>
166-
{button.label}
167-
</Button>
168-
))}
169-
</DesktopTopNav.End>
170-
</DesktopTopNav>
140+
<div style={{ display: showDesktopView ? 'block' : 'none' }}>
141+
<DesktopTopNav lightMode={lti}>
142+
<DesktopTopNav.Start>
143+
<IconButton
144+
withBackground={false}
145+
withBorder={false}
146+
screenReaderLabel={hamburgerLabel}
147+
onClick={hamburgerOnClick}
148+
// color={lti ? 'secondary' : 'primary-inverse'}
149+
>
150+
<IconHamburgerLine />
151+
</IconButton>
152+
<div style={{ minWidth: '100%' }}>
153+
<Breadcrumb label={breadcrumb.label}>
154+
{breadcrumb.links.map((link: any, index: any) =>
155+
link.href ? (
156+
<Breadcrumb.Link key={index} href={link.href}>
157+
{link.label}
158+
</Breadcrumb.Link>
159+
) : (
160+
<Breadcrumb.Link key={index}>{link.label}</Breadcrumb.Link>
161+
)
162+
)}
163+
</Breadcrumb>
164+
</div>
165+
</DesktopTopNav.Start>
166+
<DesktopTopNav.End>
167+
{buttons.map((button: any) => (
168+
<Button key={button.label} renderIcon={button.icon}>
169+
{button.label}
170+
</Button>
171+
))}
172+
</DesktopTopNav.End>
173+
</DesktopTopNav>
174+
</div>
171175
)
172176
}
173177

0 commit comments

Comments
 (0)