diff --git a/apps/desktop/src/ui/components/base/Dropdown.module.scss b/apps/desktop/src/ui/components/base/Dropdown.module.scss index 0270c908..5c394910 100644 --- a/apps/desktop/src/ui/components/base/Dropdown.module.scss +++ b/apps/desktop/src/ui/components/base/Dropdown.module.scss @@ -3,8 +3,13 @@ .list { @apply bg-secondary rounded-lg border border-gray-05 p-1 shadow-md shadow-black/30; - @apply flex flex-col gap-2; + @apply flex-col gap-2; @apply max-h-46 overflow-auto; + @apply hidden; + + &.visible { + @apply flex; + } } .row { diff --git a/apps/desktop/src/ui/components/base/Dropdown.tsx b/apps/desktop/src/ui/components/base/Dropdown.tsx index aef2bab0..df07d3cf 100644 --- a/apps/desktop/src/ui/components/base/Dropdown.tsx +++ b/apps/desktop/src/ui/components/base/Dropdown.tsx @@ -72,7 +72,7 @@ function Dropdown(props: DropdownProps) { ref.classList.add(...split.dropdownClass.split(' ')); }} > - + {(item, index) => (
select(index)}> @@ -91,6 +91,7 @@ function Dropdown(props: DropdownProps) { Dropdown.Row = function (props: ParentProps) { return ( + // TODO(a11y): tabIndex
{props.children}
diff --git a/apps/desktop/src/ui/components/overlay/cluster/ClusterCreationModal.tsx b/apps/desktop/src/ui/components/overlay/cluster/ClusterCreationModal.tsx index a2f410ee..1f0d1817 100644 --- a/apps/desktop/src/ui/components/overlay/cluster/ClusterCreationModal.tsx +++ b/apps/desktop/src/ui/components/overlay/cluster/ClusterCreationModal.tsx @@ -1,18 +1,23 @@ -import { type Accessor, type Context, Match, type ParentProps, type Setter, Switch, createContext, createEffect, createSignal, useContext } from 'solid-js'; +import { type Accessor, type Context, Match, type ParentProps, type Setter, Show, Switch, createContext, createEffect, createSignal, on, useContext } from 'solid-js'; import { ArrowRightIcon, Server01Icon } from '@untitled-theme/icons-solid'; import HeaderImage from '../../../../assets/images/header.png'; import FullscreenOverlay, { type FullscreenOverlayProps } from '../FullscreenOverlay'; import ClusterStepOne from './ClusterStepOne'; import { ClusterStepTwo } from './ClusterStepTwo'; import Button from '~ui/components/base/Button'; +import type { CreateCluster } from '~bindings'; + +type PartialCluster = Partial; // Why the fuck do I need to use a context for all this??? // TODO: Rewrite for use with the new Modal stacking system -type ClusterModalContextFunc = [ - step: Accessor, - setStep: Setter, - setVisible: Setter, -]; +interface ClusterModalContextFunc { + step: Accessor; + setStep: Setter; + partialCluster: Accessor; + setPartialCluster: Setter; + setVisible: Setter; +} const ClusterModalContext = createContext() as Context; @@ -26,39 +31,35 @@ type ClusterModalStagesLength = UnionToArray['l export function ClusterModalController(props: ParentProps) { const [step, setStep] = createSignal(ClusterModalStages.STAGE_1_PROVIDER); const [visible, setVisible] = createSignal(false); - const [canGoForward, setCanGoForward] = createSignal(false); + const [partialCluster, setPartialCluster] = createSignal({}); - const stepper: ClusterModalContextFunc = [ + const stepper: ClusterModalContextFunc = { step, setStep, + partialCluster, + setPartialCluster, setVisible, - ]; + }; createEffect(() => { if (visible() === false) setStep(ClusterModalStages.STAGE_1_PROVIDER); }); - const stepComponents = [ - ClusterStepOne, - ClusterStepTwo, - ]; - return ( {props.children} - - {(stepComponents[step()]!({ - canGoForward, setCanGoForward, - }))} - + + {/* Makes sure theres a new instance of the modal */} + + + ); } @@ -68,24 +69,38 @@ export function useClusterModalController() { } export interface ClusterStepProps { - canGoForward: Accessor; setCanGoForward: Setter; + visible: Accessor; }; type ClusterCreationModalProps = FullscreenOverlayProps & { step: Accessor; setStep: Setter; buttonIsNext: boolean; - canGoForward: Accessor; }; function ClusterCreationModal(props: ClusterCreationModalProps) { + const [canGoForward, setCanGoForward] = createSignal(false); // Indexed by the current step const messages: FixedArray = [ 'Provider selection', 'Game Setup', ]; + createEffect(on(() => props.step(), () => { + setCanGoForward(false); + })); + + const stepComponents = [ + ClusterStepOne, + ClusterStepTwo, + ].map((component, index) => component({ + setCanGoForward, + visible: () => props.step() === index, + })); + + const Step = (props: { step: number }) => <>{stepComponents[props.step]}; + return (
- {props.children} +
@@ -138,7 +153,7 @@ function ClusterCreationModal(props: ClusterCreationModalProps) {