Skip to content

Commit

Permalink
Fix misaligned header items
Browse files Browse the repository at this point in the history
  • Loading branch information
mrseanbaines committed May 19, 2020
1 parent 214cea2 commit b553e5a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
6 changes: 6 additions & 0 deletions src/components/header/header.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ export default {
export const Default = () => <Header title='Transactions' />

export const WithSubtitle = () => <Header title='Transactions' subtitle='April 2020' />

export const WithFilters = () => <Header title='Transactions' withFilters />

export const WithDateSelect = () => <Header title='Transactions' withDateSelect />

export const WithFiltersAndDateSelect = () => <Header title='Transactions' withFilters withDateSelect />
12 changes: 10 additions & 2 deletions src/components/header/header.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ import styled, { css } from 'styled-components'
export const Wrapper = styled.header(({ theme }) => {
return css`
background: ${theme.colors.background.muted};
display: flex;
justify-content: space-between;
align-items: center;
padding: ${theme.space[3]} ${theme.space[4]};
display: grid;
grid-template-columns: 1fr auto 1fr;
*:nth-child(2) {
justify-self: center;
}
*:nth-child(3) {
justify-self: end;
}
`
})

Expand Down
24 changes: 14 additions & 10 deletions src/components/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,26 @@ const Header: React.FC<Props> = ({
onDateSelectClick,
}) => (
<s.Wrapper>
{withFilters && (
<s.Button onClick={onFiltersClick}>
<FiltersIcon />
</s.Button>
)}
<div>
{withFilters && (
<s.Button onClick={onFiltersClick}>
<FiltersIcon />
</s.Button>
)}
</div>

<s.CenterSection>
<s.Title>{title}</s.Title>
{subtitle && <s.Subtitle>{subtitle}</s.Subtitle>}
</s.CenterSection>

{withDateSelect && (
<s.Button onClick={onDateSelectClick}>
<CalendarIcon />
</s.Button>
)}
<div>
{withDateSelect && (
<s.Button onClick={onDateSelectClick}>
<CalendarIcon />
</s.Button>
)}
</div>
</s.Wrapper>
)

Expand Down

0 comments on commit b553e5a

Please sign in to comment.