mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 13:28:36 +03:00
add support for custom fields
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import copy from '../common/data/copy.json'
|
||||
import React from 'react'
|
||||
|
||||
import CardCustomField from './presentational/Card/CustomField'
|
||||
import CardTime from './presentational/Card/Time'
|
||||
import CardLocation from './presentational/Card/Location'
|
||||
import CardCaret from './presentational/Card/Caret'
|
||||
@@ -132,6 +133,16 @@ class Card extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
renderCustomFields () {
|
||||
return this.props.features.CUSTOM_EVENT_FIELDS
|
||||
.map(field => {
|
||||
const value = this.props.event[field.key]
|
||||
return value ? (
|
||||
<CardCustomField field={field} value={this.props.event[field.key]} />
|
||||
) : null
|
||||
})
|
||||
}
|
||||
|
||||
renderMain () {
|
||||
return (
|
||||
<div className='card-container'>
|
||||
@@ -140,6 +151,7 @@ class Card extends React.Component {
|
||||
{this.renderLocation()}
|
||||
</div>
|
||||
{this.renderSummary()}
|
||||
{this.renderCustomFields()}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
14
src/components/presentational/Card/CustomField.js
Normal file
14
src/components/presentational/Card/CustomField.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import React from 'react'
|
||||
import marked from 'marked'
|
||||
|
||||
const CardCustomField = ({ field, value }) => (
|
||||
<div className='card-cell'>
|
||||
<p>
|
||||
<i className='material-icons left'>{field.icon}</i>
|
||||
<b>{field.title ? `${field.title}: ` : '- '}</b>
|
||||
{field.kind === 'text' ? value : marked(`[${value}](${field.value})`)}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
|
||||
export default CardCustomField
|
||||
Reference in New Issue
Block a user