Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
fix(button toolbar): align buttons to the right in the toolbar
Browse files Browse the repository at this point in the history
fix #1852
  • Loading branch information
oliv37 committed Feb 28, 2020
1 parent 3068090 commit 9b2e721
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/__tests__/page-header/ButtonToolBar.test.tsx
Expand Up @@ -19,9 +19,18 @@ describe('Button Tool Bar', () => {
jest.spyOn(ButtonBarProvider, 'useButtons')
mocked(ButtonBarProvider).useButtons.mockReturnValue(buttons)

const wrapper = mount(<ButtonToolBar />)
const wrapper = mount(<ButtonToolBar />).find('.button-toolbar')

expect(wrapper.childAt(0).getElement()).toEqual(buttons[0])
expect(wrapper.childAt(1).getElement()).toEqual(buttons[1])
})

it('should return null when there is no button in the provider', () => {
jest.spyOn(ButtonBarProvider, 'useButtons')
mocked(ButtonBarProvider).useButtons.mockReturnValue([])

const wrapper = mount(<ButtonToolBar />)

expect(wrapper.html()).toBeNull()
})
})
4 changes: 4 additions & 0 deletions src/index.css
Expand Up @@ -93,3 +93,7 @@ code {
padding: 0;
background-color: white;
}

.button-toolbar > button {
margin-left: .5rem;
}
7 changes: 6 additions & 1 deletion src/page-header/ButtonToolBar.tsx
Expand Up @@ -3,7 +3,12 @@ import { useButtons } from './ButtonBarProvider'

const ButtonToolBar = () => {
const buttons = useButtons()
return <>{buttons.map((button) => button)}</>

if (buttons.length === 0) {
return null
}

return <div className="button-toolbar">{buttons.map((button) => button)}</div>
}

export default ButtonToolBar

0 comments on commit 9b2e721

Please sign in to comment.