A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
fix(app): fade carousel steps in order and focus the new step
Hampus3546b6689011
diff --git a/fluxer_app/src/features/guild/components/modals/AddGuildModal.tsx b/fluxer_app/src/features/guild/components/modals/AddGuildModal.tsxindex ecdee9e51..805562019 100644--- a/fluxer_app/src/features/guild/components/modals/AddGuildModal.tsx+++ b/fluxer_app/src/features/guild/components/modals/AddGuildModal.tsx@@ -77,7 +77,12 @@ export const AddGuildModal = observer(({initialView = 'landing'}: {initialView?:<Modal.Root size="small" centered data-flx="guild.add-guild-modal.modal-root"><Modal.Header title={getTitle()} data-flx="guild.add-guild-modal.modal-header" /><Modal.Content contentClassName={styles.content} data-flx="guild.add-guild-modal.modal-content">- <SteppedCarousel step={view} steps={ADD_GUILD_VIEW_ORDER} data-flx="guild.add-guild-modal.stepped-carousel">+ <SteppedCarousel+ step={view}+ steps={ADD_GUILD_VIEW_ORDER}+ focusOnStepChange+ data-flx="guild.add-guild-modal.stepped-carousel"+ >{renderView()}</SteppedCarousel></Modal.Content>diff --git a/fluxer_app/src/features/ui/stepped_carousel/SteppedCarousel.module.css b/fluxer_app/src/features/ui/stepped_carousel/SteppedCarousel.module.cssindex 03a9f7c96..9dda571d0 100644--- a/fluxer_app/src/features/ui/stepped_carousel/SteppedCarousel.module.css+++ b/fluxer_app/src/features/ui/stepped_carousel/SteppedCarousel.module.css@@ -6,7 +6,8 @@flex: 0 0 auto;flex-direction: column;gap: inherit;- overflow: hidden;+ margin: -0.5rem;+ overflow: clip;}.pane {@@ -14,7 +15,9 @@flex-direction: column;gap: inherit;flex: 0 0 auto;+ box-sizing: border-box;width: 100%;+ padding: 0.5rem;}.actions {diff --git a/fluxer_app/src/features/ui/stepped_carousel/SteppedCarousel.tsx b/fluxer_app/src/features/ui/stepped_carousel/SteppedCarousel.tsxindex 30cb6e656..5a01f12d0 100644--- a/fluxer_app/src/features/ui/stepped_carousel/SteppedCarousel.tsx+++ b/fluxer_app/src/features/ui/stepped_carousel/SteppedCarousel.tsx@@ -28,10 +28,22 @@ interface SteppedCarouselActionsProps extends React.HTMLAttributes<HTMLElement>children: React.ReactNode;}+const SLIDE_DISTANCE_PX = 24;++function getSlideOffset(direction: number): number {+ if (direction > 0) {+ return SLIDE_DISTANCE_PX;+ }+ if (direction < 0) {+ return -SLIDE_DISTANCE_PX;+ }+ return 0;+}+const slideVariants: Variants = {enter: (direction: number) => ({opacity: 0,- x: direction > 0 ? 24 : direction < 0 ? -24 : 0,+ x: getSlideOffset(direction),}),center: {opacity: 1,@@ -40,8 +52,8 @@ const slideVariants: Variants = {},exit: (direction: number) => ({opacity: 0,- x: direction > 0 ? -24 : direction < 0 ? 24 : 0,- transition: {duration: 0.1, ease: 'easeIn'},+ x: getSlideOffset(-direction),+ transition: {duration: 0.08, ease: 'easeIn'},}),};const heightTransition: Transition = {@@ -115,6 +127,7 @@ export function SteppedCarousel<Step extends string>({const model = selectSteppedCarouselModel(nextSnapshot);const paneRef = useRef<HTMLDivElement | null>(null);const pendingFocusRequestRef = useRef(0);+ pendingFocusRequestRef.current = model.focusRequestId;const handledFocusRequestRef = useRef(0);const onStepShownRef = useRef(onStepShown);const paneStep = step;@@ -157,9 +170,6 @@ export function SteppedCarousel<Step extends string>({},[measureNode, paneStep],);- useLayoutEffect(() => {- pendingFocusRequestRef.current = model.focusRequestId;- }, [model.focusRequestId]);useLayoutEffect(() => {onStepShownRef.current = onStepShown;});@@ -173,7 +183,7 @@ export function SteppedCarousel<Step extends string>({data-flx={dataFlx ?? 'ui.stepped-carousel.container'}><AnimatePresence- mode="popLayout"+ mode="wait"initial={false}custom={model.direction}data-flx="ui.stepped-carousel.stepped-carousel.animate-presence"