Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Simplify Space onboarding

Anand Baburajane85d548d63dc
diff --git a/web/apps/space/src/screens/OnboardingScreen.tsx b/web/apps/space/src/screens/OnboardingScreen.tsx
index 165a504090..17d920b11c 100644
--- a/web/apps/space/src/screens/OnboardingScreen.tsx
+++ b/web/apps/space/src/screens/OnboardingScreen.tsx
@@ -1,39 +1,15 @@
import { Box } from "@mui/material";
import { EnteLogo } from "ente-base/components/EnteLogo";
-import React, { useEffect, useRef, useState } from "react";
-import { spaceTouchTargetSize } from "styles/touchTargets";
+import React from "react";
export const onboardingGreen = "#08C225";
export const onboardingTitle = "Share your life";
export const onboardingDescription =
- "A private, end-to-end encrypted space for sharing everyday moments with friends and family";
+ "A private space for sharing everyday moments with friends and family. No ads. No brain rot. No strangers.";
export const addFriendOnboardingTitle = "Follow their life";
const softGreen = "#E7F6E9";
const copyGreen = "#AAFFB8";
-const activePaginationGreen = "#07951D";
-const inactivePaginationGreen = "#5EE873";
-const carouselSlideDurationMs = 4800;
-
-const onboardingSlides = [
- {
- description: onboardingDescription,
- image: "/images/share-memories.svg",
- title: onboardingTitle,
- },
- {
- description:
- "Only you and your friends can see what you share. Everything is end-to-end encrypted.",
- image: "/images/share-memories.svg",
- title: "Private by design",
- },
- {
- description:
- "No brain rot. No ads. No strangers. Just everyday photos from friends and family.",
- image: "/images/share-memories.svg",
- title: "Just your people",
- },
-] as const;
interface ActionButtonProps {
children: React.ReactNode;
@@ -87,130 +63,12 @@ interface OnboardingScreenProps {
title?: string;
}
-interface OnboardingPaginationDotsProps {
- activeSlideIndex: number;
- onShowSlide: (index: number) => void;
- slides: readonly { title: string }[];
-}
-
-const OnboardingPaginationDots: React.FC<OnboardingPaginationDotsProps> = ({
- activeSlideIndex,
- onShowSlide,
- slides,
-}) => (
- <Box
- sx={{
- alignItems: "center",
- display: "flex",
- flexShrink: 0,
- gap: "14px",
- justifyContent: "center",
- mt: "26px",
- }}
- >
- {slides.map((slide, index) => (
- <Box
- key={slide.title}
- component="button"
- type="button"
- aria-label={`Show onboarding page ${index + 1}`}
- aria-current={activeSlideIndex == index ? "page" : undefined}
- onClick={() => onShowSlide(index)}
- sx={{
- alignItems: "center",
- bgcolor: "transparent",
- border: 0,
- borderRadius: "999px",
- cursor: "pointer",
- display: "flex",
- height: spaceTouchTargetSize,
- justifyContent: "center",
- p: 0,
- width: spaceTouchTargetSize,
- "&:focus-visible": {
- outline: "2px solid white",
- outlineOffset: 4,
- },
- }}
- >
- <Box
- component="span"
- sx={{
- bgcolor:
- activeSlideIndex == index
- ? activePaginationGreen
- : inactivePaginationGreen,
- borderRadius: "999px",
- height: 10,
- transition:
- "background-color 180ms ease, height 180ms ease, width 180ms ease",
- width: activeSlideIndex == index ? 24 : 10,
- "@media (prefers-reduced-motion: reduce)": {
- transition: "none",
- },
- }}
- />
- </Box>
- ))}
- </Box>
-);
-
export const OnboardingScreen: React.FC<OnboardingScreenProps> = ({
description = onboardingDescription,
onCreateAccount,
onLogin,
title = onboardingTitle,
}) => {
- const [activeSlideIndex, setActiveSlideIndex] = useState(0);
- const touchStartXRef = useRef<number | null>(null);
- const slides = onboardingSlides.map((slide, index) =>
- index == 0 ? { ...slide, description, title } : slide,
- );
-
- useEffect(() => {
- const prefersReducedMotion = window.matchMedia(
- "(prefers-reduced-motion: reduce)",
- ).matches;
- if (prefersReducedMotion) return undefined;
-
- const timeoutID = window.setTimeout(() => {
- setActiveSlideIndex((index) => (index + 1) % slides.length);
- }, carouselSlideDurationMs);
-
- return () => window.clearTimeout(timeoutID);
- }, [activeSlideIndex, slides.length]);
-
- const showSlide = (index: number) => setActiveSlideIndex(index);
-
- const showPreviousSlide = () =>
- setActiveSlideIndex(
- (index) => (index - 1 + slides.length) % slides.length,
- );
-
- const showNextSlide = () =>
- setActiveSlideIndex((index) => (index + 1) % slides.length);
-
- const handleTouchStart: React.TouchEventHandler<HTMLDivElement> = (
- event,
- ) => {
- touchStartXRef.current = event.touches[0]?.clientX ?? null;
- };
-
- const handleTouchEnd: React.TouchEventHandler<HTMLDivElement> = (event) => {
- const startX = touchStartXRef.current;
- touchStartXRef.current = null;
- const endX = event.changedTouches[0]?.clientX;
- if (startX == null || endX == null) return;
-
- const deltaX = endX - startX;
- if (Math.abs(deltaX) < 44) return;
- if (deltaX > 0) {
- showPreviousSlide();
- } else {
- showNextSlide();
- }
- };
-
return (
<Box
className="green-bg"
@@ -278,110 +136,76 @@ export const OnboardingScreen: React.FC<OnboardingScreenProps> = ({
}}
>
<Box
- onTouchEnd={handleTouchEnd}
- onTouchStart={handleTouchStart}
sx={{
+ alignItems: "center",
+ display: "flex",
+ flexDirection: "column",
flexShrink: 0,
+ justifyContent: "center",
+ minWidth: 0,
overflow: "hidden",
width: "100%",
}}
>
<Box
+ component="img"
+ alt=""
+ src="/images/share-memories.svg"
sx={{
+ flexShrink: 0,
+ height: "clamp(132px, 29svh, 245.189px)",
+ maxWidth: "min(282px, 76vw)",
+ width: "auto",
+ "@media (max-width: 340px)": {
+ height: "auto",
+ width: "76vw",
+ },
+ }}
+ />
+ <Box
+ sx={{
+ alignItems: "center",
display: "flex",
- transform: `translateX(-${activeSlideIndex * 100}%)`,
- transition:
- "transform 360ms cubic-bezier(0.32, 0.72, 0, 1)",
+ flexDirection: "column",
+ flexShrink: 0,
+ mt: "clamp(28px, 7svh, 60px)",
+ textAlign: "center",
width: "100%",
- "@media (prefers-reduced-motion: reduce)": {
- transition: "none",
- },
+ "@media (min-height: 760px)": { mt: "92px" },
}}
>
- {slides.map((slide) => (
- <Box
- key={slide.title}
- sx={{
- alignItems: "center",
- display: "flex",
- flex: "0 0 100%",
- flexDirection: "column",
- justifyContent: "center",
- minWidth: 0,
- overflow: "hidden",
- width: "100%",
- }}
- >
- <Box
- component="img"
- alt=""
- src={slide.image}
- sx={{
- flexShrink: 0,
- height: "clamp(132px, 29svh, 245.189px)",
- maxWidth: "min(282px, 76vw)",
- width: "auto",
- "@media (max-width: 340px)": {
- height: "auto",
- width: "76vw",
- },
- }}
- />
- <Box
- sx={{
- alignItems: "center",
- display: "flex",
- flexDirection: "column",
- flexShrink: 0,
- mt: "clamp(28px, 7svh, 60px)",
- textAlign: "center",
- width: "100%",
- "@media (min-height: 760px)": {
- mt: "92px",
- },
- }}
- >
- <Box
- component="h1"
- sx={{
- fontFamily:
- "Nunito, sans-serif",
- fontSize: 24,
- fontWeight: 800,
- letterSpacing: 0,
- lineHeight: "29px",
- m: 0,
- whiteSpace: "nowrap",
- }}
- >
- {slide.title}
- </Box>
- <Box
- component="p"
- sx={{
- color: copyGreen,
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- fontWeight: 500,
- lineHeight: "20px",
- m: 0,
- mt: "12px",
- width: "100%",
- }}
- >
- {slide.description}
- </Box>
- </Box>
- </Box>
- ))}
+ <Box
+ component="h1"
+ sx={{
+ fontFamily: "Nunito, sans-serif",
+ fontSize: 24,
+ fontWeight: 800,
+ letterSpacing: 0,
+ lineHeight: "29px",
+ m: 0,
+ whiteSpace: "nowrap",
+ }}
+ >
+ {title}
+ </Box>
+ <Box
+ component="p"
+ sx={{
+ color: copyGreen,
+ fontFamily:
+ '"Inter Variable", Inter, sans-serif',
+ fontSize: 14,
+ fontWeight: 500,
+ lineHeight: "20px",
+ m: 0,
+ mt: "12px",
+ width: "100%",
+ }}
+ >
+ {description}
+ </Box>
</Box>
</Box>
- <OnboardingPaginationDots
- activeSlideIndex={activeSlideIndex}
- onShowSlide={showSlide}
- slides={slides}
- />
</Box>
<Box
sx={{