ISSUE-045 - Venetian Blinds - Improvements to prototype state management by using partial state updates, which are pretty useful.
More props for <VenentianBlindsTransition>.
This commit is contained in:
1 parent
14e4c0569d
commit
3ce590d794
6 files changed
+90
-60
No files matched your search
+6
-4
@@ -17,8 +17,9 @@ export function VenetianBlindsWorkspace() {
|
||||
{prototypeState?.venetianTransition?.mode === "driverPortrait" ? (
|
||||
<VenetianBlindsTransition
|
||||
blindsColor={theme.colors.teams.mercedes + "b5"}
|
||||
degrees={35}
|
||||
duration={500}
|
||||
blindsAngle={-45}
|
||||
wipeAngle={45}
|
||||
wipeDuration={500}
|
||||
wipeStartingCorner="topLeft"
|
||||
>
|
||||
<DriverPortrait
|
||||
@@ -29,8 +30,9 @@ export function VenetianBlindsWorkspace() {
|
||||
) : (
|
||||
<VenetianBlindsTransition
|
||||
blindsColor="#f60d0db5"
|
||||
degrees={45}
|
||||
duration={350}
|
||||
blindsAngle={-45}
|
||||
wipeAngle={35}
|
||||
wipeDuration={350}
|
||||
wipeStartingCorner="bottomRight"
|
||||
>
|
||||
<PositionFlag size={122} number={1} />
|
||||
|
||||
+6
-26
@@ -1,9 +1,8 @@
|
||||
import { PadBox } from "@bedrock-layout/padbox";
|
||||
import { Split } from "@bedrock-layout/split";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
|
||||
import { useDispatch } from "react-redux";
|
||||
|
||||
import { setPrototypeState } from "../../../../features/workspace/workspaceSlice";
|
||||
import { updateAngledFlagCountry, updateAngledFlagTeam } from "../../../../features/workspace/workspaceSlice";
|
||||
import { FlagMode, TeamId } from "../../../../types/state";
|
||||
|
||||
import { SlotSelector } from "../../../Common/Inputs/SlotSelector";
|
||||
@@ -17,41 +16,22 @@ const teams: Array<TeamId> = [
|
||||
"mclaren", "mercedes", "redBull", "williams",
|
||||
];
|
||||
|
||||
const DEFAULT_COUNTRY = "GBR";
|
||||
const DEFAULT_TEAM: TeamId = "alfaRomeo";
|
||||
|
||||
type AngledFlagPrototypeControlsProps = {
|
||||
flagMode: FlagMode,
|
||||
};
|
||||
export function AngledFlagPrototypeControls({ flagMode }: AngledFlagPrototypeControlsProps) {
|
||||
const dispatch = useDispatch();
|
||||
const { prototypeState } = useSelector(workspaceSelector);
|
||||
const flagList = flagMode === "country" ? countries : flagMode === "team" ? teams : [];
|
||||
|
||||
const onChange = (flag: "flagA" | "flagB") => (index: number) => {
|
||||
if (flagMode === "country") {
|
||||
dispatch(setPrototypeState({
|
||||
angledFlagCountry: {
|
||||
flagA: flag === "flagA"
|
||||
? countries[index]
|
||||
: prototypeState?.angledFlagCountry?.flagA ?? DEFAULT_COUNTRY,
|
||||
flagB: flag === "flagB"
|
||||
? countries[index]
|
||||
: prototypeState?.angledFlagCountry?.flagB ?? DEFAULT_COUNTRY,
|
||||
},
|
||||
dispatch(updateAngledFlagCountry({
|
||||
[flag]: countries[index],
|
||||
}));
|
||||
} else if (flagMode === "team") {
|
||||
dispatch(setPrototypeState({
|
||||
angledFlagTeam: {
|
||||
flagA: flag === "flagA"
|
||||
? teams[index]
|
||||
: prototypeState?.angledFlagTeam?.flagA ?? DEFAULT_TEAM,
|
||||
flagB: flag === "flagB"
|
||||
? teams[index]
|
||||
: prototypeState?.angledFlagTeam?.flagB ?? DEFAULT_TEAM,
|
||||
},
|
||||
dispatch(updateAngledFlagTeam({
|
||||
[flag]: teams[index],
|
||||
}));
|
||||
|
||||
}
|
||||
};
|
||||
return (
|
||||
|
||||
+7
-12
@@ -1,8 +1,9 @@
|
||||
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
||||
import { PadBox } from "@bedrock-layout/padbox";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
|
||||
import { setPrototypeState } from "../../../../features/workspace/workspaceSlice";
|
||||
import { updateVenetianTransition } from "../../../../features/workspace/workspaceSlice";
|
||||
import { VenetianTransitionWorkspaceMode } from "../../../../types/state";
|
||||
|
||||
import { SlotSelector } from "../../../Common/Inputs/SlotSelector";
|
||||
@@ -18,20 +19,14 @@ export function VenetianBlindsPrototypeControls() {
|
||||
const { prototypeState } = useSelector(workspaceSelector);
|
||||
|
||||
const onChange = (index: number) => {
|
||||
dispatch(setPrototypeState({
|
||||
venetianTransition: {
|
||||
mode: modes[index],
|
||||
showBG: prototypeState?.venetianTransition?.showBG ?? false,
|
||||
},
|
||||
dispatch(updateVenetianTransition({
|
||||
mode: modes[index],
|
||||
}));
|
||||
};
|
||||
|
||||
const onToggle = (value: boolean) => {
|
||||
dispatch(setPrototypeState({
|
||||
venetianTransition: {
|
||||
mode: prototypeState?.venetianTransition?.mode ?? "positionFlag",
|
||||
showBG: value,
|
||||
},
|
||||
dispatch(updateVenetianTransition({
|
||||
showBG: value,
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -44,7 +39,7 @@ export function VenetianBlindsPrototypeControls() {
|
||||
slotWidth="200px"
|
||||
/>
|
||||
<Toggle
|
||||
toggled={prototypeState?.venetianTransition?.showBG ?? false}
|
||||
toggled={prototypeState?.venetianTransition?.showBG ?? true}
|
||||
onToggle={onToggle}
|
||||
label="Show BG"
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user