Skip to content

Commit

Permalink
chore: differentiate action popup and popup, improve responsiveness a…
Browse files Browse the repository at this point in the history
…nd refactor footers, ref #5260
  • Loading branch information
pete-watters committed Aug 19, 2024
1 parent 9e7d404 commit 2cae2a2
Show file tree
Hide file tree
Showing 49 changed files with 815 additions and 860 deletions.
14 changes: 14 additions & 0 deletions public/html/action-popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html class="mode__action-popup light">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="/assets/base.css" rel="stylesheet" />
</head>
<body>
<div id="splash-screen"></div>
<div id="app"></div>
<script src="/assets/splash-screen.js"></script>
<script src="browser-polyfill.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion scripts/generate-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const manifest = {
web_accessible_resources: [{ resources: ['inpage.js'], matches: ['*://*/*'] }],
action: {
default_title: 'Leather',
default_popup: 'popup.html',
default_popup: 'action-popup.html',
default_icon: defaultIconEnvironment[WALLET_ENVIRONMENT],
},
options_ui: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/disclaimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface DisclaimerProps extends BoxProps {
}
export function Disclaimer({ disclaimerText, learnMoreUrl, ...props }: DisclaimerProps) {
return (
<Box lineHeight="1.4" {...props}>
<Box {...props}>
<styled.span textStyle="caption.01">
{disclaimerText}
{learnMoreUrl ? (
Expand Down
1 change: 0 additions & 1 deletion src/app/components/info-card/info-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export function InfoCardBtn({ icon, label, onClick }: InfoCardBtnProps) {
interface InfoCardFooterProps {
children: ReactNode;
}
/** @deprecated replace with ui/footer */
export function InfoCardFooter({ children }: InfoCardFooterProps) {
return (
<Flex
Expand Down
27 changes: 0 additions & 27 deletions src/app/components/layout/card/card-content.tsx

This file was deleted.

90 changes: 86 additions & 4 deletions src/app/components/layout/card/card.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,110 @@
import { TooltipProvider } from '@radix-ui/react-tooltip';
import type { Meta } from '@storybook/react';
import { Box } from 'leather-styles/jsx';
import { Box, styled } from 'leather-styles/jsx';

import { Button } from '@leather.io/ui';
import { Button, Logo } from '@leather.io/ui';

import { Card as Component } from './card';
import { AvailableBalance, ButtonRow } from './index';

const meta: Meta<typeof Component> = {
component: Component,
tags: ['autodocs'],
title: 'Layout/Card',
decorators: [
Story => (
<TooltipProvider>
<Story />
</TooltipProvider>
),
],
};

export default meta;

export function Card() {
return (
<Component>
<Box height="40vh">Card content</Box>
</Component>
);
}

export function CardWithButtonFooter() {
return (
<Component
footer={
<Button fullWidth onClick={() => null}>
Create new account
Button
</Button>
}
>
<Box height="200px" bg="lightModeRed.300" />
<Box height="40vh">Card content</Box>
</Component>
);
}
export function CardWithButtonRowFooter() {
return (
<Component
footer={
<ButtonRow flexDirection="row">
<Button flexGrow={1} onClick={() => null} variant="outline">
Cancel
</Button>
<Button flexGrow={1} onClick={() => null}>
Confirm
</Button>
</ButtonRow>
}
>
<Box height="40vh">Card content</Box>
</Component>
);
}

export function CardWithBalanceFooter() {
return (
<Component
footer={
<ButtonRow>
<Button fullWidth onClick={() => null}>
Continue
</Button>
<AvailableBalance balance="$10" />
</ButtonRow>
}
>
<Box height="40vh">Card content</Box>
</Component>
);
}

export function CardWithBigHeader() {
return (
<Component
header={
<styled.h1 textStyle="heading.03" p="space.05">
choose asset <br /> to fund
</styled.h1>
}
>
<Box height="40vh">Card content</Box>
</Component>
);
}

export function CardWithLogo() {
return (
<Component
header={
<styled.h1 p="space.04" hideBelow="sm">
<Box px="space.02">
<Logo />
</Box>
</styled.h1>
}
>
<Box height="40vh">Card content</Box>
</Component>
);
}
55 changes: 50 additions & 5 deletions src/app/components/layout/card/card.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,65 @@
import type { ReactNode } from 'react';

import { Flex } from 'leather-styles/jsx';
import { Flex, FlexProps } from 'leather-styles/jsx';
import { token } from 'leather-styles/tokens';

interface CardProps {
children: ReactNode;
dataTestId?: string;
header?: ReactNode;
footer?: ReactNode;
footerBorder?: boolean;
contentStyle?: FlexProps;
}

export function Card({ children, dataTestId, header, footer }: CardProps) {
export function Card({
children,
dataTestId,
header,
footer,
contentStyle,
footerBorder = false,
...props
}: CardProps & FlexProps) {
return (
<Flex data-testid={dataTestId} direction="column">
<Flex
data-testid={dataTestId}
direction="column"
position={{ base: 'unset', sm: 'relative' }}
border={{ base: 'unset', sm: 'default' }}
rounded="lg"
{...props}
>
{header}
{children}
{footer}
<Flex
flexDirection="column"
width="100%"
overflowY="auto"
style={{ marginBottom: footer ? token('sizes.footerHeight') : 0 }}
p="space.05"
maxHeight={{ base: '70vh', md: '80vh' }}
{...contentStyle}
>
{children}
</Flex>
{footer && (
<Flex
bottom={0}
position="absolute"
gap="space.05"
p="space.05"
width="100vw"
maxWidth="100%"
zIndex={1}
minHeight="footerHeight"
bg="ink.background-primary"
borderTop={footerBorder ? 'default' : 'unset'}
borderBottomLeftRadius="lg"
borderBottomRightRadius="lg"
>
{footer}
</Flex>
)}
</Flex>
);
}
11 changes: 11 additions & 0 deletions src/app/components/layout/card/components/button-row.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Flex, FlexProps } from 'leather-styles/jsx';

import { HasChildren } from '@app/common/has-children';

export function ButtonRow({ children, ...props }: HasChildren & FlexProps) {
return (
<Flex flexDirection="column" gap="space.04" width="100%" {...props}>
{children}
</Flex>
);
}
18 changes: 18 additions & 0 deletions src/app/components/layout/card/components/summary-footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { HStack } from 'leather-styles/jsx';

import { CopyIcon, ExternalLinkIcon } from '@leather.io/ui';

import { InfoCardBtn } from '@app/components/info-card/info-card';

interface SummaryFooterProps {
onClickLink(): void;
onClickCopy(): void;
}
export function SummaryFooter({ onClickLink, onClickCopy }: SummaryFooterProps) {
return (
<HStack gap="space.04" width="100%">
<InfoCardBtn icon={<ExternalLinkIcon />} label="View details" onClick={onClickLink} />
<InfoCardBtn icon={<CopyIcon />} label="Copy ID" onClick={onClickCopy} />
</HStack>
);
}
4 changes: 4 additions & 0 deletions src/app/components/layout/card/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { Card } from './card';
export { ButtonRow } from './components/button-row';
export { SummaryFooter } from './components/summary-footer';
export { AvailableBalance } from './components/available-balance';
Loading

0 comments on commit 2cae2a2

Please sign in to comment.