Skip to content
Snippets Groups Projects
Commit c0612835 authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

feat(visual): dashboard header

parent 8d536a60
No related branches found
No related tags found
1 merge request!43Sprint #19
import { isNumber } from 'lodash'
import styled from 'styled-components' import styled from 'styled-components'
import { th } from '@pubsweet/ui-toolkit' import { th } from '@pubsweet/ui-toolkit'
...@@ -5,7 +6,7 @@ export default styled.div.attrs({ ...@@ -5,7 +6,7 @@ export default styled.div.attrs({
'data-test-id': props => props['data-test-id'] || 'item', 'data-test-id': props => props['data-test-id'] || 'item',
})` })`
display: flex; display: flex;
flex: ${({ flex }) => flex || 1}; flex: ${({ flex }) => (isNumber(flex) ? flex : 1)};
flex-direction: ${({ vertical }) => (vertical ? 'column' : 'row')}; flex-direction: ${({ vertical }) => (vertical ? 'column' : 'row')};
justify-content: ${({ centered }) => (centered ? 'center' : 'initial')}; justify-content: ${({ centered }) => (centered ? 'center' : 'initial')};
margin-right: ${({ withRightMargin }) => margin-right: ${({ withRightMargin }) =>
......
import { get } from 'lodash' import { get } from 'lodash'
import styled, { css } from 'styled-components'
import { th } from '@pubsweet/ui-toolkit' import { th } from '@pubsweet/ui-toolkit'
import styled, { css } from 'styled-components'
export default styled.div.attrs({ export default styled.div.attrs({
'data-test-id': props => props['data-test-id'] || 'row', 'data-test-id': props => props['data-test-id'] || 'row',
})` })`
align-items: ${props => get(props, 'alignItems', 'flex-start')}; align-items: ${props => get(props, 'alignItems', 'flex-start')};
background-color: ${props => props.bgColor || 'transparent'};
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: ${({ justify }) => justify || 'space-evenly'}; justify-content: ${({ justify }) => justify || 'space-evenly'};
......
export { default as Row } from './Row'
export { default as Item } from './Item'
...@@ -16,3 +16,4 @@ export { default as Text } from './Text' ...@@ -16,3 +16,4 @@ export { default as Text } from './Text'
// modals // modals
export * from './modals' export * from './modals'
export * from './gridItems'
import React from 'react' import React from 'react'
import { Button } from '@pubsweet/ui'
import styled from 'styled-components' import styled from 'styled-components'
import { th } from '@pubsweet/ui-toolkit' import { Button, H1 } from '@pubsweet/ui'
import { compose, withProps } from 'recompose' import { compose, withProps } from 'recompose'
import { Row } from 'pubsweet-component-faraday-ui'
import { DashboardItems, DashboardFilters } from './' import { DashboardItems, DashboardFilters } from './'
...@@ -16,19 +16,17 @@ const Dashboard = ({ ...@@ -16,19 +16,17 @@ const Dashboard = ({
getDefaultFilterValue, getDefaultFilterValue,
}) => ( }) => (
<Root className="dashboard"> <Root className="dashboard">
<Header> <Row alignItems="center" justify="space-between">
<Heading>Manuscripts</Heading> <H1>Dashboard</H1>
<HeaderButtons> <Button
<Button data-test="new-manuscript"
data-test="new-manuscript" disabled={!canCreateDraft}
disabled={!canCreateDraft} onClick={createDraftSubmission}
onClick={createDraftSubmission} primary
primary >
> New
New </Button>
</Button> </Row>
</HeaderButtons>
</Header>
<DashboardFilters <DashboardFilters
changeFilterValue={changeFilterValue} changeFilterValue={changeFilterValue}
getDefaultFilterValue={getDefaultFilterValue} getDefaultFilterValue={getDefaultFilterValue}
...@@ -53,19 +51,4 @@ const Root = styled.div` ...@@ -53,19 +51,4 @@ const Root = styled.div`
min-height: 50vh; min-height: 50vh;
overflow: auto; overflow: auto;
` `
const Header = styled.div`
display: flex;
justify-content: space-between;
`
const Heading = styled.div`
color: ${th('colorPrimary')};
font-size: 1.6em;
text-transform: uppercase;
`
const HeaderButtons = styled.div`
display: flex;
`
// #endregion // #endregion
import React from 'react' import React from 'react'
import { Menu } from '@pubsweet/ui' import { Menu } from '@pubsweet/ui'
import styled from 'styled-components'
import { th } from '@pubsweet/ui-toolkit' import { th } from '@pubsweet/ui-toolkit'
import { compose, withHandlers } from 'recompose' import { compose, withHandlers } from 'recompose'
import { Row, Item, Text, Label } from 'pubsweet-component-faraday-ui'
const DashboardFilters = ({ const DashboardFilters = ({
getFilterOptions, getFilterOptions,
changeFilterValue, changeFilterValue,
getDefaultFilterValue, getDefaultFilterValue,
}) => ( }) => (
<FiltersContainer> <Row alignItems="flex-end" justify="flex-start">
<span>Filter view:</span> <FilterText secondary>Filters</FilterText>
<FilterGroup> <Item flex={0} vertical withRightMargin>
<span>Priority</span> <Label>Priority</Label>
<Menu <Menu
inline inline
onChange={changeFilterValue('priority')} onChange={changeFilterValue('priority')}
options={getFilterOptions('priority')} options={getFilterOptions('priority')}
value={getDefaultFilterValue('priority')} value={getDefaultFilterValue('priority')}
/> />
</FilterGroup> </Item>
<FilterGroup> <Item flex={0} vertical>
<span>Sort</span> <Label>Sort</Label>
<Menu <Menu
inline inline
onChange={changeFilterValue('order')} onChange={changeFilterValue('order')}
options={getFilterOptions('order')} options={getFilterOptions('order')}
value={getDefaultFilterValue('order')} value={getDefaultFilterValue('order')}
/> />
</FilterGroup> </Item>
</FiltersContainer> </Row>
) )
export default compose( export default compose(
...@@ -41,29 +41,8 @@ export default compose( ...@@ -41,29 +41,8 @@ export default compose(
)(DashboardFilters) )(DashboardFilters)
// #region styles // #region styles
const FiltersContainer = styled.div` const FilterText = Text.extend`
align-items: center; margin-right: ${th('gridUnit')};
border-bottom: ${th('borderDefault')}; padding-bottom: ${th('gridUnit')};
color: ${th('colorPrimary')};
display: flex;
justify-content: flex-start;
margin: calc(${th('subGridUnit')} * 2) 0;
padding-bottom: calc(${th('subGridUnit')} * 2);
> span {
align-self: flex-end;
margin-bottom: calc(${th('subGridUnit')} * 2);
padding: 0 calc(${th('subGridUnit')});
}
`
const FilterGroup = styled.div`
align-items: flex-start;
display: flex;
flex-direction: column;
margin-left: calc(${th('subGridUnit')} * 2);
> div {
min-width: 200px;
}
` `
// #endregion // #endregion
...@@ -2,8 +2,13 @@ import { css } from 'styled-components' ...@@ -2,8 +2,13 @@ import { css } from 'styled-components'
import { th } from '@pubsweet/ui-toolkit' import { th } from '@pubsweet/ui-toolkit'
export default { export default {
Main: css`
height: calc(${th('gridUnit')} * 4);
min-width: 120px;
`,
Value: css` Value: css`
border: none; border: none;
font-family: ${th('fontHeading')};
&:hover { &:hover {
color: ${th('colorSecondary')}; color: ${th('colorSecondary')};
...@@ -15,6 +20,8 @@ export default { ...@@ -15,6 +20,8 @@ export default {
Opener: css` Opener: css`
border-color: ${props => border-color: ${props =>
props.open ? th('menu.hoverColor') : th('colorBorder')}; props.open ? th('menu.hoverColor') : th('colorBorder')};
height: calc(${th('gridUnit')} * 4);
&:hover { &:hover {
border-color: ${th('menu.hoverColor')}; border-color: ${th('menu.hoverColor')};
} }
...@@ -38,6 +45,8 @@ export default { ...@@ -38,6 +45,8 @@ export default {
font-family: ${th('fontHeading')}; font-family: ${th('fontHeading')};
font-size: ${th('fontSizeBase')}; font-size: ${th('fontSizeBase')};
line-height: ${th('lineHeightBase')}; line-height: ${th('lineHeightBase')};
height: calc(${th('gridUnit')} * 4);
padding: ${th('gridUnit')};
&:hover { &:hover {
background-color: ${th('menu.optionBackground')}; background-color: ${th('menu.optionBackground')};
......
...@@ -44,6 +44,7 @@ export default compose( ...@@ -44,6 +44,7 @@ export default compose(
const Root = styled.div` const Root = styled.div`
height: 100%; height: 100%;
overflow-y: scroll;
div[open] { div[open] {
width: auto; width: auto;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment