-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core/nav): Add sections for vertical nav (#8162)
* feat(core/nav): Add nav sections * feat(core/nav): Css for nav sections * feat(core/nav): Unit tests * feat(core/nav): Update tests * Move css to stylguide classes
- Loading branch information
1 parent
21488bc
commit 6833559
Showing
3 changed files
with
97 additions
and
36 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
app/scripts/modules/core/src/application/nav/NavSection.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import { | ||
mockLoadBalancerDataSourceConfig, | ||
mockPipelineDataSourceConfig, | ||
mockServerGroupDataSourceConfig, | ||
} from '@spinnaker/mocks'; | ||
import { ApplicationModelBuilder } from '../../application'; | ||
import { NavSection } from './NavSection'; | ||
|
||
describe('NavCategory', () => { | ||
it('should render multiple categories', () => { | ||
const app = ApplicationModelBuilder.createApplicationForTests( | ||
'testapp', | ||
mockPipelineDataSourceConfig, | ||
mockLoadBalancerDataSourceConfig, | ||
mockServerGroupDataSourceConfig, | ||
); | ||
|
||
const wrapper = shallow(<NavSection app={app} categories={app.dataSources} activeCategoryName="Pipelines" />); | ||
const nodes = wrapper.children(); | ||
expect(nodes.length).toEqual(3); | ||
}); | ||
|
||
it('should not render if no categories', () => { | ||
const app = ApplicationModelBuilder.createApplicationForTests('testapp'); | ||
|
||
const wrapper = shallow(<NavSection app={app} categories={[]} activeCategoryName="" />); | ||
const nodes = wrapper.children(); | ||
expect(nodes.length).toEqual(0); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
app/scripts/modules/core/src/application/nav/NavSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import { NavRoute } from './NavRoute'; | ||
|
||
import { ApplicationDataSource } from '../service/applicationDataSource'; | ||
import { Application } from '../application.model'; | ||
|
||
export interface INavigationSectionProps { | ||
categories: ApplicationDataSource[]; | ||
activeCategoryName: string; | ||
app: Application; | ||
} | ||
|
||
export const NavSection = ({ activeCategoryName, app, categories }: INavigationSectionProps) => ( | ||
<div className="nav-section sp-padding-s-yaxis text-semibold"> | ||
{categories.map(category => ( | ||
<NavRoute key={category.label} category={category} app={app} isActive={category.label === activeCategoryName} /> | ||
))} | ||
</div> | ||
); |
81 changes: 45 additions & 36 deletions
81
app/scripts/modules/core/src/application/nav/verticalNav.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,53 @@ | ||
.nav-category { | ||
color: var(--color-accent); | ||
padding-left: 40px; | ||
.nav-section { | ||
font-size: 14px; | ||
text-transform: uppercase; | ||
|
||
.badge-none { | ||
min-width: 18px; | ||
margin-right: 8px; | ||
} | ||
|
||
.badge-running-count { | ||
min-width: 18px; | ||
margin-right: 8px; | ||
border-radius: 3px; | ||
color: var(--color-white); | ||
background-color: var(--color-primary); | ||
padding: 3px; | ||
line-height: 14px; | ||
text-align: center; | ||
@media (max-width: 1400px) { | ||
font-size: 10px; | ||
.nav-category { | ||
color: var(--color-accent); | ||
padding-left: 40px; | ||
|
||
.badge-none { | ||
min-width: 18px; | ||
margin-right: 8px; | ||
} | ||
|
||
.badge-running-count { | ||
min-width: 18px; | ||
margin-right: 8px; | ||
border-radius: 3px; | ||
color: var(--color-white); | ||
background-color: var(--color-primary); | ||
padding: 3px; | ||
line-height: 14px; | ||
text-align: center; | ||
@media (max-width: 1400px) { | ||
font-size: 10px; | ||
} | ||
} | ||
|
||
.nav-item { | ||
min-width: 16px; | ||
margin-right: 8px; | ||
line-height: 10px; | ||
} | ||
} | ||
|
||
.nav-item { | ||
min-width: 16px; | ||
margin-right: 8px; | ||
line-height: 10px; | ||
a { | ||
text-decoration: none; | ||
} | ||
} | ||
|
||
a { | ||
text-decoration: none; | ||
} | ||
|
||
.active { | ||
.nav-category { | ||
background: var(--color-accessory-light); | ||
color: var(--color-primary); | ||
.active { | ||
.nav-category { | ||
background: var(--color-accessory-light); | ||
color: var(--color-primary); | ||
} | ||
.nav-icon { | ||
color: var(--color-primary); | ||
} | ||
} | ||
} | ||
|
||
.nav-icon { | ||
color: var(--color-primary); | ||
} | ||
.nav-section:not(:first-of-type):not(:last-of-type) { | ||
border-top: 1px solid var(--color-white); | ||
} |