From d27ddc85aeef62c4f6d64c51750f7c0f868c7d22 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Thu, 1 Jul 2021 00:54:52 -0400 Subject: [PATCH] Move code for smaller notice into general notice component Fixes other notices --- public/content.css | 22 +---- src/components/NoticeComponent.tsx | 124 ++++++++++++++----------- src/components/SkipNoticeComponent.tsx | 74 +++++---------- 3 files changed, 99 insertions(+), 121 deletions(-) diff --git a/public/content.css b/public/content.css index 9fc67cd8..dc5e94c3 100644 --- a/public/content.css +++ b/public/content.css @@ -120,17 +120,17 @@ } .sponsorSkipNoticeParent { - min-width: 350px; position: absolute; right: 5px; bottom: 100px; right: 10px; - - z-index: 1000; - - border-radius: 5px; +} +.sponsorSkipNoticeParent, .sponsorSkipNotice { + min-width: 350px; + + border-radius: 5px; border-spacing: 5px 10px; padding-left: 5px; padding-right: 5px; @@ -142,21 +142,9 @@ min-width: 350px; background-color: rgba(28, 28, 28, 0.9); - border-radius: 5px; - - border-spacing: 5px 10px; - padding-left: 5px; - padding-right: 5px; - - border-collapse: unset; - transition: all 0.1s ease-out; } -/* .sponsorSkipNotice .miniNotice { - bottom: 146px; -} */ - .sponsorSkipNotice .hidden { display: none; } diff --git a/src/components/NoticeComponent.tsx b/src/components/NoticeComponent.tsx index ac0cbc59..c968afca 100644 --- a/src/components/NoticeComponent.tsx +++ b/src/components/NoticeComponent.tsx @@ -21,12 +21,13 @@ export interface NoticeProps { startFaded?: boolean, firstColumn?: React.ReactElement, firstRow?: React.ReactElement, + bottomRow?: React.ReactElement[], smaller?: boolean, // Callback for when this is closed closeListener: () => void, - onMouseEnter?: (e: React.MouseEvent) => void, + onMouseEnter?: (e: React.MouseEvent) => void, zIndex?: number, style?: React.CSSProperties @@ -94,66 +95,79 @@ class NoticeComponent extends React.Component { } return ( - 0 ? " secondSkipNotice" : "")} - style={noticeStyle} +
0 ? " secondSkipNotice" : "")} onMouseEnter={(e) => this.onMouseEnter(e) } - onMouseLeave={() => this.timerMouseLeave()}> -
+ onMouseLeave={() => this.timerMouseLeave()} + style={noticeStyle} > +
+ - {/* First row */} - - {/* Left column */} - - - {this.props.firstRow} - - {/* Right column */} - + {/* Left column */} + - + {this.props.firstColumn} + - {this.props.children} + {this.props.firstRow} - -
- {/* Logo */} - - - - - - {this.state.noticeTitle} - - - {this.props.firstColumn} - - - {/* Time left */} - {this.props.timed ? ( - this.toggleManualPause()} - className="sponsorSkipObject sponsorSkipNoticeTimeLeft"> - - {this.getCountdownElements()} + {/* First row */} +
+ {/* Logo */} + + + + + {this.state.noticeTitle} - ) : ""} - - {/* Close button */} - this.close()}> - -
+ {/* Right column */} + + + {/* Time left */} + {this.props.timed ? ( + this.toggleManualPause()} + className="sponsorSkipObject sponsorSkipNoticeTimeLeft"> + + {this.getCountdownElements()} + + + ) : ""} + + + {/* Close button */} + this.close()}> + + + + + {this.props.children} + + {!this.props.smaller ? + this.props.bottomRow + : null} + + + + + {/* Add as a hidden table to keep the height constant */} + {this.props.smaller ? + + {this.props.bottomRow} +
+ : null} + ); } @@ -182,7 +196,7 @@ class NoticeComponent extends React.Component { )]; } - onMouseEnter(event: React.MouseEvent): void { + onMouseEnter(event: React.MouseEvent): void { if (this.props.onMouseEnter) this.props.onMouseEnter(event); this.fadedMouseEnter(); diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index a99ef289..6126fac0 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -145,11 +145,6 @@ class SkipNoticeComponent extends React.Component - this.contentContainer().v?.playbackRate} - style={noticeStyle} - ref={this.noticeRef} - closeListener={() => this.closeListener()} - smaller={this.props.smaller} - firstColumn={firstColumn} - onMouseEnter={() => this.onMouseEnter() } > - - {(Config.config.audioNotificationOnSkip) && } - - {/* Text Boxes */} - {!this.state.smaller ? - this.getMessageBoxes() - : null} - - {!this.state.smaller ? - this.getBottomRow() - : null} - - - - {/* Text Boxes */} - {this.state.smaller ? ( - - {this.getMessageBoxes()} - - {this.getBottomRow()} -
- ) : null} - + this.contentContainer().v?.playbackRate} + style={noticeStyle} + ref={this.noticeRef} + closeListener={() => this.closeListener()} + smaller={this.state.smaller} + firstColumn={firstColumn} + bottomRow={[...this.getMessageBoxes(), ...this.getBottomRow() ]} + onMouseEnter={() => this.onMouseEnter() } > + + {(Config.config.audioNotificationOnSkip) && } + ); } @@ -367,14 +342,15 @@ class SkipNoticeComponent extends React.Component + className="sponsorBlockSpacer" + key={0}> - ); + ]; } const elements: JSX.Element[] = [];