mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 07:32:02 +00:00
new checkbox api adapted
This commit is contained in:
parent
96a8cf78d0
commit
11fc70045d
3 changed files with 21 additions and 27 deletions
|
|
@ -6,6 +6,12 @@ import { Input } from 'stremio-common';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
|
|
||||||
class Checkbox extends PureComponent {
|
class Checkbox extends PureComponent {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
this.checkboxRef = props.forwardedRef || React.createRef();
|
||||||
|
}
|
||||||
|
|
||||||
onClick = (event) => {
|
onClick = (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (typeof this.props.onClick === 'function') {
|
if (typeof this.props.onClick === 'function') {
|
||||||
|
|
@ -19,7 +25,7 @@ class Checkbox extends PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!event.defaultPrevented) {
|
if (!event.defaultPrevented) {
|
||||||
this.props.forwardedRef.current.blur();
|
this.checkboxRef.current.blur();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -29,7 +35,7 @@ class Checkbox extends PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!event.defaultPrevented) {
|
if (!event.defaultPrevented) {
|
||||||
this.props.forwardedRef.current.blur();
|
this.checkboxRef.current.blur();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,7 +43,7 @@ class Checkbox extends PureComponent {
|
||||||
return (
|
return (
|
||||||
<label className={classnames(this.props.className, styles['checkbox-container'], { 'checked': this.props.checked }, { 'disabled': this.props.disabled })} onClick={this.onClick} onDrag={this.onDrag} onMouseOut={this.onMouseOut}>
|
<label className={classnames(this.props.className, styles['checkbox-container'], { 'checked': this.props.checked }, { 'disabled': this.props.disabled })} onClick={this.onClick} onDrag={this.onDrag} onMouseOut={this.onMouseOut}>
|
||||||
<Input
|
<Input
|
||||||
ref={this.props.forwardedRef}
|
ref={this.checkboxRef}
|
||||||
className={styles['native-checkbox']}
|
className={styles['native-checkbox']}
|
||||||
type={'checkbox'}
|
type={'checkbox'}
|
||||||
disabled={this.props.disabled}
|
disabled={this.props.disabled}
|
||||||
|
|
|
||||||
|
|
@ -152,14 +152,9 @@ class SubtitlesPicker extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<label className={styles['background-toggle-container']}>
|
<Checkbox className={styles['background-toggle-checkbox']} checked={this.props.subtitleDarkBackground} onClick={this.toggleSubtitleDarkBackground}>
|
||||||
<Checkbox
|
|
||||||
className={styles['background-toggle-checkbox']}
|
|
||||||
checked={this.props.subtitleDarkBackground}
|
|
||||||
onClick={this.toggleSubtitleDarkBackground}
|
|
||||||
/>
|
|
||||||
<div className={styles['background-toggle-label']}>Dark background</div>
|
<div className={styles['background-toggle-label']}>Dark background</div>
|
||||||
</label>
|
</Checkbox>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.background-toggle-container {
|
.background-toggle-checkbox {
|
||||||
|
--icon-background-color: transparent;
|
||||||
|
--icon-color: var(--color-surfacelighter);
|
||||||
|
--icon-size: calc(var(--subtitles-picker-button-size) * 0.6);
|
||||||
|
|
||||||
align-self: stretch;
|
align-self: stretch;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
@ -161,17 +165,6 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
.background-toggle-checkbox {
|
|
||||||
--icon-color: var(--color-surfacelighter);
|
|
||||||
--background-color: transparent;
|
|
||||||
width: calc(var(--subtitles-picker-button-size) * 0.6);
|
|
||||||
height: calc(var(--subtitles-picker-button-size) * 0.6);
|
|
||||||
|
|
||||||
&:global(.checked) {
|
|
||||||
--background-color: var(--color-primarydark);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.background-toggle-label {
|
.background-toggle-label {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 0 0.5em;
|
padding: 0 0.5em;
|
||||||
|
|
@ -183,11 +176,11 @@
|
||||||
color: var(--color-surfacelighter);
|
color: var(--color-surfacelighter);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:global(.checked) {
|
||||||
.background-toggle-checkbox {
|
--icon-background-color: var(--color-primarydark);
|
||||||
&:global(.checked) {
|
|
||||||
--background-color: var(--color-primarylight);
|
&:hover {
|
||||||
}
|
--icon-background-color: var(--color-primarylight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue