Skip to content

Commit

Permalink
feat(TopbarNav): add alignment prop
Browse files Browse the repository at this point in the history
  • Loading branch information
bfbiggs committed Jan 24, 2020
1 parent ed1e3da commit fe2577b
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 80 deletions.
2 changes: 1 addition & 1 deletion angular/src/lib/topbar/topbar-brand.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Component, Input } from '@angular/core';
selector: '[md-top-bar-brand]',
exportAs: 'mdTopbarBrand',
template: `
<div class="md-brand__logo">
<div class="md-brand__logo" [ngClass]="[title ? 'md-brand__logo--pad' : '']">
<img *ngIf="image" src="{{ image }}" alt="{{ alt }}" />
<i *ngIf="!image" [ngClass]="['icon', icon]"></i>
</div>
Expand Down
2 changes: 1 addition & 1 deletion core/scss/components/top-bar/examples/blue.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="md-top-bar__container">
<div class="md-top-bar__brand">
<a class="md-brand" href="/">
<div class="md-brand__logo">
<div class="md-brand__logo md-brand__logo--pad">
<!-- Note: use either image or icon, but not both -->
<!-- img src="/assets/spark-logo.svg" alt="Momentum UI" -->
<i class="icon icon-cisco-logo"></i>
Expand Down
2 changes: 1 addition & 1 deletion core/scss/components/top-bar/examples/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="md-top-bar__container">
<div class="md-top-bar__brand">
<a class="md-brand" href="/">
<div class="md-brand__logo">
<div class="md-brand__logo md-brand__logo--pad">
<!-- Note: use either image or icon, but not both -->
<!-- img src="/assets/spark-logo.svg" alt="Momentum UI" -->
<i class="icon icon-cisco-logo"></i>
Expand Down
2 changes: 1 addition & 1 deletion core/scss/components/top-bar/examples/light.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="md-top-bar__container">
<div class="md-top-bar__brand">
<a class="md-brand" href="/">
<div class="md-brand__logo">
<div class="md-brand__logo md-brand__logo--pad">
<!-- Note: use either image or icon, but not both -->
<!-- img src="/assets/spark-logo.svg" alt="Momentum UI" -->
<i class="icon icon-cisco-logo"></i>
Expand Down
15 changes: 11 additions & 4 deletions core/scss/components/top-bar/top-bar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,20 @@

&__nav {
display: none;
align-items: center;
justify-content: center;
flex: 2 0 auto;

.#{$list-item__class} {
padding: rem-calc(2) rem-calc(12);
}

@media #{$large-up} {
display: flex;
align-items: center;
justify-content: center;
flex: 2 0 auto;
}

&--right {
justify-content: flex-end;
}
}

Expand Down Expand Up @@ -155,9 +159,12 @@
display: flex;
width: auto;
height: $brand-image__size;
margin-right: rem-calc(12);
font-size: $brand-image__size;

&--pad {
margin-right: rem-calc(12);
}

@media #{$medium-only} {
height: $brand-image__size--medium;
font-size: $brand-image__size--medium;
Expand Down
9 changes: 6 additions & 3 deletions react/src/lib/ListSeparator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import React from 'react';
import PropTypes from 'prop-types';
import { prefix } from '../utils/index';

const ListSeparator = props => {
const {
Expand All @@ -15,10 +16,12 @@ const ListSeparator = props => {
...otherProps
} = props;

const lsClass = `${prefix}-list-separator`;

return (
<div
className={
'md-list-separator' +
`${lsClass}` +
`${className && ` ${className}` || ''}`
}
style={{
Expand All @@ -28,12 +31,12 @@ const ListSeparator = props => {
{...otherProps}
>

<span className="md-list-separator__container">
<span className={`${lsClass}__container`}>
{
children || text
&&
<span
className='md-list-separator__text'
className={`${lsClass}__text`}
style={{
...textColor && {color: textColor},
...textPadding && {padding: textPadding},
Expand Down
2 changes: 2 additions & 0 deletions react/src/lib/Topbar/examples/KitchenSink.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
TopbarBlue,
TopbarDark,
TopbarLight,
TopbarNavFlexRight,
TopbarNoMiddle
} from './index';

Expand All @@ -14,6 +15,7 @@ export default class TopbarKitchenSink extends React.Component {
<TopbarBlue />
<TopbarDark />
<TopbarLight />
<TopbarNavFlexRight />
<TopbarNoMiddle />
</React.Fragment>
);
Expand Down
61 changes: 61 additions & 0 deletions react/src/lib/Topbar/examples/NavFlexRight.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from 'react';
import {
Button,
Icon,
ListItem,
ListSeparator,
Topbar,
TopbarMobile,
TopbarNav,
TopbarRight,
} from '@momentum-ui/react';

export default class TopbarBlue extends React.Component {
render() {
return (
<Topbar
color='blue'
title='test'
brandAnchorElement={
<a
href='javascript:void(0)'
title='Momentum UI'
>
<Icon name='cisco-logo' />
</a>
}
>
<TopbarNav alignment='right'>
<ListItem separator>Develop</ListItem>
<ListItem>Styles</ListItem>
<ListSeparator direction='horizontal'/>
<ListItem>Layout</ListItem>
<ListItem>Navigation</ListItem>
</TopbarNav>
<TopbarRight>
<div className='md-top-bar__user' />
<div className='md-top-bar__logged-out'>
<a href='javascript:void(0)'>Log In</a>
<Button color='blue' ariaLabel='myAriaLabel'>
Button
</Button>
</div>
</TopbarRight>
<TopbarMobile shouldCloseOnClick={false}>
<a
href='javascript:void(0)'
title='Momentum UI'
>
<Icon name='cisco-logo' />
</a>
<ListItem>Develop</ListItem>
<ListItem>Styles</ListItem>
<ListItem>Layout</ListItem>
<ListItem>Navigation</ListItem>
</TopbarMobile>
</Topbar>
);
}
}
/* eslint-enable jsx-a11y/anchor-is-valid */
1 change: 1 addition & 0 deletions react/src/lib/Topbar/examples/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export { default as TopbarLight } from './Light';
export { default as TopbarDark } from './Dark';
export { default as TopbarBlue } from './Blue';
export { default as TopbarNavFlexRight } from './NavFlexRight';
export { default as TopbarNoMiddle } from './NoMiddle';
export { default as TopbarKitchenSink } from './KitchenSink';

17 changes: 13 additions & 4 deletions react/src/lib/Topbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,27 @@ class Topbar extends React.Component {

const topBarClass = `${prefix}-top-bar`;
const brandClass = `${prefix}-brand`;
const addPadding = (image || icon ) && title;

const brandNodeChildren = ([
<div className={`${brandClass}__logo`} key={`${brandClass}__logo`}>
<div
className={
`${brandClass}__logo` +
`${(addPadding && ` ${brandClass}__logo--pad`) || ''}`
}
key={`${brandClass}__logo`}
>
{
image
? image
: <i className={`icon ${icon}`} />
}
</div>,
<div className={`${brandClass}__title`} key={`${brandClass}__title`}>
{title}
</div>
...title && (
<div className={`${brandClass}__title`} key={`${brandClass}__title`}>
{title}
</div>
)
]);

const getBrandAnchor = () => (
Expand Down
74 changes: 10 additions & 64 deletions react/src/lib/Topbar/tests/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ ShallowWrapper {
className="icon icon-cisco-logo"
/>
</div>
<div
className="md-brand__title"
>
</div>
</a>
</div>
</div>,
Expand Down Expand Up @@ -76,11 +72,7 @@ ShallowWrapper {
className="icon icon-cisco-logo"
/>
</div>
<div
className="md-brand__title"
>
</div>
</a>
</div>,
null,
Expand All @@ -105,11 +97,7 @@ ShallowWrapper {
className="icon icon-cisco-logo"
/>
</div>
<div
className="md-brand__title"
>
</div>
</a>,
"className": "md-top-bar__brand",
},
Expand All @@ -127,11 +115,7 @@ ShallowWrapper {
className="icon icon-cisco-logo"
/>
</div>,
<div
className="md-brand__title"
>
</div>,
"",
],
"className": "md-brand",
"href": null,
Expand Down Expand Up @@ -162,18 +146,7 @@ ShallowWrapper {
},
"type": "div",
},
Object {
"instance": null,
"key": "md-brand__title",
"nodeType": "host",
"props": Object {
"children": "",
"className": "md-brand__title",
},
"ref": null,
"rendered": "",
"type": "div",
},
"",
],
"type": "a",
},
Expand Down Expand Up @@ -208,11 +181,7 @@ ShallowWrapper {
className="icon icon-cisco-logo"
/>
</div>
<div
className="md-brand__title"
>
</div>
</a>
</div>
</div>,
Expand Down Expand Up @@ -240,11 +209,7 @@ ShallowWrapper {
className="icon icon-cisco-logo"
/>
</div>
<div
className="md-brand__title"
>
</div>
</a>
</div>,
null,
Expand All @@ -269,11 +234,7 @@ ShallowWrapper {
className="icon icon-cisco-logo"
/>
</div>
<div
className="md-brand__title"
>
</div>
</a>,
"className": "md-top-bar__brand",
},
Expand All @@ -291,11 +252,7 @@ ShallowWrapper {
className="icon icon-cisco-logo"
/>
</div>,
<div
className="md-brand__title"
>
</div>,
"",
],
"className": "md-brand",
"href": null,
Expand Down Expand Up @@ -326,18 +283,7 @@ ShallowWrapper {
},
"type": "div",
},
Object {
"instance": null,
"key": "md-brand__title",
"nodeType": "host",
"props": Object {
"children": "",
"className": "md-brand__title",
},
"ref": null,
"rendered": "",
"type": "div",
},
"",
],
"type": "a",
},
Expand Down
Loading

0 comments on commit fe2577b

Please sign in to comment.