Skip to content

Commit

Permalink
Add welcome view
Browse files Browse the repository at this point in the history
  • Loading branch information
serjonya-trili committed Aug 13, 2024
1 parent 40fa603 commit 57eb6c2
Show file tree
Hide file tree
Showing 16 changed files with 312 additions and 139 deletions.
25 changes: 0 additions & 25 deletions apps/web/src/App.tsx

This file was deleted.

29 changes: 29 additions & 0 deletions apps/web/src/App/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { mockImplicitAccount } from "@umami/core";
import { addTestAccount, makeStore } from "@umami/state";

import { App } from "./App";
import { render, screen } from "../testUtils";

jest.mock("@chakra-ui/react", () => ({
...jest.requireActual("@chakra-ui/react"),
useBreakpointValue: jest.fn(map => map["lg"]),
}));

describe("<App />", () => {
it("renders welcome screen for a new user", () => {
render(<App />);

expect(screen.getByTestId("welcome-view")).toBeVisible();
expect(screen.queryByTestId("signed-in-layout")).not.toBeInTheDocument();
});

it("renders signed-in layout for an existing user", () => {
const store = makeStore();
addTestAccount(store, mockImplicitAccount(0));

render(<App />, { store });

expect(screen.getByTestId("signed-in-layout")).toBeVisible();
expect(screen.queryByTestId("welcome-view")).not.toBeInTheDocument();
});
});
17 changes: 17 additions & 0 deletions apps/web/src/App/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useCurrentAccount } from "@umami/state";

import { BeaconProvider } from "../components/beacon";
import { Layout } from "../Layout";
import { Welcome } from "../views/Welcome";

export const App = () => {
const currentAccount = useCurrentAccount();

return currentAccount ? (
<BeaconProvider>
<Layout />
</BeaconProvider>
) : (
<Welcome />
);
};
1 change: 1 addition & 0 deletions apps/web/src/App/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./App";
1 change: 1 addition & 0 deletions apps/web/src/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const Layout = () => {
}}
height={{ lg: "100vh", base: "100dvh" }}
padding={{ lg: "20px 46px 0", base: "54px 0 0" }}
data-testid="signed-in-layout"
>
<GridItem
position={{ base: "fixed", lg: "static" }}
Expand Down
11 changes: 6 additions & 5 deletions apps/web/src/assets/icons/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as AddContactIcon } from "./add-contact-s.svg";
export { default as AlertCircleIcon } from "./alert-circle.svg";
export { default as AlertIcon } from "./alert.svg";
export { default as ArrowDownLeftIcon } from "./arrow-down-left.svg";
export { default as ArrowLeftCircleIcon } from "./arrow-left-circle.svg";
Expand All @@ -15,10 +16,10 @@ export { default as CrossedCircleIcon } from "./crossed-circle.svg";
export { default as DelegateIcon } from "./delegate-s.svg";
export { default as DownloadIcon } from "./download.svg";
export { default as EditIcon } from "./edit.svg";
export { default as EyeIcon } from "./eye.svg";
export { default as EyeOffIcon } from "./eye-off.svg";
export { default as EnvelopeIcon } from "./envelope.svg";
export { default as ExternalLinkIcon } from "./external-link.svg";
export { default as EyeIcon } from "./eye.svg";
export { default as EyeOffIcon } from "./eye-off.svg";
export { default as FA12Icon } from "./fa12.svg";
export { default as FA2Icon } from "./fa2.svg";
export { default as FacebookIcon } from "./facebook.svg";
Expand All @@ -28,6 +29,7 @@ export { default as GoogleIcon } from "./google.svg";
export { default as HourglassIcon } from "./hourglass.svg";
export { default as IncomingArrowIcon } from "./incoming-arrow.svg";
export { default as KeyIcon } from "./key.svg";
export { default as LockIcon } from "./lock.svg";
export { default as LogoDarkIcon } from "./logo-dark.svg";
export { default as LogoLightIcon } from "./logo-light.svg";
export { default as LogoutIcon } from "./logout.svg";
Expand All @@ -37,11 +39,13 @@ export { default as MoonIcon } from "./moon.svg";
export { default as MultisigIcon } from "./multisig.svg";
export { default as OutgoingArrowIcon } from "./outgoing-arrow.svg";
export { default as PlusIcon } from "./plus.svg";
export { default as RadioIcon } from "./radio.svg";
export { default as RedditIcon } from "./reddit.svg";
export { default as SearchIcon } from "./search.svg";
export { default as SelectorIcon } from "./selector.svg";
export { default as SettingsIcon } from "./settings.svg";
export { default as TagIcon } from "./tag.svg";
export { default as TezosLogoIcon } from "./tezos-logo.svg";
export { default as ThreeDotsIcon } from "./three-dots.svg";
export { default as TrashIcon } from "./trash.svg";
export { default as TwitterIcon } from "./twitter.svg";
Expand All @@ -50,9 +54,6 @@ export { default as USBIcon } from "./usb.svg";
export { default as UserPlusIcon } from "./user-plus.svg";
export { default as VerifiedIcon } from "./verified.svg";
export { default as WalletIcon } from "./wallet.svg";
export { default as RadioIcon } from "./radio.svg";
export { default as LockIcon } from "./lock.svg";
export { default as AlertCircleIcon } from "./alert-circle.svg";
export { TokenIcon } from "./TokenIcon";

import CloseIcon from "./close.svg";
Expand Down
6 changes: 6 additions & 0 deletions apps/web/src/assets/icons/tezos-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import { ThreeDotsIcon } from "../../assets/icons";
import { useColor } from "../../styles/useColor";
import { AccountTile } from "../AccountTile";
import { ModalCloseButton } from "../CloseButton";
import { useOnboardingModal } from "../Onboarding/useOnboardingModal";

export const AccountSelectorModal = () => {
const accounts = useImplicitAccounts();
const color = useColor();
const getBalance = useGetAccountBalance();
const { onOpen: openOnboardingModal, modalElement } = useOnboardingModal();
// TODO: add ConnectOptions onboarding modal
const { onOpen: openOnboardingModal, modalElement } = { modalElement: null, onOpen: () => {} };
const { onClose } = useDynamicModalContext();

const dispatch = useDispatch();
Expand Down
16 changes: 12 additions & 4 deletions apps/web/src/components/AccountTile/AccountTileIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,27 @@ export const AccountTileIcon = ({ account }: { account: ImplicitAccount }) => {
case "social": {
switch (account.idp) {
case "facebook":
return <Icon as={FacebookIcon} width="48px" height="48px" />;
return <FacebookAccountIcon />;
case "google":
return <Icon as={GoogleIcon} width="48px" height="48px" />;
return <GoogleAccountIcon />;
case "twitter":
return <Icon as={TwitterIcon} width="28px" height="28px" />;
return <TwitterAccountIcon />;
case "email":
return <Icon as={EnvelopeIcon} width="28px" height="28px" color={color("600")} />;
case "reddit":
return <Icon as={RedditIcon} width="28px" height="28px" />;
return <RedditAccountIcon />;
}
}
// eslint-disable-next-line no-fallthrough
case "secret_key":
return <Icon as={KeyIcon} width="28px" height="28px" color={color("600")} />;
}
};

export const FacebookAccountIcon = () => <Icon as={FacebookIcon} width="48px" height="48px" />;

export const GoogleAccountIcon = () => <Icon as={GoogleIcon} width="48px" height="48px" />;

export const TwitterAccountIcon = () => <Icon as={TwitterIcon} width="28px" height="28px" />;

export const RedditAccountIcon = () => <Icon as={RedditIcon} width="28px" height="28px" />;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { useImplicitAccounts } from "@umami/state";
import { ConnectOptions } from "./connectOptions/ConnectOptions";
import { ConnectOrCreate } from "./connectOrCreate/ConnectOrCreate";
import { DerivationPath } from "./derivationPath/DerivationPath";
import { Eula } from "./eula/Eula";
import { FakeAccount } from "./FakeAccount";
import { MasterPassword } from "./masterPassword/MasterPassword";
import { ModalBackButton } from "./ModalBackButton";
Expand All @@ -26,12 +25,10 @@ import { ShowSeedphrase } from "./showSeedphrase/ShowSeedphrase";
import { VerifySeedphrase } from "./verifySeedphrase/VerifySeedphrase";

// TODO: rebuild it for the web.
export const useOnboardingModal = (onModalClose?: () => void) => {
export const OnboardingModal = (onModalClose?: () => void) => {
const { isOpen, onOpen, onClose } = useDisclosure();
const hasAccounts = useImplicitAccounts().length !== 0;
const history = useStepHistory<OnboardingStep>({
type: hasAccounts ? "connectOrCreate" : "eula",
});
const history = useStepHistory<OnboardingStep>({ type: "connectOrCreate" });
const { currentStep, goToStep } = history;

const closeModal = () => {
Expand All @@ -42,8 +39,6 @@ export const useOnboardingModal = (onModalClose?: () => void) => {

const getStepPage = () => {
switch (currentStep.type) {
case "eula":
return <Eula goToStep={goToStep} />;
case "connectOrCreate":
return <ConnectOrCreate closeModal={closeModal} goToStep={goToStep} />;
case "connectOptions":
Expand Down
2 changes: 0 additions & 2 deletions apps/web/src/components/Onboarding/OnboardingStep.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export type OnboardingStep =
| EulaStep
| ConnectOrCreateStep
| NoticeStep
| ConnectOptionsStep
Expand All @@ -14,7 +13,6 @@ export type OnboardingStep =
| MasterPasswordStep
| FakeAccountStep;

type EulaStep = { type: "eula" };
type ConnectOrCreateStep = { type: "connectOrCreate" };
type NoticeStep = { type: "notice" };
type ConnectOptionsStep = { type: "connectOptions" };
Expand Down
36 changes: 0 additions & 36 deletions apps/web/src/components/Onboarding/eula/Eula.test.tsx

This file was deleted.

57 changes: 0 additions & 57 deletions apps/web/src/components/Onboarding/eula/Eula.tsx

This file was deleted.

6 changes: 5 additions & 1 deletion apps/web/src/styles/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type StyleFunctionProps, mode } from "@chakra-ui/theme-tools";
import { dark, light } from "./colors";

const config = {
initialColorMode: "light",
initialColorMode: "dark",
useSystemColorMode: false,
};

Expand Down Expand Up @@ -93,6 +93,10 @@ const theme = extendTheme({
fontSize: "24px",
lineHeight: "32px",
},
"3xl": {
fontSize: "30px",
lineHeight: "36px",
},
},
},
Card: {
Expand Down
Loading

0 comments on commit 57eb6c2

Please sign in to comment.