Fixed Navbar bugs

- Links having a <a> in a <a>
- UserMenu links eing squished together

Signed-off-by: Florian BOUILLON <florian.bouillon@delta-wings.net>
This commit is contained in:
Florian Bouillon 2021-04-14 15:50:51 +02:00
parent cfd33ab0d6
commit fe17d4687b
3 changed files with 29 additions and 14 deletions

View File

@ -56,7 +56,6 @@
position fixed position fixed
top 70px top 70px
right 0 right 0
padding 16px
border-bottom-left-radius 4px border-bottom-left-radius 4px
transform translateX(100%) transform translateX(100%)
background inherit background inherit
@ -216,15 +215,20 @@
margin 0 margin 0
padding 0 padding 0
.userMenu a .userMenu
padding 16px 0 padding 8px 16px
a
display inline-block
padding-bottom 16px
.mobileMenu .mobileMenu
opacity 0 opacity 0
transition opacity $transition transition opacity $transition
pointer-events none
&.shown &.shown
opacity 1 opacity 1
pointer-events initial
.mainGradient .mainGradient
//WIP //WIP

View File

@ -1,6 +1,8 @@
import { Meta, Story } from '@storybook/react/types-6-0' import { Meta, Story } from '@storybook/react/types-6-0'
import React from 'react' import React from 'react'
import { Zap, ZapOff } from 'react-feather'
import Component from '.' import Component from '.'
import Text from '../Text'
export default { export default {
title: 'DZEIO/Navbar', title: 'DZEIO/Navbar',
@ -9,13 +11,10 @@ export default {
export const Basic: Story<any> = (args: any) => <Component {...args} /> export const Basic: Story<any> = (args: any) => <Component {...args} />
Basic.args = { Basic.args = {
items: [{ type: 'navbar',
path: '/dashboard', logo: {src: '/90-38.svg', width: 90, height: 38},
name: 'Dasboard'
}],
loginUrl: '/login', loginUrl: '/login',
registerUrl: '/register', registerUrl: '/register',
type: 'navbar',
user: { user: {
name: 'Username', name: 'Username',
description: 'User Description', description: 'User Description',
@ -23,8 +22,20 @@ Basic.args = {
links: [{ links: [{
path: '/logout', path: '/logout',
name: 'Logout' name: 'Logout'
}] }, {
path: '/logout',
name: 'Logout'
}],
informations: (<Text>Testing :D</Text>)
} }
}, },
logo: {src: '/90-38.svg', width: 90, height: 38} items: [{
path: '/dashboard',
name: 'Dasboard',
icon: Zap
}, {
path: '/dashboard',
name: 'Dasboard',
icon: ZapOff
}],
} }

View File

@ -82,7 +82,7 @@ interface State {
/** /**
* Navbar/Sidebar Component * Navbar/Sidebar Component
* @version 1.0.2 * @version 1.0.3
*/ */
export default class Navbar extends React.Component<Props, State> { export default class Navbar extends React.Component<Props, State> {
@ -186,14 +186,14 @@ export default class Navbar extends React.Component<Props, State> {
)} )}
<ul> <ul>
{!this.state.isMobile && this.props.items.map((item) => ( {!this.state.isMobile && this.props.items.map((item) => (
<li key={item.path}><Link noStyle href={item.path}><a> <li key={item.path}><Link noStyle href={item.path}>
<Text className={buildClassName([css.active, this.state.path?.startsWith(item.path)])}> <Text className={buildClassName([css.active, this.state.path?.startsWith(item.path)])}>
{this.getType() === 'sidebar' && item.icon && ( {this.getType() === 'sidebar' && item.icon && (
<item.icon /> <item.icon />
)} )}
<span>{item.name}</span> <span>{item.name}</span>
</Text> </Text>
</a></Link></li> </Link></li>
))} ))}
</ul> </ul>
<div style={{flex: 1}}></div> <div style={{flex: 1}}></div>
@ -224,7 +224,7 @@ export default class Navbar extends React.Component<Props, State> {
</div> </div>
</div> </div>
<div className={buildClassName(css.userMenu, [css.menuActive, !this.state.isMobile && this.state.menuActive])}> <div className={buildClassName(css.userMenu, [css.menuActive, !this.state.isMobile && this.state.menuActive])}>
<Row nomargin={this.getType() === 'navbar'}> <Row nomargin>
{this.props.user.menu?.informations && ( {this.props.user.menu?.informations && (
<Col>{this.props.user.menu?.informations}</Col> <Col>{this.props.user.menu?.informations}</Col>
)} )}