Skip to content

Commit 6297620

Browse files
committed
feat: home card ui component
1 parent ceaefc6 commit 6297620

File tree

7 files changed

+168
-343
lines changed

7 files changed

+168
-343
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { AuthState } from '~/helpers/utils';
2+
3+
import { Button, type ButtonProps } from '@leather.io/ui';
4+
5+
const authStateCopyMap: Record<AuthState, string> = {
6+
'no-extension': 'Install',
7+
'extension-pre-onboarding': 'Sign up',
8+
'extension-user': 'Account',
9+
};
10+
11+
interface AuthButtonProps extends ButtonProps {
12+
state: AuthState;
13+
}
14+
export function AuthButton(props: AuthButtonProps) {
15+
return (
16+
<Button variant="outline" {...props}>
17+
{authStateCopyMap[props.state]}
18+
</Button>
19+
);
20+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { type HTMLStyledProps, styled } from 'leather-styles/jsx';
2+
3+
export function HomeCard(props: HTMLStyledProps<'div'>) {
4+
return <styled.div borderRadius="md" p="space.04" {...props} />;
5+
}
6+
7+
export function HomeHeroCard(props: HTMLStyledProps<'div'>) {
8+
return (
9+
<HomeCard background="linear-gradient(261deg, #FFCAC7 28.46%, #FFC484 99.71%)" {...props} />
10+
);
11+
}

apps/web/app/features/home/home.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,25 @@ import { leather } from '~/helpers/leather-sdk';
33

44
import { Button } from '@leather.io/ui';
55

6+
import { HomeHeroCard } from './components/home-card';
7+
68
interface HomeProps {
79
latestArticles: { name: string; url: string }[];
810
}
911
export function Home({ latestArticles }: HomeProps) {
1012
return (
1113
<>
1214
<styled.div p="space.04">
13-
<styled.h1 textStyle="display.02">Bitcoin for the rest of us</styled.h1>
14-
<styled.h2 textStyle="heading.05">
15-
Unlock yield opportunities without giving up control of your assets.
16-
</styled.h2>
17-
<styled.h2 textStyle="heading.03">Featured articles</styled.h2>
15+
<HomeHeroCard>
16+
<styled.h1 textStyle="heading.03">Earn rewards with BTC</styled.h1>
17+
<styled.p textStyle="label.02" mt="space.03">
18+
Bridge BTC to sBTC to access DeFi, NFTs, and ~5% Bitcoin yield* while keeping full
19+
liquidity and self-custody. Transfers adjust rewards dynamically.
20+
</styled.p>
21+
<styled.button textStyle="label.02" mt="space.03">
22+
Get started →
23+
</styled.button>
24+
</HomeHeroCard>
1825
<ul>
1926
{latestArticles.map(article => (
2027
<li key={article.name}>

apps/web/app/helpers/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
import { isDefined } from '@leather.io/utils';
2+
13
export function getUiPackageAssetUrl(path: string) {
24
if (import.meta.env.MODE === 'development') {
35
return 'node_modules/@leather.io/ui/dist-web/assets/' + path;
46
}
57
return 'assets/' + path;
68
}
9+
10+
export function isLeatherInstalled() {
11+
return isDefined(window.LeatherProvider);
12+
}
13+
14+
export type AuthState = 'no-extension' | 'extension-pre-onboarding' | 'extension-user';

apps/web/app/layouts/nav/nav.tsx

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { styled } from 'leather-styles/jsx';
2+
import { AuthButton } from '~/components/auth-button';
23

34
import { NavItem } from './nav-item.layout';
45

56
export function Nav() {
7+
const allNavItems = false;
8+
69
return (
710
<styled.nav
811
display="flex"
@@ -60,22 +63,27 @@ export function Nav() {
6063
</NavItem>
6164
</styled.div>
6265

63-
<styled.div mt="auto" mb="space.09">
64-
<NavItem href="/blog" icon="newspaper">
65-
Blog
66-
</NavItem>
66+
{allNavItems && (
67+
<styled.div mt="auto" mb="space.09">
68+
<NavItem href="/blog" icon="newspaper">
69+
Blog
70+
</NavItem>
6771

68-
<NavItem href="/guides" icon="glasses">
69-
Guides
70-
</NavItem>
72+
<NavItem href="/guides" icon="glasses">
73+
Guides
74+
</NavItem>
7175

72-
<NavItem href="/dev-docs" icon="terminal">
73-
Dev Docs
74-
</NavItem>
76+
<NavItem href="/dev-docs" icon="terminal">
77+
Dev Docs
78+
</NavItem>
7579

76-
<NavItem href="/support" icon="support">
77-
Support
78-
</NavItem>
80+
<NavItem href="/support" icon="support">
81+
Support
82+
</NavItem>
83+
</styled.div>
84+
)}
85+
<styled.div mt="auto" mb="space.04">
86+
<AuthButton state="extension-pre-onboarding" mx="space.04" />
7987
</styled.div>
8088
</styled.nav>
8189
);

apps/web/tests/homepage.spec.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@ import { expect, test } from '@playwright/test';
33
test.describe('Homepage', () => {
44
test('has title', async ({ page }) => {
55
await page.goto('/');
6-
await expect(page.getByRole('heading', { name: 'Bitcoin for the rest of us' })).toBeVisible();
7-
});
8-
9-
test('get started link', async ({ page }) => {
10-
await page.goto('/');
11-
12-
// Click the get started link.
13-
await page.getByRole('link', { name: 'Docs' }).click();
14-
15-
// Expects page to have a heading with the name of Installation.
16-
await expect(page.getByRole('heading', { name: 'Leather web app' })).toBeVisible();
6+
await expect(page.getByRole('heading', { name: 'Earn rewards with BTC' })).toBeVisible();
177
});
188
});

0 commit comments

Comments
 (0)