diff --git a/src/common/ColorInput/ColorInput.js b/src/common/ColorInput/ColorInput.js new file mode 100644 index 000000000..ae231de9e --- /dev/null +++ b/src/common/ColorInput/ColorInput.js @@ -0,0 +1,45 @@ +const React = require('react'); +const classnames = require('classnames'); +const PropTypes = require('prop-types'); +const Popup = require('stremio/common/Popup'); +const Button = require('stremio/common/Button'); +const ColorPicker = require('stremio/common/ColorPicker'); +const useBinaryState = require('stremio/common/useBinaryState'); +const styles = require('./styles'); + +const ColorInput = React.forwardRef((props, ref) => { + const [menuOpen, openMenu, closeMenu, toggleMenu] = useBinaryState(false); + const [color, setColor] = React.useState(props.defaultValue); + const [chosenColor, setChosenColor] = React.useState(props.defaultValue); + const updateolorsAndCloseMenu = () => { setChosenColor(color); props.onChange(color); closeMenu(); }; + return ( + ( + + )} + renderMenu={() => ( +
+ +
+ + +
+
+ )} + /> + ); +}); + + +ColorInput.displayName = 'ColorInput'; + +ColorInput.propTypes = { + className: PropTypes.string, + defaultValue: PropTypes.string, + onChange: PropTypes.func +}; + +module.exports = ColorInput; \ No newline at end of file diff --git a/src/common/ColorInput/index.js b/src/common/ColorInput/index.js new file mode 100644 index 000000000..ce4fa913a --- /dev/null +++ b/src/common/ColorInput/index.js @@ -0,0 +1,4 @@ +const ColorInput = require('./ColorInput'); + +module.exports = ColorInput; + diff --git a/src/common/ColorInput/styles.less b/src/common/ColorInput/styles.less new file mode 100644 index 000000000..0bea883d3 --- /dev/null +++ b/src/common/ColorInput/styles.less @@ -0,0 +1,11 @@ +.color-input-container { + display: flex; + padding: 10px; + background-color: #000; + flex-direction: row; + + .buttons-container { + padding-left: 1rem; + flex-grow: .5; + } +} \ No newline at end of file diff --git a/src/common/ColorPicker/ColorPicker.js b/src/common/ColorPicker/ColorPicker.js index 341bacb39..f414a349e 100644 --- a/src/common/ColorPicker/ColorPicker.js +++ b/src/common/ColorPicker/ColorPicker.js @@ -4,7 +4,7 @@ const AColorPicker = require('a-color-picker'); const COLOR_FORMAT = 'rgbacss'; -const ColorPicker = ({ className, value, onChange }) => { +const ColorPicker = ({ className, value, onChange, pickerOpts }) => { value = AColorPicker.parseColor(value, COLOR_FORMAT); const pickerRef = React.useRef(null); const pickerElementRef = React.useRef(null); @@ -14,7 +14,8 @@ const ColorPicker = ({ className, value, onChange }) => { showHSL: false, showHEX: false, showRGB: false, - showAlpha: true + showAlpha: true, + ...pickerOpts }); }, []); React.useEffect(() => { diff --git a/src/common/index.js b/src/common/index.js index b22b17376..28bad5f65 100644 --- a/src/common/index.js +++ b/src/common/index.js @@ -1,6 +1,7 @@ const Button = require('./Button'); const Checkbox = require('./Checkbox'); const ColorPicker = require('./ColorPicker'); +const ColorInput = require('./ColorInput'); const Dropdown = require('./Dropdown'); const MainNavBar = require('./MainNavBar'); const MetaItem = require('./MetaItem'); @@ -26,6 +27,7 @@ module.exports = { Button, Checkbox, ColorPicker, + ColorInput, Dropdown, MainNavBar, MetaItem,