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

feat(styleguide): add row and item helper elements, add person info component

parent 600453dc
No related branches found
No related tags found
1 merge request!43Sprint #19
......@@ -21,5 +21,9 @@ const Required = styled.span`
const Root = styled.div`
align-items: center;
display: flex;
${H4} {
margin: 0;
}
`
// #endregion
import React from 'react'
import styled from 'styled-components'
import { th } from '@pubsweet/ui-toolkit'
import { Box } from 'grid-styled'
import PropTypes from 'prop-types'
import Text from './Text'
import Label from './Label'
import Row from './gridItems/Row'
import Item from './gridItems/Item'
const PersonInfo = () => (
<Box>
<Label>Email</Label>
<Text>alexandru.munt@gmail.com</Text>
</Box>
const defaultPerson = {
email: '',
firstName: '',
lastName: '',
affiliation: '',
}
const PersonInfo = ({
person: { email, firstName, lastName, affiliation } = defaultPerson,
}) => (
<Row>
<Item vertical withRightMargin>
<Label>Email</Label>
<Text>{email}</Text>
</Item>
<Item vertical withRightMargin>
<Label>First name</Label>
<Text>{firstName}</Text>
</Item>
<Item vertical withRightMargin>
<Label>Last name</Label>
<Text>{lastName}</Text>
</Item>
<Item vertical>
<Label>Affiliation</Label>
<Text>{affiliation}</Text>
</Item>
</Row>
)
PersonInfo.proTypes = {
person: PropTypes.shape({
email: PropTypes.string,
firstName: PropTypes.string,
lastName: PropTypes.string,
affiliation: PropTypes.string,
}),
}
export default PersonInfo
// #region styles
......
Details of a person.
```js
<PersonInfo />
const anAuthor = {
email: 'author.manuscriptovici@gmail.com',
firstName: 'Author',
lastName: 'Manuscriptovici',
affiliation: 'PSD',
};
<PersonInfo person={anAuthor} />
```
import styled from 'styled-components'
import { th } from '@pubsweet/ui-toolkit'
export default styled.div`
background-color: red;
export default styled.div.attrs({
'data-test-id': props => props['data-test-id'] || 'item',
})`
display: flex;
flex: ${({ flex }) => flex || 1};
flex-direction: ${({ vertical }) => (vertical ? 'column' : 'row')};
justify-content: ${({ centered }) => (centered ? 'center' : 'initial')};
margin-right: ${({ withRightMargin }) =>
withRightMargin ? th('gridUnit') : 0};
`
An item.
An item. By default the content is displayed in a row.
```js
<Item>wai nebun</Item>
<Item>
<span>I am on the left side</span>
<span>I am on the right side</span>
</Item>
```
Displayed in a column.
```js
<Item vertical>
<span>I am on top</span>
<span>I am at the bottom</span>
</Item>
```
import { get } from 'lodash'
import styled, { css } from 'styled-components'
import { th } from '@pubsweet/ui-toolkit'
export default styled.div.attrs({
'data-test-id': props => props['data-test-id'] || 'row',
})`
align-items: ${props => get(props, 'alignItems', 'flex-start')};
display: flex;
flex-direction: row;
justify-content: ${({ justify }) => justify || 'space-evenly'};
margin: ${({ noMargin }) =>
noMargin ? 0 : css`calc(${th('subGridUnit')} * 2) 0`};
width: 100%;
`
A row of items.
```js
<Row>
<Item>Item 1</Item>
<Item>Item 2</Item>
<div>Item 3</div>
</Row>
```
\ No newline at end of file
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