-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[KED-2872] Create global toolbar UI #576
Merged
tynandebold
merged 6 commits into
experiment-tracking/single-view-journey-1
from
feature/create-global-toolbar-ui#ked-2872
Oct 1, 2021
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
563d04a
adds in the global toolbar component; moves settings and theme button…
tynandebold 507e4a2
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold aaff24f
adds new logo icons for kedro, pipeline, and experiments and adds the…
tynandebold 5b6f701
adds new test file for global-toolbar; updates primary-toolbar tests
tynandebold bac8e14
updates icon styles and order; removes unnecessary tests and initial …
tynandebold 17b62eb
removes two unneeded App propTypes
tynandebold File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -129,4 +129,4 @@ | |
"not op_mini all" | ||
], | ||
"snyk": true | ||
} | ||
} |
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
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
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
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
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,45 @@ | ||
@import '../../styles/variables'; | ||
@import '../../styles/extends'; | ||
|
||
.pipeline-global-toolbar { | ||
background: var(--color-global-toolbar-background); | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
left: 0; | ||
position: absolute; | ||
top: 0; | ||
width: $global-toolbar-width; | ||
z-index: 5; | ||
} | ||
|
||
.pipeline-global-routes-toolbar { | ||
@extend %listReset; | ||
} | ||
|
||
.pipeline-global-control-toolbar { | ||
@extend %listReset; | ||
|
||
margin-top: auto; | ||
} | ||
|
||
.pipeline-menu-button--large { | ||
height: $global-toolbar-width; | ||
width: $global-toolbar-width; | ||
} | ||
|
||
.pipeline-menu-button--link { | ||
&:hover { | ||
background-color: var(--color-bg-2); | ||
} | ||
} | ||
|
||
.pipeline-menu-button--logo { | ||
margin-bottom: 40px; | ||
|
||
svg { | ||
height: 2.9em; | ||
opacity: 1; | ||
width: 2.9em; | ||
} | ||
} |
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,71 @@ | ||
import React from 'react'; | ||
import ConnectedGlobalToolbar, { | ||
GlobalToolbar, | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
} from './index'; | ||
import { mockState, setup } from '../../utils/state.mock'; | ||
|
||
describe('GlobalToolbar', () => { | ||
it('renders without crashing', () => { | ||
const wrapper = setup.mount(<ConnectedGlobalToolbar />); | ||
expect(wrapper.find('.pipeline-icon-toolbar__button').length).toBe(5); | ||
}); | ||
|
||
const functionCalls = [ | ||
['.pipeline-menu-button--theme', 'onToggleTheme'], | ||
['.pipeline-menu-button--settings', 'onToggleSettingsModal'], | ||
]; | ||
|
||
test.each(functionCalls)( | ||
'calls %s function on %s button click', | ||
(selector, callback) => { | ||
const mockFn = jest.fn(); | ||
const props = { | ||
theme: mockState.animals.theme, | ||
visible: mockState.animals.visible, | ||
[callback]: mockFn, | ||
}; | ||
const wrapper = setup.mount(<GlobalToolbar {...props} />); | ||
expect(mockFn.mock.calls.length).toBe(0); | ||
wrapper.find(selector).find('button').simulate('click'); | ||
expect(mockFn.mock.calls.length).toBe(1); | ||
} | ||
); | ||
|
||
it('maps state to props', () => { | ||
const expectedResult = { | ||
theme: expect.stringMatching(/light|dark/), | ||
visible: expect.objectContaining({ | ||
exportBtn: expect.any(Boolean), | ||
exportModal: expect.any(Boolean), | ||
plotModal: expect.any(Boolean), | ||
settingsModal: expect.any(Boolean), | ||
labelBtn: expect.any(Boolean), | ||
layerBtn: expect.any(Boolean), | ||
sidebar: expect.any(Boolean), | ||
}), | ||
}; | ||
expect(mapStateToProps(mockState.animals)).toEqual(expectedResult); | ||
}); | ||
|
||
describe('mapDispatchToProps', () => { | ||
it('onToggleTheme', () => { | ||
const dispatch = jest.fn(); | ||
mapDispatchToProps(dispatch).onToggleTheme('light'); | ||
expect(dispatch.mock.calls[0][0]).toEqual({ | ||
theme: 'light', | ||
type: 'TOGGLE_THEME', | ||
}); | ||
}); | ||
|
||
it('onToggleSettingsModal', () => { | ||
const dispatch = jest.fn(); | ||
mapDispatchToProps(dispatch).onToggleSettingsModal(true); | ||
expect(dispatch.mock.calls[0][0]).toEqual({ | ||
visible: true, | ||
type: 'TOGGLE_SETTINGS_MODAL', | ||
}); | ||
}); | ||
}); | ||
}); |
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,90 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { toggleSettingsModal, toggleTheme } from '../../actions'; | ||
import ExperimentsIcon from '../icons/experiments'; | ||
import IconButton from '../icon-button'; | ||
import LogoIcon from '../icons/logo'; | ||
import SettingsIcon from '../icons/settings'; | ||
import ThemeIcon from '../icons/theme'; | ||
import TreeIcon from '../icons/tree'; | ||
|
||
import './global-toolbar.css'; | ||
|
||
/** | ||
* Main controls for filtering the chart data | ||
* @param {Function} onToggleTheme Handle toggling theme between light/dark | ||
* @param {string} theme Kedro UI light/dark theme | ||
*/ | ||
export const GlobalToolbar = ({ | ||
onToggleSettingsModal, | ||
onToggleTheme, | ||
theme, | ||
visible, | ||
}) => { | ||
return ( | ||
<> | ||
<div className="pipeline-global-toolbar"> | ||
<ul className="pipeline-global-routes-toolbar kedro"> | ||
<IconButton | ||
ariaLabel={'Kedro Viz logo and link'} | ||
className={'pipeline-menu-button--logo pipeline-menu-button--large'} | ||
disabled={false} | ||
icon={LogoIcon} | ||
/> | ||
<IconButton | ||
ariaLabel={'View your pipeline'} | ||
className={'pipeline-menu-button--large pipeline-menu-button--link'} | ||
disabled={false} | ||
icon={TreeIcon} | ||
/> | ||
<IconButton | ||
ariaLabel={'View your experiments'} | ||
className={'pipeline-menu-button--large pipeline-menu-button--link'} | ||
disabled={false} | ||
icon={ExperimentsIcon} | ||
/> | ||
</ul> | ||
<ul className="pipeline-global-control-toolbar kedro"> | ||
<IconButton | ||
ariaLive="polite" | ||
ariaLabel={`Change to ${ | ||
theme === 'light' ? 'dark' : 'light' | ||
} theme`} | ||
className={ | ||
'pipeline-menu-button--theme pipeline-menu-button--large' | ||
} | ||
onClick={() => onToggleTheme(theme === 'light' ? 'dark' : 'light')} | ||
icon={ThemeIcon} | ||
labelText="Toggle theme" | ||
/> | ||
<IconButton | ||
ariaLabel={'Change the settings flags'} | ||
className={ | ||
'pipeline-menu-button--settings pipeline-menu-button--large' | ||
} | ||
onClick={() => onToggleSettingsModal(true)} | ||
icon={SettingsIcon} | ||
disabled={false} | ||
labelText={'Settings'} | ||
/> | ||
</ul> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export const mapStateToProps = (state) => ({ | ||
theme: state.theme, | ||
visible: state.visible, | ||
}); | ||
|
||
export const mapDispatchToProps = (dispatch) => ({ | ||
onToggleSettingsModal: (value) => { | ||
dispatch(toggleSettingsModal(value)); | ||
}, | ||
onToggleTheme: (value) => { | ||
dispatch(toggleTheme(value)); | ||
}, | ||
}); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(GlobalToolbar); |
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 |
---|---|---|
|
@@ -41,8 +41,8 @@ | |
} | ||
|
||
svg { | ||
width: 1.8em; | ||
height: 1.8em; | ||
width: 2.175em; | ||
height: 2.175em; | ||
} | ||
} | ||
|
||
|
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,9 @@ | ||
import React from 'react'; | ||
|
||
const ExperimentsIcon = ({ className }) => ( | ||
<svg className={className} viewBox="0 0 24 24"> | ||
<path d="M13 10V6h-2v4l-.766 2-.83 1.66 4.571-1.225-.218-.435L13 10zm1.889 4.261-6.68 1.79L7.235 18h9.526l-1.872-3.739zM20 20H4l4.999-10H9V6H8V4h8v2h-1v4h-.007L20 20z" /> | ||
</svg> | ||
); | ||
|
||
export default ExperimentsIcon; |
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,15 @@ | ||
import React from 'react'; | ||
|
||
const LogoIcon = ({ className }) => ( | ||
<svg className={className} viewBox="24 25 32 30"> | ||
<path | ||
d="M40 25.414 54.586 40 40 54.586 25.414 40 40 25.414z" | ||
fill="none" | ||
fillRule="evenodd" | ||
stroke="#FFBC00" | ||
strokeWidth="2" | ||
/> | ||
</svg> | ||
); | ||
|
||
export default LogoIcon; |
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
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,9 @@ | ||
import React from 'react'; | ||
|
||
const TreeIcon = ({ className }) => ( | ||
<svg className={className} viewBox="0 0 24 24"> | ||
<path d="M12 2a3 3 0 0 1 2.16 5.082l4.47 8.94a3 3 0 1 1-1.79.895l-4.469-8.94a3.03 3.03 0 0 1-.742 0l-4.47 8.94a3 3 0 1 1-1.789-.895l4.47-8.94A3 3 0 0 1 12 2z" /> | ||
</svg> | ||
); | ||
|
||
export default TreeIcon; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice one!