-
-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
146 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import * as React from "react"; | ||
import Config from "../config"; | ||
import { ContentContainer, SponsorTime, VisualSegmentInfo } from "../types"; | ||
import Utils from "../utils"; | ||
|
||
|
||
const utils = new Utils(); | ||
|
||
export interface SponsorTimeEditProps { | ||
index: number, | ||
|
||
visual: VisualSegmentInfo, | ||
|
||
idSuffix: string, | ||
// Contains functions and variables from the content script needed by the skip notice | ||
contentContainer: ContentContainer, | ||
} | ||
|
||
export interface SponsorTimeEditState { | ||
|
||
} | ||
|
||
class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, SponsorTimeEditState> { | ||
|
||
idSuffix: string; | ||
|
||
configUpdateListener: () => void; | ||
|
||
constructor(props: SponsorTimeEditProps) { | ||
super(props); | ||
|
||
this.idSuffix = this.props.idSuffix; | ||
|
||
this.state = { | ||
// editing: false, | ||
// sponsorTimeEdits: [null, null] | ||
}; | ||
} | ||
|
||
componentDidMount(): void { | ||
// Add as a config listener | ||
if (!this.configUpdateListener) { | ||
this.configUpdateListener = () => this.configUpdate(); | ||
Config.configListeners.push(this.configUpdate.bind(this)); | ||
} | ||
} | ||
|
||
componentWillUnmount(): void { | ||
if (this.configUpdateListener) { | ||
Config.configListeners.splice(Config.configListeners.indexOf(this.configUpdate.bind(this)), 1); | ||
} | ||
} | ||
|
||
render(): React.ReactElement { | ||
return <> | ||
<span id={`time${this.props.idSuffix}`}> | ||
{utils.getFormattedTime(this.props.visual.time, true)} | ||
</span> | ||
|
||
<span> | ||
- | ||
</span> | ||
|
||
{this.getBoundsElement()} | ||
|
||
<span> | ||
- | ||
</span> | ||
|
||
<input | ||
type="checkBox" | ||
onChange={(event) => this.colorUpdated(event)} | ||
value={this.props.visual.color} | ||
/> | ||
|
||
<span> | ||
Smooth | ||
</span> | ||
|
||
<span> | ||
- | ||
</span> | ||
|
||
<input | ||
className="categoryColorTextBox" | ||
type="color" | ||
onChange={(event) => this.colorUpdated(event)} | ||
value={this.props.visual.color} | ||
/> | ||
|
||
|
||
</> | ||
} | ||
|
||
getBoundsElement(): React.ReactElement[] { | ||
const elements: React.ReactElement[] = []; | ||
|
||
for (const bound of this.props.visual.bounds) { | ||
elements.push( | ||
<span> | ||
{`${bound[0] * 100}% x ${bound[0] * 100}%, `} | ||
</span> | ||
); | ||
} | ||
|
||
return elements; | ||
} | ||
|
||
colorUpdated(event: React.ChangeEvent<HTMLInputElement>): void { | ||
this.props.visual.color = event.target.value; | ||
} | ||
|
||
configUpdate(): void { | ||
this.forceUpdate(); | ||
} | ||
} | ||
|
||
export default SponsorTimeEditComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { VisualSegmentInfo } from "../types"; | ||
|
||
export function toSVG(visuals: VisualSegmentInfo[]): string { | ||
throw new Error("Method not implemented."); | ||
} | ||
|
||
export function toVisualSegmentInfo(svg: string): VisualSegmentInfo { | ||
throw new Error("Method not implemented."); | ||
} |