mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 03:22:11 +00:00
basic color pickers implemented
This commit is contained in:
parent
98c29b1a56
commit
43cd79b2c2
5 changed files with 59 additions and 8 deletions
42
src/common/ColorPicker/ColorPicker.js
Normal file
42
src/common/ColorPicker/ColorPicker.js
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
const React = require('react');
|
||||||
|
const PropTypes = require('prop-types');
|
||||||
|
const { SketchPicker } = require('react-color');
|
||||||
|
|
||||||
|
class ColorPicker extends React.Component {
|
||||||
|
onContainerClicked = (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
|
onColorChanged = (color) => {
|
||||||
|
const value = '#' + `0${color.rgb.r.toString(16)}`.slice(-2) +
|
||||||
|
`0${color.rgb.g.toString(16)}`.slice(-2) +
|
||||||
|
`0${color.rgb.b.toString(16)}`.slice(-2) +
|
||||||
|
`0${Math.round(color.rgb.a * 255).toString(16)}`.slice(-2);
|
||||||
|
if (typeof this.props.onChange === 'function') {
|
||||||
|
this.props.onChange(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div className={this.props.className} onClick={this.onContainerClicked}>
|
||||||
|
<SketchPicker
|
||||||
|
width={''}
|
||||||
|
color={this.props.value}
|
||||||
|
presetColors={[]}
|
||||||
|
onChangeComplete={this.onColorChanged}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorPicker.propTypes = {
|
||||||
|
className: PropTypes.string,
|
||||||
|
value: PropTypes.string.isRequired,
|
||||||
|
onChange: PropTypes.func,
|
||||||
|
onOpen: PropTypes.func,
|
||||||
|
onClose: PropTypes.func
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = ColorPicker;
|
||||||
3
src/common/ColorPicker/index.js
Normal file
3
src/common/ColorPicker/index.js
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
const ColorPicker = require('./ColorPicker');
|
||||||
|
|
||||||
|
module.exports = ColorPicker;
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import Slider from './Slider';
|
import Slider from './Slider';
|
||||||
import { FocusableProvider, withFocusable } from './Focusable';
|
import { FocusableProvider, withFocusable } from './Focusable';
|
||||||
import Checkbox from './Checkbox';
|
import Checkbox from './Checkbox';
|
||||||
|
import ColorPicker from './ColorPicker';
|
||||||
import Input from './Input';
|
import Input from './Input';
|
||||||
import { Modal, ModalsContainerContext, withModalsContainer } from './Modal';
|
import { Modal, ModalsContainerContext, withModalsContainer } from './Modal';
|
||||||
import Popup from './Popup';
|
import Popup from './Popup';
|
||||||
|
|
@ -13,6 +14,7 @@ import Loader from './Loader';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
Checkbox,
|
Checkbox,
|
||||||
|
ColorPicker,
|
||||||
Input,
|
Input,
|
||||||
Popup,
|
Popup,
|
||||||
NavBar,
|
NavBar,
|
||||||
|
|
|
||||||
|
|
@ -116,16 +116,16 @@ class SubtitlesPicker extends React.Component {
|
||||||
this.props.dispatch({ propName: 'subtitlesDelay', propValue: event.currentTarget.dataset.value });
|
this.props.dispatch({ propName: 'subtitlesDelay', propValue: event.currentTarget.dataset.value });
|
||||||
}
|
}
|
||||||
|
|
||||||
setSubtitlesTextColor = (event) => {
|
setSubtitlesTextColor = (color) => {
|
||||||
// TODO fix it
|
this.props.dispatch({ propName: 'subtitlesTextColor', propValue: color });
|
||||||
}
|
}
|
||||||
|
|
||||||
setSubtitlesBackgroundColor = (event) => {
|
setSubtitlesBackgroundColor = (color) => {
|
||||||
// TODO fix it
|
this.props.dispatch({ propName: 'subtitlesBackgroundColor', propValue: color });
|
||||||
}
|
}
|
||||||
|
|
||||||
setSubtitlesOutlineColor = (event) => {
|
setSubtitlesOutlineColor = (color) => {
|
||||||
// TODO fix it
|
this.props.dispatch({ propName: 'subtitlesOutlineColor', propValue: color });
|
||||||
}
|
}
|
||||||
|
|
||||||
renderToggleButton({ selectedTrack }) {
|
renderToggleButton({ selectedTrack }) {
|
||||||
|
|
|
||||||
|
|
@ -223,9 +223,13 @@
|
||||||
.color-picker-modal-container {
|
.color-picker-modal-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
.color-picker-container {
|
.color-picker-container {
|
||||||
width: 80vmin;
|
width: 35vmin;
|
||||||
height: 50vmin;
|
height: 35vmin;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue