Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit e7abf72

Browse files
committed
fix(navbar): fix-navbar-mistakes
fix #148
1 parent 88fa66f commit e7abf72

3 files changed

Lines changed: 14 additions & 18 deletions

File tree

src/components/Navbar/Navbar.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface Props extends React.Props<any> {
1616
navLinks: NavLink[]
1717
/** Determines the hospital/clinic name to be shown at the navbar */
1818
brand: Brand
19-
/** Defines the button variant. By default is 'primary ' */
19+
/** Defines the properties of the search element */
2020
search: Search
2121
}
2222

@@ -49,7 +49,7 @@ const Navbar = (props: Props) => {
4949
}
5050
return (
5151
<NavbarRB bg={bg} variant={variant}>
52-
<NavbarRB.Brand href={brand.href} onClick={brand.onClick} style={{ cursor: 'pointer' }}>
52+
<NavbarRB.Brand onClick={brand.onClick} style={{ cursor: 'pointer' }}>
5353
{brand.src ? (
5454
<img
5555
alt={brand.label}
@@ -69,12 +69,12 @@ const Navbar = (props: Props) => {
6969
<Form inline>
7070
<FormControl
7171
type="text"
72-
placeholder={search.placeholderText}
72+
placeholder={search.placeholderText || 'Search'}
7373
className="mr-sm-2"
7474
onChange={search.onChangeInput}
7575
/>
76-
<Button color={search.buttonColor} onClick={search.onClickButton}>
77-
{search.buttonText}
76+
<Button color={search.buttonColor || 'primary'} onClick={search.onClickButton}>
77+
{search.buttonText || 'Search'}
7878
</Button>
7979
</Form>
8080
</Nav>

src/components/Navbar/interfaces.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@ export interface Brand {
33
label: string
44
/** Label color */
55
color?: string
6-
/** Determina the href */
7-
href?: string
86
/** A path which contain the company icon/image */
97
src?: string
10-
/** A click handle which will redirect the user to the respectivel webpage/path */
11-
onClick?: (event: React.MouseEvent<any>) => void
8+
/** A click handle which will redirect the user to the respectable webpage/path */
9+
onClick: (event: React.MouseEvent<any>) => void
1210
}
1311

1412
export interface NavLinkElement {
1513
/** The link name */
1614
label: string
1715
/** A click handle which will redirect the user to whenever it is clicked */
1816
onClick: (event: React.MouseEvent<any>) => void
19-
/** Determina the href */
17+
/** Determines the href */
2018
href?: string
2119
}
2220

@@ -27,9 +25,9 @@ export interface NavLink extends NavLinkElement {
2725

2826
export interface Search {
2927
/** Defines the placeholder text. */
30-
placeholderText?: string | 'Search'
28+
placeholderText?: string
3129
/** Defines the button text. */
32-
buttonText?: string | 'Search'
30+
buttonText?: string
3331
/** Defines the button variant. */
3432
buttonColor?:
3533
| 'primary'
@@ -41,7 +39,7 @@ export interface Search {
4139
| 'light'
4240
| 'dark'
4341
/** Handles the on click search button event */
44-
onClickButton?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
42+
onClickButton: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
4543
/** Handles the on change search form event */
4644
onChangeInput?: (event: React.ChangeEvent<HTMLInputElement>) => void
4745
}

stories/navbar.stories.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ storiesOf('Navbar', module)
2121
},
2222
}}
2323
search={{
24-
placeholderText: 'Test',
25-
buttonText: 'Search',
24+
placeholderText: 'Custom',
25+
buttonText: 'Text',
26+
buttonColor: 'secondary',
2627
onClickButton: () => {
2728
Toast('success', 'Button clicked!!', 'Success')
2829
},
@@ -46,16 +47,13 @@ storiesOf('Navbar', module)
4647
<Navbar
4748
brand={{
4849
label: 'HospitalRun',
49-
href: '/',
5050
src:
5151
'https://raw.githubusercontent.com/HospitalRun/hospitalrun.github.io/master/favicon.png',
5252
onClick: () => {
5353
Toast('success', 'Brand button clicked!!', 'Success')
5454
},
5555
}}
5656
search={{
57-
placeholderText: 'Search',
58-
buttonText: 'Search',
5957
onClickButton: () => {
6058
Toast('success', 'Button clicked!!', 'Success')
6159
},

0 commit comments

Comments
 (0)