-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor PM-407: Outcome components #245
Changes from 10 commits
a4ad7f7
f986167
21e360c
3b5d0c4
f582adf
f8bc7be
1770729
1b765b1
2b043e8
a50719e
520783c
f084edd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import cn from 'classnames' | ||
import style from '../outcomeCategorical.scss' | ||
|
||
const cx = cn.bind(style) | ||
|
||
const TrendingOutcomeCategorical = ({ | ||
entryStyle, outcome, percentage, resolutionDate, | ||
}) => ( | ||
<div className="outcomes outcomes--categorical"> | ||
<div className={cx('outcomeWrapper')}> | ||
<div className="entry__color" style={entryStyle} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andre-meyer Will fix that, this is related to the question I asked you today about adding class names for elements with no style imported from .scss |
||
<div className={cx('outcome')}>{outcome}</div> | ||
</div> | ||
<div>{percentage}%</div> | ||
<div className={cx('date')}>{resolutionDate}</div> | ||
</div> | ||
) | ||
|
||
TrendingOutcomeCategorical.propTypes = { | ||
entryStyle: PropTypes.object, | ||
outcome: PropTypes.string, | ||
percentage: PropTypes.string, | ||
resolutionDate: PropTypes.string, | ||
} | ||
|
||
TrendingOutcomeCategorical.defaultProps = { | ||
entryStyle: {}, | ||
outcome: '', | ||
percentage: '', | ||
resolutionDate: '', | ||
} | ||
|
||
export default TrendingOutcomeCategorical |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
@import '../../../scss/vars.scss'; | ||
|
||
$outcome-bar-height: 15px; | ||
$outcome-bar-height-leading: 30px; | ||
|
||
.outcome { | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
max-width: 100%; | ||
} | ||
|
||
.outcomeWrapper { | ||
max-width: 75%; | ||
} | ||
|
||
.outcomeBar { | ||
display: inline-block; | ||
position: relative; | ||
width: 30%; | ||
margin: 5px 0; | ||
} | ||
|
||
.outcomeBarInner { | ||
height: $outcome-bar-height; | ||
position: relative; | ||
border-top-right-radius: 5px; | ||
border-bottom-right-radius: 5px; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
|
||
transition: width 1s ease; | ||
} | ||
|
||
.outcomeBarValue { | ||
line-height: $outcome-bar-height; | ||
vertical-align: middle; | ||
padding-left: 5px; | ||
display: inline; | ||
min-width: 30px; | ||
color: $font-color-muted; | ||
font-size: 10px; | ||
letter-spacing: 0.5px; | ||
text-transform: uppercase; | ||
} | ||
|
||
.outcomeBarLabel { | ||
margin-left: 100%; | ||
padding-left: 5px; | ||
line-height: $outcome-bar-height; | ||
text-transform: uppercase; | ||
font-size: 10px; | ||
letter-spacing: 0.5px; | ||
} | ||
|
||
.outcomeLabel { | ||
display: inline-block; | ||
} | ||
|
||
.date { | ||
margin-left: 7px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import DecimalValue from 'components/DecimalValue' | ||
|
||
const TrendingOutcomeScalar = ({ predictedValue, unit, decimals }) => ( | ||
<div className="row"> | ||
<div className="col-md-6"> | ||
<DecimalValue value={predictedValue} decimals={decimals} className="outcome__currentPrediction--value" /> | ||
{unit} | ||
</div> | ||
</div> | ||
) | ||
|
||
TrendingOutcomeScalar.propTypes = { | ||
predictedValue: PropTypes.string, | ||
unit: PropTypes.string, | ||
decimals: PropTypes.string, | ||
} | ||
|
||
TrendingOutcomeScalar.defaultProps = { | ||
predictedValue: '0', | ||
unit: '', | ||
decimals: '0', | ||
} | ||
|
||
export default TrendingOutcomeScalar |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
@import '../../../scss/vars.scss'; | ||
|
||
$expandable-arrow-size: 7px; | ||
|
||
.scalarOutcome { | ||
width: 50%; | ||
display: table; | ||
margin-top: 40px; | ||
} | ||
|
||
.currentPrediction { | ||
position: relative; | ||
height: 30px; | ||
width: 100%; | ||
} | ||
|
||
|
||
.currentPredictionLine { | ||
position: absolute; | ||
background-color: $bg-color-muted; | ||
height: 2px; | ||
width: 100%; | ||
top: 50%; | ||
transform: translateY(-1px); | ||
} | ||
|
||
.currentPredictionValue { | ||
position: absolute; | ||
background-color: $link-color; | ||
padding: 5px; | ||
border-radius: 5px; | ||
color: white; | ||
top: 50%; | ||
transform: translate(-50%, -38px); | ||
transition: left 1s ease; | ||
left: 0; | ||
&:after { | ||
content: ''; | ||
position: absolute; | ||
bottom: -5px; | ||
left: 50%; | ||
margin-left: -$expandable-arrow-size; | ||
width: 0; | ||
height: 0; | ||
border-left: $expandable-arrow-size solid transparent; | ||
border-right: $expandable-arrow-size solid transparent; | ||
border-top: $expandable-arrow-size solid $link-color; | ||
} | ||
} | ||
|
||
.outcomeBound { | ||
display: table-cell; | ||
width: 15%; | ||
height: 30px; | ||
vertical-align: middle; | ||
font-size: 10px; | ||
font-weight: 500; | ||
letter-spacing: 0.5px; | ||
|
||
.lower { | ||
text-align: left; | ||
} | ||
|
||
.upper { | ||
text-align: right; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cx('outcomes', 'categorical')
if we're going for css-modules, we need to use the bound styles everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌