Skip to content
Snippets Groups Projects
Commit 570bbfb5 authored by Tamlyn Rhodes's avatar Tamlyn Rhodes
Browse files

Update AppBar styling and API

Add prop for injecting main nav links
Expect user object instead of username
Expect logout callback instead of link
Rename brandName prop to brand
parent 851b61d5
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ import Icon from '../atoms/Icon' ...@@ -6,7 +6,7 @@ import Icon from '../atoms/Icon'
const AppBar = ({ const AppBar = ({
brandLink = '/', brandLink = '/',
brandName, brand,
loginLink = '/login', loginLink = '/login',
onLogoutClick, onLogoutClick,
navLinks, navLinks,
...@@ -15,9 +15,11 @@ const AppBar = ({ ...@@ -15,9 +15,11 @@ const AppBar = ({
}) => ( }) => (
<nav className={classnames(classes.root, className)}> <nav className={classnames(classes.root, className)}>
<div className={classes.section}> <div className={classes.section}>
<Link className={classes.logo} to={brandLink}> {brand && (
{brandName} <Link className={classes.logo} to={brandLink}>
</Link> {brand}
</Link>
)}
{navLinks && <div className={classes.navLinks}>{navLinks}</div>} {navLinks && <div className={classes.navLinks}>{navLinks}</div>}
</div> </div>
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
} }
.navLinks { .navLinks {
align-items: center;
display: flex; display: flex;
margin: 0 1rem; margin: 0 1rem;
......
...@@ -4,25 +4,25 @@ It displays the name of the application (as a link to the home page), the ...@@ -4,25 +4,25 @@ It displays the name of the application (as a link to the home page), the
username of the current user, and a link to sign out. username of the current user, and a link to sign out.
```js ```js
<AppBar brandName="xpub" user={{ username: 'user', admin: true }} /> <AppBar brand="xpub" user={{ username: 'user', admin: true }} />
``` ```
When the user is not signed in, only the login link is displayed. When the user is not signed in, only the login link is displayed.
```js ```js
<AppBar brandName="xpub" /> <AppBar brand="xpub" />
``` ```
Can optionally pass navigation links or image for brand. Can optionally pass navigation links or image for brand.
```js ```js
<AppBar <AppBar
brandName={ brand={
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="-150 -50 300 350" viewBox="-150 -50 300 300"
width="50" width="50"
height="50" height="42"
fillOpacity="0.5" fillOpacity="0.5"
> >
<circle cx="0" cy="50" fill="red" r="100" /> <circle cx="0" cy="50" fill="red" r="100" />
......
...@@ -5,7 +5,7 @@ import renderer from 'react-test-renderer' ...@@ -5,7 +5,7 @@ import renderer from 'react-test-renderer'
import AppBar from '../src/molecules/AppBar' import AppBar from '../src/molecules/AppBar'
const baseProps = { const baseProps = {
brandName: 'some brand', brand: 'some brand',
onLogoutClick: () => {}, onLogoutClick: () => {},
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment