Skip to content
Snippets Groups Projects
Commit 00d800a2 authored by Sam Galson's avatar Sam Galson Committed by Jure
Browse files

feat(ui): convert StateList to a styled component

parent 76d1c6c6
No related branches found
No related tags found
No related merge requests found
...@@ -2,10 +2,27 @@ import PropTypes from 'prop-types' ...@@ -2,10 +2,27 @@ import PropTypes from 'prop-types'
import React from 'react' import React from 'react'
import { map, uniqueId, keys, last } from 'lodash' import { map, uniqueId, keys, last } from 'lodash'
import { ChevronRight } from 'react-feather' import { ChevronRight } from 'react-feather'
import styled from 'styled-components'
import classes from './StateList.local.scss'
import StateItem from '../atoms/StateItem' import StateItem from '../atoms/StateItem'
const StateListContainer = styled.div`
align-items: center;
display: flex;
flex-direction: row;
`
const ItemContainer = styled.div`
align-items: center;
display: flex;
flex-direction: row;
`
const Delimiter = styled(ChevronRight).attrs({ size: 16 })`
margin-left: 5px;
margin-right: 5px;
`
const StateList = ({ currentValues, update, values }) => { const StateList = ({ currentValues, update, values }) => {
const progressIds = keys(values) const progressIds = keys(values)
const lastItem = last(progressIds) const lastItem = last(progressIds)
...@@ -18,27 +35,22 @@ const StateList = ({ currentValues, update, values }) => { ...@@ -18,27 +35,22 @@ const StateList = ({ currentValues, update, values }) => {
} }
const items = map(values, (valueList, currentItem) => { const items = map(values, (valueList, currentItem) => {
let delimiter
const currentValueIndex = currentValues[currentItem] const currentValueIndex = currentValues[currentItem]
if (currentItem !== lastItem) {
delimiter = <ChevronRight className={classes.delimiter} size={16} />
}
return ( return (
<div className={classes.itemContainer} key={uniqueId()}> <ItemContainer key={uniqueId()}>
<StateItem <StateItem
disabled={!canAct(currentItem)} disabled={!canAct(currentItem)}
index={currentValueIndex} index={currentValueIndex}
update={handleUpdate} update={handleUpdate}
values={valueList} values={valueList}
/> />
{delimiter} {currentItem !== lastItem && <Delimiter />}
</div> </ItemContainer>
) )
}) })
return <div className={classes.stateListContainer}>{items}</div> return <StateListContainer>{items}</StateListContainer>
} }
StateList.propTypes = { StateList.propTypes = {
......
.stateListContainer {
align-items: center;
display: flex;
flex-direction: row;
}
.itemContainer {
align-items: center;
display: flex;
flex-direction: row;
}
.delimiter {
margin-left: 5px;
margin-right: 5px;
}
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`StateList is rendered correctly 1`] = ` exports[`StateList is rendered correctly 1`] = `
.c0 { .c2 {
cursor: pointer; cursor: pointer;
font-family: var(--font-interface); font-family: var(--font-interface);
font-size: 16px; font-size: 16px;
...@@ -9,24 +9,57 @@ exports[`StateList is rendered correctly 1`] = ` ...@@ -9,24 +9,57 @@ exports[`StateList is rendered correctly 1`] = `
padding: 0; padding: 0;
} }
.c0:focus { .c2:focus {
outline: none; outline: none;
} }
.c0:hover { .c2:hover {
color: #404040; color: #404040;
-webkit-transition: 0.25s ease-in-out 0s; -webkit-transition: 0.25s ease-in-out 0s;
transition: 0.25s ease-in-out 0s; transition: 0.25s ease-in-out 0s;
} }
.c0 {
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
}
.c1 {
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
}
.c3 {
margin-left: 5px;
margin-right: 5px;
}
<div <div
className="stateListContainer" className="c0"
> >
<div <div
className="itemContainer" className="c1"
> >
<span <span
className="c0" className="c2"
disabled={false} disabled={false}
onClick={[Function]} onClick={[Function]}
onKeyPress={[Function]} onKeyPress={[Function]}
...@@ -36,7 +69,7 @@ exports[`StateList is rendered correctly 1`] = ` ...@@ -36,7 +69,7 @@ exports[`StateList is rendered correctly 1`] = `
To Clean To Clean
</span> </span>
<svg <svg
className="delimiter" className="c3"
fill="none" fill="none"
height={16} height={16}
stroke="currentColor" stroke="currentColor"
...@@ -53,10 +86,10 @@ exports[`StateList is rendered correctly 1`] = ` ...@@ -53,10 +86,10 @@ exports[`StateList is rendered correctly 1`] = `
</svg> </svg>
</div> </div>
<div <div
className="itemContainer" className="c1"
> >
<span <span
className="c0" className="c2"
disabled={false} disabled={false}
onClick={[Function]} onClick={[Function]}
onKeyPress={[Function]} onKeyPress={[Function]}
...@@ -66,7 +99,7 @@ exports[`StateList is rendered correctly 1`] = ` ...@@ -66,7 +99,7 @@ exports[`StateList is rendered correctly 1`] = `
To Edit To Edit
</span> </span>
<svg <svg
className="delimiter" className="c3"
fill="none" fill="none"
height={16} height={16}
stroke="currentColor" stroke="currentColor"
...@@ -83,10 +116,10 @@ exports[`StateList is rendered correctly 1`] = ` ...@@ -83,10 +116,10 @@ exports[`StateList is rendered correctly 1`] = `
</svg> </svg>
</div> </div>
<div <div
className="itemContainer" className="c1"
> >
<span <span
className="c0" className="c2"
disabled={false} disabled={false}
onClick={[Function]} onClick={[Function]}
onKeyPress={[Function]} onKeyPress={[Function]}
...@@ -96,7 +129,7 @@ exports[`StateList is rendered correctly 1`] = ` ...@@ -96,7 +129,7 @@ exports[`StateList is rendered correctly 1`] = `
To Review To Review
</span> </span>
<svg <svg
className="delimiter" className="c3"
fill="none" fill="none"
height={16} height={16}
stroke="currentColor" stroke="currentColor"
...@@ -113,10 +146,10 @@ exports[`StateList is rendered correctly 1`] = ` ...@@ -113,10 +146,10 @@ exports[`StateList is rendered correctly 1`] = `
</svg> </svg>
</div> </div>
<div <div
className="itemContainer" className="c1"
> >
<span <span
className="c0" className="c2"
disabled={false} disabled={false}
onClick={[Function]} onClick={[Function]}
onKeyPress={[Function]} onKeyPress={[Function]}
......
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