import { Component, Attributes } from "armature"; import { $html, $each, $if } from "ekma" import * as moment from "moment"; import { DayEvent } from "./"; import * as API from "./API"; const template = (summary: EventSummary) => { if (summary.active) { if (summary.events.length === 0) { return noResultsTemplate(summary); } return activeTemplate(summary); } else { return inactiveTemplate(summary); } }; const inactiveTemplate = (summary: EventSummary) => $html`
Select a day to view events.
`; const noResultsTemplate = (summary: EventSummary) => $html`

No events found

`; const activeTemplate = (summary: EventSummary) => $html`
Events On: ${moment.unix(summary.events[0].date).utc().format("MMMM-DD") } ${ $each(summary.events, (event: DayEvent) => $html`
$${ event.title ? `

${ event.title }

` : "" }
    $${ event.date ? `
  • ${ moment.unix(event.date).utc().format("h:mma") }
  • ` : "" } $${ event.location ? `
  • ${ event.location }
  • ` : "" } $${ event.url ? `
  • Go to Event
  • ` : "" }
`) }
`; @Attributes({ tag: "event-summary", template }) export default class EventSummary extends Component { active = false; events: DayEvent[] = []; show(events: DayEvent[]) { this.events = events.filter(v => v.visible); this.reify(); } }