Skip to content

Commit

Permalink
Style deployment required page with new error alert component (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
JunichiSugiura authored Jun 13, 2024
1 parent b6e26ef commit d8ee2ac
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 13 deletions.
45 changes: 32 additions & 13 deletions packages/keychain/src/components/DeploymentRequired.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { constants } from "starknet";
import { Container, Footer, Content } from "components/layout";
import { useEffect, useState } from "react";
import { Status } from "utils/account";
import { Loading } from "./Loading";
import { Button, Link, Text } from "@chakra-ui/react";
import { ExternalIcon } from "@cartridge/ui";
import { ExternalIcon, PacmanIcon } from "@cartridge/ui";
import { useController } from "hooks/controller";
import { ErrorAlert } from "./ErrorAlert";
import NextLink from "next/link"

export function DeploymentRequired({
onClose,
Expand Down Expand Up @@ -60,11 +61,11 @@ export function DeploymentRequired({
if (status !== Status.DEPLOYED) {
return (
<Container
Icon={Loading}
icon={<PacmanIcon color="brand.primary" fontSize="3xl" />}
title={"Deploying your account"}
description="This may take a second"
>
<Content>
<Content alignItems="center">
{status === Status.DEPLOYING && (
<Link
href={`https://${account.chainId === constants.StarknetChainId.SN_SEPOLIA
Expand All @@ -78,18 +79,36 @@ export function DeploymentRequired({
</Button>
</Link>
)}

{error && (
<>
<Text>
We encounter an account deployment error: {error.message}
</Text>
<Text>Please come by discord and report this issue.</Text>
</>
)}
</Content>

<Footer>
<ErrorAlert title="Account deployment error" description={
error ? (
<>
<Text mb={4}>
Please come by{" "}
<Link
as={NextLink}
href="https://discord.gg/cartridge"
isExternal
color="link.blue"
display="inline-flex"
flexDir="row"
columnGap="0.1rem"
alignItems="center"
>
Discord
<ExternalIcon />
</Link>
{" "}and report this issue.
</Text>

<Text>
{error.message}
</Text>
</>
) : undefined
} />
<Button onClick={onClose}>close</Button>
</Footer>
</Container>
Expand Down
49 changes: 49 additions & 0 deletions packages/keychain/src/components/ErrorAlert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { AlertIcon } from "@cartridge/ui";
import {
Text,
Accordion,
AccordionItem,
AccordionButton,
AccordionPanel,
AccordionIcon,
Spacer,
HStack,
} from "@chakra-ui/react";
import { motion } from "framer-motion";
import { ReactElement } from "react";

export function ErrorAlert({ title, description }: { title: string; description?: string | ReactElement }) {
return (
<Accordion
as={motion.div}
w="full"
initial={{ height: 0 }}
animate={{ height: "auto" }}
allowToggle
variant="error"
color="text.primary"
fontSize="sm"
>
<AccordionItem position="relative">
<AccordionButton disabled={!description}>
<HStack>
<AlertIcon />
<Text as="b" fontSize="2xs" color="inherit" textTransform="uppercase">
{title}
</Text>
</HStack>

<Spacer />

{description && <AccordionIcon boxSize={5} />}
</AccordionButton>

{description && (
<AccordionPanel borderTop="1px solid" borderColor="translucent.soft">
<Text color="inherit">{description}</Text>
</AccordionPanel>
)}
</AccordionItem>
</Accordion>
);
}

0 comments on commit d8ee2ac

Please sign in to comment.