From a2eb9734f14590330707c65d18d6c535ef39cca7 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Tue, 11 Jan 2022 20:45:10 +0530 Subject: [PATCH] Add PowerLevelSelector component Signed-off-by: Ajay Bura --- public/res/ic/outlined/check.svg | 7 +++ .../PowerLevelSelector.jsx | 49 +++++++++++++++++++ .../PowerLevelSelector.scss | 20 ++++++++ 3 files changed, 76 insertions(+) create mode 100644 public/res/ic/outlined/check.svg create mode 100644 src/app/molecules/power-level-selector/PowerLevelSelector.jsx create mode 100644 src/app/molecules/power-level-selector/PowerLevelSelector.scss diff --git a/public/res/ic/outlined/check.svg b/public/res/ic/outlined/check.svg new file mode 100644 index 0000000..72a1832 --- /dev/null +++ b/public/res/ic/outlined/check.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/src/app/molecules/power-level-selector/PowerLevelSelector.jsx b/src/app/molecules/power-level-selector/PowerLevelSelector.jsx new file mode 100644 index 0000000..7d531bf --- /dev/null +++ b/src/app/molecules/power-level-selector/PowerLevelSelector.jsx @@ -0,0 +1,49 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import './PowerLevelSelector.scss'; + +import IconButton from '../../atoms/button/IconButton'; +import { MenuHeader, MenuItem } from '../../atoms/context-menu/ContextMenu'; + +import CheckIC from '../../../../public/res/ic/outlined/check.svg'; + +function PowerLevelSelector({ + value, max, onSelect, +}) { + const handleSubmit = (e) => { + const powerLevel = e.target.elements['power-level']; + if (!powerLevel) return; + onSelect(Number(powerLevel)); + }; + + return ( +
+ Power level selector +
{ e.preventDefault(); handleSubmit(e); }}> + + + + {max >= 0 && Presets} + {max >= 100 && onSelect(100)}>Admin - 100} + {max >= 50 && onSelect(50)}>Mod - 50} + {max >= 0 && onSelect(0)}>Member - 0} +
+ ); +} + +PowerLevelSelector.propTypes = { + value: PropTypes.number.isRequired, + max: PropTypes.number.isRequired, + onSelect: PropTypes.func.isRequired, +}; + +export default PowerLevelSelector; diff --git a/src/app/molecules/power-level-selector/PowerLevelSelector.scss b/src/app/molecules/power-level-selector/PowerLevelSelector.scss new file mode 100644 index 0000000..14a151d --- /dev/null +++ b/src/app/molecules/power-level-selector/PowerLevelSelector.scss @@ -0,0 +1,20 @@ +@use '../../partials/flex'; +@use '../../partials/dir'; + +.power-level-selector { + & .context-menu__item .text { + margin: 0 !important; + } + + & form { + margin: var(--sp-normal); + display: flex; + + & input { + @extend .cp-fx__item-one; + @include dir.side(margin, 0, var(--sp-tight)); + width: 148px; + padding: 9px var(--sp-tight); + } + } +} \ No newline at end of file