diff --git a/packages/keychain/__image_snapshots__/components-confirmtransaction--default-chromium.png b/packages/keychain/__image_snapshots__/components-confirmtransaction--default-chromium.png index a1ae4e05e..44f65e777 100644 Binary files a/packages/keychain/__image_snapshots__/components-confirmtransaction--default-chromium.png and b/packages/keychain/__image_snapshots__/components-confirmtransaction--default-chromium.png differ diff --git a/packages/keychain/__image_snapshots__/components-connect-create-createcontroller--with-theme-chromium.png b/packages/keychain/__image_snapshots__/components-connect-create-createcontroller--with-theme-chromium.png index b6182c9bf..df0fb6de7 100644 Binary files a/packages/keychain/__image_snapshots__/components-connect-create-createcontroller--with-theme-chromium.png and b/packages/keychain/__image_snapshots__/components-connect-create-createcontroller--with-theme-chromium.png differ diff --git a/packages/keychain/__image_snapshots__/components-controllererroralert--all-chromium.png b/packages/keychain/__image_snapshots__/components-controllererroralert--all-chromium.png index bf35065ce..477b82fb5 100644 Binary files a/packages/keychain/__image_snapshots__/components-controllererroralert--all-chromium.png and b/packages/keychain/__image_snapshots__/components-controllererroralert--all-chromium.png differ diff --git a/packages/keychain/__image_snapshots__/components-erroralert--default-chromium.png b/packages/keychain/__image_snapshots__/components-erroralert--default-chromium.png index c33689d62..2f8d88495 100644 Binary files a/packages/keychain/__image_snapshots__/components-erroralert--default-chromium.png and b/packages/keychain/__image_snapshots__/components-erroralert--default-chromium.png differ diff --git a/packages/keychain/__image_snapshots__/components-erroralert--error-chromium.png b/packages/keychain/__image_snapshots__/components-erroralert--error-chromium.png index 2d57f6b90..541920578 100644 Binary files a/packages/keychain/__image_snapshots__/components-erroralert--error-chromium.png and b/packages/keychain/__image_snapshots__/components-erroralert--error-chromium.png differ diff --git a/packages/keychain/__image_snapshots__/components-erroralert--info-chromium.png b/packages/keychain/__image_snapshots__/components-erroralert--info-chromium.png index 3d3198f53..234322447 100644 Binary files a/packages/keychain/__image_snapshots__/components-erroralert--info-chromium.png and b/packages/keychain/__image_snapshots__/components-erroralert--info-chromium.png differ diff --git a/packages/keychain/__image_snapshots__/components-erroralert--long-title-chromium.png b/packages/keychain/__image_snapshots__/components-erroralert--long-title-chromium.png index c471da540..74989188d 100644 Binary files a/packages/keychain/__image_snapshots__/components-erroralert--long-title-chromium.png and b/packages/keychain/__image_snapshots__/components-erroralert--long-title-chromium.png differ diff --git a/packages/keychain/__image_snapshots__/components-erroralert--warning-chromium.png b/packages/keychain/__image_snapshots__/components-erroralert--warning-chromium.png index 4297a4284..ee030d710 100644 Binary files a/packages/keychain/__image_snapshots__/components-erroralert--warning-chromium.png and b/packages/keychain/__image_snapshots__/components-erroralert--warning-chromium.png differ diff --git a/packages/keychain/src/components/ErrorAlert.tsx b/packages/keychain/src/components/ErrorAlert.tsx index 0d53c876a..ce4869ba1 100644 --- a/packages/keychain/src/components/ErrorAlert.tsx +++ b/packages/keychain/src/components/ErrorAlert.tsx @@ -1,25 +1,23 @@ import { - WedgeIcon, CopyIcon, CheckIcon, ErrorAlertIcon, ErrorAlertIconProps, Button, -} from "@cartridge/ui-next"; -import { - Text, Accordion, AccordionItem, - AccordionButton, - AccordionPanel, - Spacer, - HStack, - Box, - VStack, - Divider, -} from "@chakra-ui/react"; -import { motion } from "framer-motion"; -import React, { ReactElement, useCallback, useEffect, useState } from "react"; + AccordionTrigger, + AccordionContent, + cn, +} from "@cartridge/ui-next"; +import { Text, HStack, VStack, Divider } from "@chakra-ui/react"; +import React, { + ReactElement, + useCallback, + useEffect, + useMemo, + useState, +} from "react"; import { ErrorCode } from "@cartridge/account-wasm/controller"; import { ControllerError } from "@/utils/connection"; import { parseExecutionError, parseValidationError } from "@/utils/errors"; @@ -52,88 +50,67 @@ export function ErrorAlert({ }, 3000); }, [copied]); + const collapsible = !isExpanded || allowToggle; + const styles = useMemo(() => { + switch (variant) { + case "info": + return { bg: "bg-info", text: "text-info-foreground" }; + case "warning": + return { bg: "bg-warning", text: "text-warning-foreground" }; + case "error": + return { bg: "bg-error", text: "text-error-foreground" }; + default: + return { bg: "bg-secondary", text: "text-secondary-foreground" }; + } + }, [variant]); + return ( - - {({ isExpanded: itemExpanded }) => ( - <> - - - {variant && ( - - )} - - {title} - - - - + + + {variant && variant !== "default" && ( +
+ +
+ )} +
+ {title} +
+
- {description && !isExpanded && ( - - - - - + + {copyText && ( + - )} - - {description} - - - )} - - )} + + )} + {description &&
{description}
} +
); diff --git a/packages/keychain/src/components/Policies.tsx b/packages/keychain/src/components/Policies.tsx index c6e8160ee..3b47b5032 100644 --- a/packages/keychain/src/components/Policies.tsx +++ b/packages/keychain/src/components/Policies.tsx @@ -1,148 +1,35 @@ -import { - HStack, - VStack, - Text, - AccordionButton, - AccordionItem, - Accordion, - Spacer, - AccordionPanel, - Box, -} from "@chakra-ui/react"; -import { FnIcon, WedgeIcon, CopyAddress } from "@cartridge/ui-next"; import { SessionPolicies } from "@cartridge/presets"; +import { ContractCard } from "./session/ContractCard"; +import { useConnection } from "@/hooks/connection"; +import { MessageCard } from "./session/MessageCard"; export function Policies({ - title, policies, }: { title?: string; policies: SessionPolicies; }) { + const connection = useConnection(); + const parsedContracts = connection.policies?.contracts ?? {}; + return ( - - {title && ( - - - {title} - - +
+ {Object.entries(policies.contracts ?? {}).map(([address, p]) => { + const c = parsedContracts[address]; + return ( + + ); + })} + + {policies.messages && policies.messages.length > 0 && ( + )} - - - {Object.entries(policies.contracts ?? {}).map(([contractAddress, p]) => - p.methods.map((m) => ( - - {({ isExpanded }) => ( - <> - - - - {m.entrypoint} - - - - - - - - - - - {m.description && ( - - {m.description} - - )} - - - - )} - - )), - )} - {policies.messages?.map((p) => ( - - {({ isExpanded }) => ( - <> - - - Sign Message - - - - - - - - - - - Domain: {p.domain.name} - - - Primary Type: {p.primaryType} - - - Types: - - {Object.keys(p.types).map((key) => - key === "StarknetDomain" || - key === "StarkNetDomain" ? null : ( - - {key}: {JSON.stringify(p.types[key])} - - ), - )} - - - - )} - - ))} - - +
); } diff --git a/packages/keychain/src/components/session/ContractCard.tsx b/packages/keychain/src/components/session/ContractCard.tsx index 9d1651c7e..b6c24a014 100644 --- a/packages/keychain/src/components/session/ContractCard.tsx +++ b/packages/keychain/src/components/session/ContractCard.tsx @@ -64,10 +64,12 @@ export function ContractCard({ - Approve{" "} - - {methods.length} {methods.length > 1 ? "methods" : "method"} - +
+ Approve{" "} + + {methods.length} {methods.length > 1 ? "methods" : "method"} + +
{methods.map((method) => ( diff --git a/packages/ui-next/src/components/icons/error-alert-icon.tsx b/packages/ui-next/src/components/icons/error-alert-icon.tsx index d0200a49e..06343c761 100644 --- a/packages/ui-next/src/components/icons/error-alert-icon.tsx +++ b/packages/ui-next/src/components/icons/error-alert-icon.tsx @@ -3,35 +3,32 @@ import { InfoIcon, WarningIcon, AlertIcon as AlertIconRaw } from "./utility"; export type ErrorAlertIconProps = { variant: "info" | "warning" | "error"; - size?: "xs" | "default"; + size?: "sm"; className?: string; }; export function ErrorAlertIcon({ variant, - size = "default", + size = "sm", className, }: ErrorAlertIconProps) { switch (variant) { case "info": return ( - + ); case "warning": return ( ); case "error": return ( ); } diff --git a/packages/ui-next/src/components/primitives/accordion.tsx b/packages/ui-next/src/components/primitives/accordion.tsx index 50a5c5a65..bfd678e1b 100644 --- a/packages/ui-next/src/components/primitives/accordion.tsx +++ b/packages/ui-next/src/components/primitives/accordion.tsx @@ -24,13 +24,10 @@ const AccordionTrigger = React.forwardRef< svg]:rotate-90", - className, - )} + className="w-full flex items-center justify-between text-sm text-muted-foreground transition-all text-left [&[data-state=open]>svg]:rotate-90" {...props} > -
{children}
+
{children}
{!hideIcon && ( )} diff --git a/packages/ui-next/src/preset.ts b/packages/ui-next/src/preset.ts index 415af5103..8aad80fa0 100644 --- a/packages/ui-next/src/preset.ts +++ b/packages/ui-next/src/preset.ts @@ -59,6 +59,21 @@ export const cartridgeTWPreset: Partial = { spacer: { DEFAULT: "hsl(var(--spacer))", }, + info: { + DEFAULT: "hsl(var(--info))", + foreground: "hsl(var(--info-foreground))", + icon: "hsl(var(--info-icon))", + }, + warning: { + DEFAULT: "hsl(var(--warning))", + foreground: "hsl(var(--warning-foreground))", + icon: "hsl(var(--warning-icon))", + }, + error: { + DEFAULT: "hsl(var(--error))", + foreground: "hsl(var(--error-foreground))", + icon: "hsl(var(--error-icon))", + }, }, extend: { fontFamily: { diff --git a/packages/ui-next/src/themes/default.css b/packages/ui-next/src/themes/default.css index 7e2607827..1005d96fe 100644 --- a/packages/ui-next/src/themes/default.css +++ b/packages/ui-next/src/themes/default.css @@ -39,10 +39,13 @@ --spacer: 0 0% 0%; /* solid-fills/spacer */ --info: 209 67% 75%; - --info-foreground: 208 100% 30%; - --warning: 209 67% 75%; - --warning-foreground: 208 100% 30%; - --error: 209 67% 75%; - --error-foreground: 208 100% 30%; + --info-foreground: 135 8% 9%; + --info-icon: 208 100% 30%; + --warning: 135 6% 13%; + --warning-foreground: 0 0% 100%; + --warning-icon: 47 100% 49%; + --error: 0 84% 85%; + --error-foreground: 0 0% 0%; + --error-icon: 0 72% 65%; } }