ISSUE-020 - Plain, static SlotSelector component defined. Not too fancy looking.

To save space and reduce redundant data I created a utility function called findPrefixCount() and wrote a suite of tests for it.
This commit is contained in:
Kyle Geib committed 2022-01-14 17:16:27 -05:00
1 parent 6a8e5f28b2
commit 35ca424dd6
6 files changed
+163 -20

No files matched your search

@@ -1,4 +1,3 @@
import { useState } from "react";
import { useSelector, useDispatch } from "react-redux";
import { Inline } from "@bedrock-layout/inline";
import { PadBox } from "@bedrock-layout/padbox";
@@ -13,31 +12,17 @@ import {
import { Toggle } from "../../Common/Inputs/Toggle";
import { MockupBlock } from "../../Common/MockupBlock.styled";
import { SlotSelector } from "../../Common/Inputs/SlotSelector";
export function OverlayControl() {
const dispatch = useDispatch();
const { overlayIds, visible, currentOverlayItem } = useSelector(overlayToolSelector);
/* For prototyping use only */
const [idNum, setIdNum] = useState(0);
const nextIdNum = () => {
const nextIdNum = (idNum + 1) % overlayIds.length;
setIdNum(nextIdNum);
dispatch(setCurrentOverlayId(overlayIds[nextIdNum]));
};
/* For prototyping use only */
const onToggle = (value: boolean) => {
if (currentOverlayItem == null) {
dispatch(initNewOverlayItem({
overlayId: overlayIds[idNum],
overlayId: overlayIds[0],
initialPosition: { x: 0, y: 0 },
setVisible: true,
}));
@@ -55,9 +40,12 @@ export function OverlayControl() {
onToggle={onToggle}
/>
<PadBox padding="sm">
<MockupBlock color="green" height="1.5rem" width="100%">
Slot selector
</MockupBlock>
<SlotSelector
items={overlayIds}
onChange={(value) => dispatch(setCurrentOverlayId(value))}
removePrefix
formatter={(value) => value.replace(/(\.png)|(\.jpg)$/, "")}
/>
</PadBox>
</Inline>
<PadBox padding="sm">