diff --git a/src/components/TimedNoticeComponent.tsx b/src/components/NoticeComponent.tsx similarity index 88% rename from src/components/TimedNoticeComponent.tsx rename to src/components/NoticeComponent.tsx index 12dd1637..a988207e 100644 --- a/src/components/TimedNoticeComponent.tsx +++ b/src/components/NoticeComponent.tsx @@ -1,29 +1,36 @@ import * as React from "react"; -export interface TimedNoticeProps { +export interface NoticeProps { noticeTitle: string, maxCountdownTime?: () => number, amountOfPreviousNotices?: number, + timed?: boolean, idSuffix: string } -export interface TimedNoticeState { +export interface NoticeState { noticeTitle: string, countdownTime: number, countdownText: string, } -class TimedNoticeComponent extends React.Component { +class NoticeComponent extends React.Component { countdownInterval: NodeJS.Timeout; idSuffix: any; + timed: boolean + amountOfPreviousNotices: number; - constructor(props: TimedNoticeProps) { + constructor(props: NoticeProps) { super(props); + // Set default to timed + this.timed = props.timed; + if (this.timed === undefined) this.timed = true; + if (props.maxCountdownTime === undefined) props.maxCountdownTime = () => 4; //the id for the setInterval running the countdown @@ -84,11 +91,14 @@ class TimedNoticeComponent extends React.Component {/* Time left */} - + {this.timed ? ( + - {this.state.countdownText || (this.state.countdownTime + "s")} - + {this.state.countdownText || (this.state.countdownTime + "s")} + + ) : ""} + {/* Close button */} ; + noticeRef: React.MutableRefObject; constructor(props: SkipNoticeProps) { super(props); @@ -84,7 +84,7 @@ class SkipNoticeComponent extends React.Component - + ); }