Skip to content

Commit

Permalink
feat: add more components and features
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Dec 2, 2023
1 parent 3069fa7 commit d84fd11
Show file tree
Hide file tree
Showing 50 changed files with 1,716 additions and 150 deletions.
1 change: 1 addition & 0 deletions apps/web/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"styles": ["apps/web/src/styles.css"],
"scripts": [],
"isolatedConfig": true,
"postcssConfig": "apps/web/postcss.config.cjs",
"webpackConfig": "apps/web/webpack.config.js"
},
"configurations": {
Expand Down
87 changes: 43 additions & 44 deletions apps/web/src/app/app-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,56 @@
import { ActionIcon, Anchor, Box, Card, Group } from '@mantine/core'
import { UiContainer, UiLogoType, useUiColorScheme, useUiTheme } from '@pubkey-ui/core'
import { IconMoon, IconSun } from '@tabler/icons-react'
import { Avatar, Group, rem } from '@mantine/core'
import { UiHeader, UiLayout, UiMenu, UiThemeSwitch } from '@pubkey-ui/core'
import { IconSettings, IconUser, IconUserCog } from '@tabler/icons-react'
import { ReactNode } from 'react'
import { AccountChecker } from './features/account/account-ui'
import { ClusterChecker, ClusterUiSelect } from './features/cluster/cluster-ui'
import { ClusterChecker } from './features/cluster/cluster-ui'

export function AppLayout({ children }: { children: ReactNode }) {
const { Link } = useUiTheme()
return (
<Box>
<Card p="0" display="block">
<UiContainer py="sm">
<Group justify="space-between">
<Group align="center">
<Anchor component={Link} to="/" display="flex">
<UiLogoType height={32} />
</Anchor>
<Anchor component={Link} to="/dashboard">
Dashboard
</Anchor>
<Anchor component={Link} to="/account">
Account
</Anchor>
<Anchor component={Link} to="/demo">
Demo
</Anchor>
<Anchor component={Link} to="/dev">
Dev
</Anchor>
</Group>
<UiLayout
header={
<UiHeader
links={[
{ label: 'Dashboard', link: '/dashboard' },
{ label: 'Account', link: '/account' },
{ label: 'Demo', link: '/demo' },
{ label: 'Dev', link: '/dev' },
]}
profile={
<Group>
<ClusterUiSelect />
<ThemeToggle />
<UiThemeSwitch />
<UiMenu
position="bottom-end"
withArrow
arrowOffset={14}
icon={
<Avatar src="https://avatars.githubusercontent.com/u/36491?v=4" size={32}>
<IconUser />
</Avatar>
}
items={[
{ label: 'Account', type: 'label' },
{
label: 'Settings',
type: 'item',
leftSection: <IconSettings style={{ width: rem(14), height: rem(14) }} />,
},
{
label: 'Profile',
type: 'item',
leftSection: <IconUserCog style={{ width: rem(14), height: rem(14) }} />,
},
]}
/>
</Group>
</Group>
</UiContainer>
</Card>
}
/>
}
>
<ClusterChecker>
<AccountChecker />
</ClusterChecker>
{children}
</Box>
)
}

function ThemeToggle() {
const { toggleColorScheme, colorScheme } = useUiColorScheme()

return (
<Group justify="center">
<ActionIcon onClick={() => toggleColorScheme()} variant="default" size="xl" aria-label="Toggle color scheme">
{colorScheme === 'dark' ? <IconSun stroke={1.5} /> : <IconMoon stroke={1.5} />}
</ActionIcon>
</Group>
</UiLayout>
)
}
2 changes: 1 addition & 1 deletion apps/web/src/app/app.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { UiThemeProvider } from '@pubkey-ui/core'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { AppLayout } from './app-layout'
import { AppRoutes, ThemeLink } from './app-routes'
import { ClusterProvider } from './features/cluster/cluster-data-access'
import { SolanaProvider } from './features/solana/solana-provider'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'

const client = new QueryClient()

Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/app/features/account/account-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export function AccountBalanceCheck({ address }: { address: PublicKey }) {
if (query.isError || !query.data) {
return (
<UiWarning
styles={{
root: { display: 'flex', justifyContent: 'center' },
title: { justifyContent: 'center' },
}}
title="Account not found"
icon={<IconUserOff size={24} />}
message={
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/app/features/cluster/cluster-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export function ClusterChecker({ children }: { children: ReactNode }) {
if (query.isError || !query.data) {
return (
<UiWarning
styles={{
root: { display: 'flex', justifyContent: 'center' },
title: { justifyContent: 'center' },
}}
title="Error connecting to cluster"
icon={<IconNetworkOff />}
message={
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/features/demo/demo-feature-alerts.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SimpleGrid } from '@mantine/core'
import { UiCard, UiAlert, UiError, UiInfo, UiSuccess, UiWarning } from '@pubkey-ui/core'
import { UiAlert, UiCard, UiError, UiInfo, UiSuccess, UiWarning } from '@pubkey-ui/core'

export function DemoFeatureAlerts() {
return (
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/app/features/demo/demo-feature-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UiCard, UiStack } from '@pubkey-ui/core'
export function DemoFeatureCard() {
return (
<UiStack>
<UiCard title="Default Card">CARD CONTENT</UiCard>
<UiCard withBorder title="Card" shadow="lg">
CARD CONTENT
</UiCard>
Expand Down
136 changes: 136 additions & 0 deletions apps/web/src/app/features/demo/demo-feature-header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import { ActionIcon, Avatar, Button, Group, rem, Text } from '@mantine/core'
import { useDisclosure } from '@mantine/hooks'
import { UiCard, UiHeader, UiMenu, UiSearchInput, UiStack } from '@pubkey-ui/core'
import {
IconDoorExit,
IconLetterP,
IconMessageCircle,
IconPhoto,
IconSearch,
IconSettings,
IconUser,
IconUserCog,
} from '@tabler/icons-react'
import { useState } from 'react'
import { Route, Routes } from 'react-router-dom'

export function DemoFeatureHeader() {
const [opened, { toggle }] = useDisclosure(false)
const [signedIn, setSignedIn] = useState(false)
return (
<UiCard title="Header">
<UiStack gap="xl">
<UiHeader
base="/demo/header"
opened={opened}
toggle={toggle}
links={[
{ link: '/demo/header/about', label: 'Features' },
{ link: '/demo/header/pricing', label: 'Pricing' },
{ link: '/demo/header/learn', label: 'Learn' },
]}
profile={<UiSearchInput text={{ size: 'sm' }} />}
/>
<UiHeader
profile={
<ActionIcon radius="xl" size="lg" variant="light">
<IconSearch style={{ width: rem(16), height: rem(16) }} stroke={1.5} />
</ActionIcon>
}
/>
<UiHeader
base="/demo/header"
logo={
<Group gap={6}>
<IconLetterP size={28} />
<Text size="xl" fw="bold">
PubKey
</Text>
</Group>
}
logoSmall={<IconLetterP size={28} />}
/>
<UiHeader
profile={
<Group gap="xs">
{signedIn ? (
<UiMenu
position="bottom-end"
withArrow
arrowOffset={14}
icon={
<Avatar src="https://avatars.githubusercontent.com/u/36491?v=4" size={32}>
<IconUser />
</Avatar>
}
items={[
{ label: 'Application', type: 'label' },
{
label: 'Settings',
type: 'item',
leftSection: <IconSettings style={{ width: rem(14), height: rem(14) }} />,
},
{
label: 'Messages',
type: 'item',
leftSection: <IconMessageCircle style={{ width: rem(14), height: rem(14) }} />,
},
{
label: 'Gallery',
type: 'item',
leftSection: <IconPhoto style={{ width: rem(14), height: rem(14) }} />,
},
{
label: 'Search',
type: 'item',
leftSection: <IconSearch style={{ width: rem(14), height: rem(14) }} />,
rightSection: (
<Text size="xs" c="dimmed">
⌘K
</Text>
),
},
{
label: 'Account',
type: 'label',
},
{
label: 'Profile',
type: 'item',
leftSection: <IconUserCog style={{ width: rem(14), height: rem(14) }} />,
},
{
label: 'Sign out',
type: 'item',
leftSection: <IconDoorExit style={{ width: rem(14), height: rem(14) }} />,
onClick: () => setSignedIn(false),
},
]}
/>
) : (
<Button size="sm" variant="light" onClick={() => setSignedIn(true)}>
Sign in
</Button>
)}
</Group>
}
/>
<UiStack hiddenFrom="md">
{opened ? (
<Button onClick={toggle}>Close menu</Button>
) : (
<Button variant="light" onClick={toggle}>
Open menu
</Button>
)}
</UiStack>

<Routes>
<Route path="about" element={<div>About</div>} />
<Route path="pricing" element={<div>Pricing</div>} />
<Route path="learn" element={<div>Learn</div>} />
</Routes>
</UiStack>
</UiCard>
)
}
37 changes: 32 additions & 5 deletions apps/web/src/app/features/demo/demo-feature-logo.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
import { SimpleGrid } from '@mantine/core'
import { UiCard, UiLogoType, UiLogoTypeBlack, UiLogoTypeWhite } from '@pubkey-ui/core'
import {
UiCard,
UiGroup,
UiLogo,
UiLogoType,
UiLogoTypeBlack,
UiLogoTypeWhite,
UiStack,
UiThemeSwitch,
} from '@pubkey-ui/core'

export function DemoFeatureLogo() {
return (
<UiCard title="Logo">
<UiCard title="Logo and LogoType">
<SimpleGrid cols={2}>
<UiLogoType height={64} />
<UiLogoTypeBlack height={64} />
<UiLogoTypeWhite height={64} />
<UiStack align="center">
<UiLogo height={64} />
</UiStack>
<UiStack align="center">
<UiLogo height={128} />
</UiStack>
<UiStack align="center">
<UiLogoTypeBlack height={64} />
</UiStack>
<UiStack align="center">
<UiLogoTypeWhite height={64} />
</UiStack>
<UiStack align="center">
<UiLogoType height={64} />
</UiStack>
<UiGroup>
<UiStack align="center">
<span>Toggle the theme to see the logo change color.</span>
<UiThemeSwitch />
</UiStack>
</UiGroup>
</SimpleGrid>
</UiCard>
)
Expand Down
Loading

0 comments on commit d84fd11

Please sign in to comment.