mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 21:47:06 +03:00
Added basic category chooser UI
This commit is contained in:
63
src/components/CategorySkipOptionsComponent.tsx
Normal file
63
src/components/CategorySkipOptionsComponent.tsx
Normal file
@@ -0,0 +1,63 @@
|
||||
import * as React from "react";
|
||||
import Config from "../config"
|
||||
|
||||
export interface CategorySkipOptionsProps {
|
||||
category: string;
|
||||
defaultColor: string;
|
||||
}
|
||||
|
||||
export interface CategorySkipOptionsState {
|
||||
color: string;
|
||||
}
|
||||
|
||||
class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsProps, CategorySkipOptionsState> {
|
||||
|
||||
constructor(props: CategorySkipOptionsProps) {
|
||||
super(props);
|
||||
|
||||
// Setup state
|
||||
this.state = {
|
||||
color: props.defaultColor
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<tr id={this.props.category + "OptionsRow"}
|
||||
className="categoryTableElement">
|
||||
<td id={this.props.category + "OptionName"}
|
||||
className="categoryTableLabel">
|
||||
{chrome.i18n.getMessage("category_" + this.props.category)}
|
||||
</td>
|
||||
|
||||
<td id={this.props.category + "SkipOption"}>
|
||||
<select
|
||||
className="categoryOptionsSelector">
|
||||
{this.getOptions(["disable", "manualSkip", "autoSkip"])}
|
||||
</select>
|
||||
</td>
|
||||
|
||||
{/* TODO: Add colour chooser */}
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param optionNames List of option names as codes that will be sent to i18n
|
||||
*/
|
||||
getOptions(optionNames: string[]): JSX.Element[] {
|
||||
let elements: JSX.Element[] = [];
|
||||
|
||||
for (const optionName of optionNames) {
|
||||
elements.push(
|
||||
<option value={optionName}>
|
||||
{chrome.i18n.getMessage(optionName)}
|
||||
</option>
|
||||
);
|
||||
}
|
||||
|
||||
return elements;
|
||||
}
|
||||
}
|
||||
|
||||
export default CategorySkipOptionsComponent;
|
||||
Reference in New Issue
Block a user