Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Fix NTP clock for c71
Browse files Browse the repository at this point in the history
  • Loading branch information
petemill committed Oct 27, 2018
1 parent 1613af7 commit a6dbd7b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/old/clock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,20 @@ export interface ClockProps {
customStyle?: ClockTheme
}

interface TimeComponent {
type: string,
value: string
}

export interface ClockState {
currentTime: Array<{type: string, value: string}>
currentTime: Array<TimeComponent>
date: Date
}

function IsDayPeriod(timeComponent: TimeComponent): boolean {
return timeComponent.type.toLowerCase() === 'dayperiod'
}

class Clock extends React.PureComponent<ClockProps, ClockState> {
constructor (props: ClockProps) {
super(props)
Expand All @@ -44,7 +53,7 @@ class Clock extends React.PureComponent<ClockProps, ClockState> {
// hide blank strings
return null
}
} else if (component.type === 'dayperiod') {
} else if (IsDayPeriod(component)) {
// hide day-period (AM / PM), it's rendered in a separate component
return null
}
Expand All @@ -54,7 +63,7 @@ class Clock extends React.PureComponent<ClockProps, ClockState> {

get formattedTimePeriod () {
const time: any = this.state.currentTime
const period = time.find((component: {type: string}) => component.type === 'dayperiod')
const period = time.find(IsDayPeriod)
return period ? period.value : ''
}

Expand Down
6 changes: 6 additions & 0 deletions stories/old/views.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import * as React from 'react'
// TBD import Clock from '../components/clock'
import Page from '../../src/old/page'
import { DataBlock, DataItem } from '../../src/old/dataBlock'
import Clock from '../../src/old/clock'

storiesOf('Old/Views', module)
.addDecorator(withKnobs)
Expand Down Expand Up @@ -73,3 +74,8 @@ storiesOf('Old/Views', module)
</DataBlock>
)
})
.add('Clock', () => {
return (
<Clock />
)
})

0 comments on commit a6dbd7b

Please sign in to comment.