Time display on Card display precision

This commit is contained in:
Franc Camps-Febrer
2019-01-31 19:21:23 -05:00
parent 92d2fa9a21
commit ac740596fa
4 changed files with 22 additions and 7 deletions

View File

@@ -88,11 +88,27 @@ class Card extends React.Component {
// NB: should be internaionalized.
renderTimestamp () {
let timelabel = this.makeTimelabel(this.props.event.timestamp)
let precision = this.props.event.time_display;
if (precision === '_date_only') {
precision = ''
timelabel = timelabel.substring(0, 11)
} else if (precision === '_approximate_date_only') {
precision = ' (Approximate date)'
timelabel = timelabel.substring(0, 11)
} else if (precision === '_approximate_datetime') {
precision = ' (Approximate datetime)'
} else {
timelabel = timelabel.substring(0, 11)
}
return (
<CardTimestamp
makeTimelabel={(timestamp) => this.makeTimelabel(timestamp)}
makeTimelabel={timelabel}
language={this.props.language}
timestamp={this.props.event.timestamp}
timelabel={timelabel}
precision={precision}
/>
)
}

View File

@@ -3,18 +3,17 @@ import React from 'react'
import copy from '../../../js/data/copy.json'
import { isNotNullNorUndefined } from '../../../js/utilities'
const CardTimestamp = ({ makeTimelabel, language, timestamp }) => {
const CardTimestamp = ({ timelabel, language, precision }) => {
// const daytimeLang = copy[language].cardstack.timestamp
// const estimatedLang = copy[language].cardstack.estimated
const unknownLang = copy[language].cardstack.unknown_time
if (isNotNullNorUndefined(timestamp)) {
const timelabel = makeTimelabel(timestamp)
if (isNotNullNorUndefined(timelabel)) {
return (
<div className='card-cell timestamp'>
<p>
<i className='material-icons left'>today</i>
{timelabel}
{timelabel}{(precision !== '') ? ` - ${precision}` : ''}
</p>
</div>
)

View File

@@ -58,7 +58,6 @@ function MapEvents ({ getCategoryColor, categories, projectPoint, styleLocation,
return (
<path
onClick={() => { console.log('uo')}}
class='location-event-marker'
id={`arc_${idx}`}
d={arc}

View File

@@ -16,6 +16,7 @@ const eventSchema = Joi.object().keys({
tags: Joi.array().allow(''),
comments: Joi.string().allow(''),
timestamp: Joi.string(),
time_display: Joi.string().allow(''),
// nested
narrative___stepStyles: Joi.array()