Skip to content

Commit 282caa2

Browse files
committed
WIP(ui-top-nav-bar): improve types
1 parent 6dc072c commit 282caa2

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,20 @@ import { jsx, useTheme } from '@instructure/emotion'
2828

2929
import { generateStyles } from './styles'
3030
import { Link } from '@instructure/ui-link'
31+
import { SubNavProps, MenuItem } from './props'
3132

3233
/**
3334
---
3435
category: components
3536
---
3637
**/
37-
const SubNav = ({ menuItems, styles }: any) => {
38+
const SubNav = ({ menuItems, styles }: SubNavProps) => {
3839
return (
3940
<div style={styles.container}>
40-
{menuItems.map((item: any) => (
41-
<div style={styles.linkContainer(item)} key={item}>
41+
{menuItems.map((item: MenuItem) => (
42+
<div style={styles.linkContainer(item)} key={item.title}>
4243
<Link
43-
key={item}
44+
key={item.title}
4445
href={item.href}
4546
themeOverride={styles.link(item)}
4647
isWithinText={false}

packages/ui-top-nav-bar/src/SubNav/props.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,31 @@
2222
* SOFTWARE.
2323
*/
2424

25-
import type { ReactNode, PropsWithChildren } from 'react'
25+
type MenuItem = {
26+
href: string
27+
title: string
28+
selected: boolean
29+
onClick?: () => void
30+
}
2631

2732
type SubNavOwnProps = {
28-
lightMode?: boolean
29-
brand?: ReactNode
33+
menuItems: MenuItem[]
3034
}
3135

3236
type SubNavStyle = {
3337
container: {
3438
[key: string]: string | number
3539
}
36-
content: (open: boolean) => {
37-
[key: string]: string | number
38-
}
39-
topBar: {
40+
linkContainer: (item: MenuItem) => {
4041
[key: string]: string | number
4142
}
42-
btnRow: {
43+
link: (item: MenuItem) => {
4344
[key: string]: string | number
4445
}
4546
}
4647

4748
type SubNavProps = SubNavOwnProps & {
4849
styles: SubNavStyle
49-
} & PropsWithChildren
50+
}
5051

51-
export type { SubNavProps, SubNavOwnProps }
52+
export type { SubNavProps, SubNavOwnProps, MenuItem }

0 commit comments

Comments
 (0)