Skip to content
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

No data text change for agency view #845

Merged
merged 2 commits into from
Jun 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/AgencyChartContainer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import lowerCase from 'lodash.lowercase'
import startCase from 'lodash.startcase'
import PropTypes from 'prop-types'
import React from 'react'
Expand All @@ -24,10 +25,12 @@ const getContent = ({ crime, place, since, summary, until }) => {
dataClean.length ===
dataClean.filter(d => d.reported === 0 && d.cleared === 0).length

const noDataText = `There were no ${lowerCase(crime)} incidents reported during this time period.`

return (
<div>
{hasNoValues
? <NoData />
? <NoData text={noDataText} />
: <div>
<AgencyChart
crime={crime}
Expand Down
11 changes: 9 additions & 2 deletions src/components/Loading.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types'
import React from 'react'

const Loading = ({ slim, text }) => (
Expand All @@ -7,14 +8,20 @@ const Loading = ({ slim, text }) => (
width="30"
height="30"
src="/img/loading.svg"
alt="loading..."
alt="Loading..."
/>
{text || 'Loading'}
{text}
</div>
)

Loading.defaultProps = {
slim: false,
text: 'Loading',
}

Loading.PropTypes = {
slim: PropTypes.boolean,
text: PropTypes.string,
}

export default Loading
11 changes: 10 additions & 1 deletion src/components/NoData.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import PropTypes from 'prop-types'
import React from 'react'

const NoData = () => <div className="fs-18">There’s no data at this time.</div>
const NoData = ({ text }) => <div className="fs-18">{text}</div>

NoData.defaultProps = {
text: 'There is no data at this time.',
}

NoData.propTypes = {
text: PropTypes.string,
}

export default NoData
5 changes: 4 additions & 1 deletion src/components/SparklineContainer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { max } from 'd3-array'
import lowerCase from 'lodash.lowercase'
import snakeCase from 'lodash.snakecase'
import startCase from 'lodash.startcase'
import PropTypes from 'prop-types'
Expand Down Expand Up @@ -40,7 +41,9 @@ const SparklineContainer = ({ crime, since, summaries, until, usState }) => {

return (
<div className="mb4">
<h3 className="mt0 mb2 fs-18">State and national {crime} rates</h3>
<h3 className="mt0 mb2 fs-18">
State and national {lowerCase(crime)} rates
</h3>
<div className="clearfix mxn1">
{sparklines.map((s, i) => (
<div className="sm-col sm-col-6 mb1 px1" key={i}>
Expand Down