From 710fb708c220bcca53dfb2fcc28308f293ae6a42 Mon Sep 17 00:00:00 2001 From: Daniel Cortes Date: Thu, 5 Dec 2024 11:38:16 -0700 Subject: [PATCH] Add Card component and asset row cards in balance page --- packages/mobile-app/app/(tabs)/balances.tsx | 42 +++++++++-- .../tackle-box/lib/components/Box/Box.tsx | 15 +++- .../tackle-box/lib/components/Card/Card.tsx | 72 +++++++++++++++++++ .../tackle-box/lib/components/Stack/Stack.tsx | 7 +- packages/tackle-box/lib/index.ts | 8 ++- 5 files changed, 127 insertions(+), 17 deletions(-) create mode 100644 packages/tackle-box/lib/components/Card/Card.tsx diff --git a/packages/mobile-app/app/(tabs)/balances.tsx b/packages/mobile-app/app/(tabs)/balances.tsx index 6f4e202..c789a90 100644 --- a/packages/mobile-app/app/(tabs)/balances.tsx +++ b/packages/mobile-app/app/(tabs)/balances.tsx @@ -6,6 +6,7 @@ import { Tabs, Text, VStack, + Card, } from "@ironfish/tackle-box"; import { SafeAreaGradient } from "@/components/SafeAreaGradient/SafeAreaGradient"; @@ -39,16 +40,13 @@ export default function Balances() { Transactions - - Assets - Assets - Assets - Assets - Assets + + + - + Transactions Transactions Transactions @@ -75,3 +73,33 @@ function NavBar() { ); } + +function AssetBadge() { + return ( + + ); +} + +function AssetRow() { + return ( + + + + + $IRON + + 100.55 + + + + + + ); +} diff --git a/packages/tackle-box/lib/components/Box/Box.tsx b/packages/tackle-box/lib/components/Box/Box.tsx index 0d25ac6..66f7e63 100644 --- a/packages/tackle-box/lib/components/Box/Box.tsx +++ b/packages/tackle-box/lib/components/Box/Box.tsx @@ -26,6 +26,7 @@ const styles = css.create({ flexDirection: "column", alignItems: "stretch", justifyContent: "flex-start", + position: "relative", }, backgroundColor: (color?: string) => ({ backgroundColor: color, @@ -34,6 +35,10 @@ const styles = css.create({ height, width, }), + minDimensions: (minHeight?: UnitValue, minWidth?: UnitValue) => ({ + minHeight, + minWidth, + }), margin: ( top: UnitValue, right: UnitValue, @@ -77,21 +82,26 @@ const styles = css.create({ }); export type BoxProps = BorderRadiusArgs & - BorderWidthArgs & { + BorderWidthArgs & + MarginPadding & { children?: ReactNode; height?: UnitValue; width?: UnitValue; + minHeight?: UnitValue; + minWidth?: UnitValue; bg?: Colors; borderColor?: Colors; borderWidth?: number; flexGrow?: number; style?: StyleObj; - } & MarginPadding; + }; export function Box({ children, height = "auto", width = "100%", + minHeight, + minWidth, bg, borderColor, borderRadius = 0, @@ -176,6 +186,7 @@ export function Box({ style={[ styles.base, styles.dimensions(height, width), + styles.minDimensions(minHeight, minWidth), styles.margin(...margin), styles.padding(...padding), styles.borderRadius(borderRadiusValues), diff --git a/packages/tackle-box/lib/components/Card/Card.tsx b/packages/tackle-box/lib/components/Card/Card.tsx new file mode 100644 index 0000000..bdfde0a --- /dev/null +++ b/packages/tackle-box/lib/components/Card/Card.tsx @@ -0,0 +1,72 @@ +import { PropsWithChildren } from "react"; +import { css } from "react-strict-dom"; +import { Box } from "@/components/Box/Box"; +import { MarginPadding } from "@/utils/useMarginPaddingValues"; + +const style = css.create({ + shadowWrapper: { + position: "absolute", + top: 0, + left: 0, + right: 0, + bottom: 0, + }, + content: { + zIndex: 1, + }, +}); + +type CardProps = PropsWithChildren< + MarginPadding & { + active?: boolean; + } +>; + +export function Card({ + children, + active, + m, + mx, + my, + mt, + mr, + mb, + ml, + p = 4, + px, + py, + pt, + pr, + pb, + pl, +}: CardProps) { + return ( + + + {children} + + + + + + ); +} diff --git a/packages/tackle-box/lib/components/Stack/Stack.tsx b/packages/tackle-box/lib/components/Stack/Stack.tsx index 42ea9b1..3155dd3 100644 --- a/packages/tackle-box/lib/components/Stack/Stack.tsx +++ b/packages/tackle-box/lib/components/Stack/Stack.tsx @@ -22,14 +22,12 @@ const styles = css.create({ type StackProps = BoxProps & { gap?: number; - spacing?: number; alignItems?: string; justifyContent?: string; }; export function HStack({ gap = 0, - spacing, alignItems = "stretch", justifyContent = "flex-start", children, @@ -39,7 +37,7 @@ export function HStack({