Skip to content

Commit

Permalink
Sunset chakra components from layout (#1267)
Browse files Browse the repository at this point in the history
* Replace layout wrapper with TW classes

* Replace layout footer with TW classes

* Remove chakra components from layout Content

* Remove layout context

* Fix footer height

* Fix content height

* Remove chakra components from layout header

* Prevent client-side cross-site scripting via user defined image src

* Add snapshot updates

* Fix topbar padding

* Float network right even without close/back button

* Update snapshots

---------

Co-authored-by: Tarrence van As <[email protected]>
  • Loading branch information
JunichiSugiura and tarrencev authored Jan 14, 2025
1 parent 168bd74 commit cec808a
Show file tree
Hide file tree
Showing 45 changed files with 224 additions and 393 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/keychain/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
})();
</script>
</head>
<body class="h-screen bg-background text-foreground">
<body class="h-screen bg-background text-foreground overflow-y-auto">
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions packages/keychain/src/components/DeployController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export function DeployController({
title="Deploying Controller"
description={`Your controller is being deployed on ${chainName}`}
>
<Content alignItems="center">
<Content className="items-center">
{deployHash && controller && (
<ExplorerLink
chainId={controller.chainId()}
Expand Down Expand Up @@ -201,7 +201,7 @@ export function DeployController({
title="Success!"
description={`Your controller has been deployed on ${chainName}`}
>
<Content alignItems="center">
<Content className="items-center">
{deployHash && controller && (
<ExplorerLink
chainId={controller.chainId()}
Expand Down
2 changes: 1 addition & 1 deletion packages/keychain/src/components/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function ErrorPage({ error }: { error: Error }) {
description="Something went wrong"
icon={<AlertIcon size="lg" />}
>
<Content gap={4}>
<Content className="gap-4">
<div className="flex w-full px-4 py-6 bg-secondary border border-quaternary rounded">
<p className="w-full text-sm">{error.message}</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/keychain/src/components/connect/CreateSession.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function CreateSession({
}
}}
>
<Content gap={6}>
<Content className="gap-6">
<SessionConsent isVerified={policies?.verified} />
{policies?.verified ? (
<VerifiedSessionSummary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { useRef, useState, useEffect } from "react";
import { Container, Footer, Content } from "@/components/layout";
import { Button, cn } from "@cartridge/ui-next";
import { Button, cn, Input } from "@cartridge/ui-next";
import { useControllerTheme } from "@/hooks/theme";
import { usePostHog } from "posthog-js/react";
import { useDebounce } from "@/hooks/debounce";
import { useUsernameValidation } from "./useUsernameValidation";
import { LoginMode } from "../types";
import { Legal, StatusTray } from ".";
import { useCreateController } from "./useCreateController";
import { Input } from "@cartridge/ui-next";
import { ErrorAlert } from "@/components/ErrorAlert";
import { VerifiableControllerTheme } from "@/context/theme";
import InAppSpy from "inapp-spy";
Expand Down Expand Up @@ -58,7 +57,7 @@ export function CreateControllerView({
if (e.key === "Enter") e.preventDefault();
}}
>
<Content mb="2rem" gap={0}>
<Content className="gap-0">
<div
className={cn(
"border-[#E46958] rounded",
Expand Down
2 changes: 1 addition & 1 deletion packages/keychain/src/components/funding/DepositEth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function DepositEthInner({ onComplete, onBack }: DepositEthProps) {
Icon={EthereumIcon}
onBack={onBack}
>
<Content gap={6}>
<Content className="gap-6">
<Balance showBalances={["eth"]} />
</Content>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function PurchaseCredits({ onBack }: PurchaseCreditsProps) {
}
onBack={state === PurchaseState.SELECTION ? onBack : undefined}
>
<Content gap={6}>
<Content className="gap-6">
<Balance showBalances={["credits"]} />
<ErrorAlert
variant=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default function StripeCheckout({
icon={<CoinsIcon variant="solid" />}
onBack={onBack}
>
<Content gap={6}>
<Content className="gap-6">
<form id="payment-form">
<PaymentElement
id="payment-element"
Expand Down
2 changes: 1 addition & 1 deletion packages/keychain/src/components/funding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function Funding({ onComplete, title }: FundingProps) {
description={controller && <CopyAddress address={controller.address} />}
icon={<ArrowIcon variant="down" />}
>
<Content gap={6}>
<Content className="gap-6">
<Balance showBalances={["credits", "eth"]} />
</Content>
<Footer>
Expand Down
20 changes: 13 additions & 7 deletions packages/keychain/src/components/layout/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { StackProps, VStack } from "@chakra-ui/react";
import { useLayout } from "./container";

export function Content({ children, ...stackProps }: StackProps) {
const { footer } = useLayout();
import { cn } from "@cartridge/ui-next";
import { PropsWithChildren } from "react";

export function Content({
children,
className,
}: PropsWithChildren & { className?: string }) {
return (
<VStack w="full" px={4} pb={footer.height} align="stretch" {...stackProps}>
<div
className={cn(
"w-full px-4 pb-[var(--footer-height)] flex flex-col items-stretch gap-2",
className,
)}
>
{children}
</VStack>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react";
import { Banner } from "./Banner";
import { LayoutContext } from "..";
import { EthereumIcon, TransferDuoIcon } from "@cartridge/ui-next";

const meta: Meta<typeof Banner> = {
component: Banner,
Expand All @@ -11,45 +11,41 @@ const meta: Meta<typeof Banner> = {
values: [{ name: "dark", value: "#161a17" }],
},
},
decorators: [
(Story, context) => (
<LayoutContext.Provider
value={{
variant: context.parameters.variant || "default",
footer: {
height: 0,
setHeight: () => {},
isOpen: false,
onToggle: () => {},
},
}}
>
<Story />
</LayoutContext.Provider>
),
],
args: {
variant: "compressed",
title: "Welcome to Keychain",
description: "Secure your digital assets",
},
} satisfies Meta<typeof Banner>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Expanded: Story = {
parameters: {
args: {
variant: "expanded",
},
};

export const Compressed: Story = {};

export const IconComponentProp: Story = {
args: {
title: "Welcome to Keychain",
description: "Secure your digital assets",
Icon: TransferDuoIcon,
},
};

export const Compressed: Story = {
parameters: {
variant: "compressed",
export const IconElementProp: Story = {
args: {
icon: <EthereumIcon />,
},
};

export const VeryLongTitle: Story = {
args: {
title: "Welcome to Keychain",
description: "Secure your digital assets",
title: "This is a very long title that should be truncated",
description:
"This is a very long description that should be wrapped and demonstrate how text behaves when it extends beyond multiple lines. It's important to test how the UI handles lengthy content to ensure proper wrapping, readability, and overall visual appeal. How does this much longer description look in the component?",
},
};
Loading

0 comments on commit cec808a

Please sign in to comment.