-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
818 additions
and
39 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
apps/web/src/app/features/demo/demo-feature-dashboard-grid.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { UiCard, UiDashboardGrid, UiDashboardItem, UiStack } from '@pubkey-ui/core' | ||
import { | ||
IconBuildingBank, | ||
IconCashBanknote, | ||
IconCoin, | ||
IconCreditCard, | ||
IconReceipt, | ||
IconReceiptRefund, | ||
IconReceiptTax, | ||
IconRepeat, | ||
IconReport, | ||
} from '@tabler/icons-react' | ||
import { ReactNode } from 'react' | ||
import { useRoutes } from 'react-router-dom' | ||
|
||
export function useDashboardItems(): { | ||
links: UiDashboardItem[] | ||
routes: ReactNode | ||
} { | ||
const links: UiDashboardItem[] = [ | ||
{ to: 'credit-cards', label: 'Credit cards', icon: IconCreditCard }, | ||
{ to: 'banks-nearby', label: 'Banks nearby', icon: IconBuildingBank }, | ||
{ to: 'transfers', label: 'Transfers', icon: IconRepeat }, | ||
{ to: 'refunds', label: 'Refunds', icon: IconReceiptRefund }, | ||
{ to: 'receipts', label: 'Receipts', icon: IconReceipt }, | ||
{ to: 'taxes', label: 'Taxes', icon: IconReceiptTax }, | ||
{ to: 'reports', label: 'Reports', icon: IconReport }, | ||
{ to: 'payments', label: 'Payments', icon: IconCoin }, | ||
{ to: 'cashback', label: 'Cashback', icon: IconCashBanknote }, | ||
] | ||
const routes = useRoutes([ | ||
{ index: true, element: <div>Dashboard Grid</div> }, | ||
...links.map((link) => ({ path: link.to, element: <div>{link.label}</div> })), | ||
]) | ||
|
||
return { | ||
links, | ||
routes, | ||
} | ||
} | ||
|
||
export function DemoFeatureDashboardGrid() { | ||
const base = '/demo/dashboard-grid' | ||
const { links, routes } = useDashboardItems() | ||
return ( | ||
<UiStack> | ||
<UiDashboardGrid | ||
links={links.map(({ to, label, icon }) => ({ | ||
to: `${base}/${to}`, | ||
label, | ||
icon, | ||
}))} | ||
/> | ||
<UiCard>{routes}</UiCard> | ||
</UiStack> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { UiCard, UiContainer, UiDashboardGrid } from '@pubkey-ui/core' | ||
import { | ||
IconBuildingBank, | ||
IconCashBanknote, | ||
IconCoin, | ||
IconCreditCard, | ||
IconReceipt, | ||
IconReceiptRefund, | ||
IconReceiptTax, | ||
IconRepeat, | ||
IconReport, | ||
} from '@tabler/icons-react' | ||
|
||
export function DevFeatureActionGrid() { | ||
return ( | ||
<UiContainer> | ||
<UiCard title="ActionGrid"> | ||
<UiDashboardGrid | ||
links={[ | ||
{ to: '', label: 'Credit cards', icon: IconCreditCard }, | ||
{ to: '', label: 'Banks nearby', icon: IconBuildingBank }, | ||
{ to: '', label: 'Transfers', icon: IconRepeat }, | ||
{ to: '', label: 'Refunds', icon: IconReceiptRefund }, | ||
{ to: '', label: 'Receipts', icon: IconReceipt }, | ||
{ to: '', label: 'Taxes', icon: IconReceiptTax }, | ||
{ to: '', label: 'Reports', icon: IconReport }, | ||
{ to: '', label: 'Payments', icon: IconCoin }, | ||
{ to: '', label: 'Cashback', icon: IconCashBanknote }, | ||
]} | ||
/> | ||
</UiCard> | ||
</UiContainer> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ui-dashboard-grid' |
16 changes: 16 additions & 0 deletions
16
packages/core/src/lib/ui-dashboard-grid/ui-dashboard-grid.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.item { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
text-align: center; | ||
border-radius: var(--mantine-radius-md); | ||
height: rem(180px); | ||
background-color: light-dark(var(--mantine-color-gray-0), var(--mantine-color-dark-7)); | ||
transition: box-shadow 150ms ease, transform 100ms ease; | ||
|
||
@mixin hover { | ||
box-shadow: var(--mantine-shadow-md); | ||
transform: scale(1.05); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
packages/core/src/lib/ui-dashboard-grid/ui-dashboard-grid.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { SimpleGrid, Text, UnstyledButton, useMantineTheme } from '@mantine/core' | ||
import { useUiTheme } from '../ui-theme' | ||
import { ComponentType } from 'react' | ||
|
||
import classes from './ui-dashboard-grid.module.css' | ||
|
||
const linkColors = ['violet', 'indigo', 'blue', 'green', 'teal', 'cyan', 'pink', 'red', 'orange'] | ||
|
||
export function getColorByIndex(index: number) { | ||
return linkColors[index % linkColors.length] | ||
} | ||
|
||
export interface UiDashboardItem { | ||
icon: ComponentType<{ color?: string; size: number | string }> | ||
label: string | ||
to: string | ||
color?: string | ||
} | ||
|
||
export interface UiDashboardGridProps { | ||
links: UiDashboardItem[] | ||
} | ||
|
||
export function UiDashboardGrid({ links }: UiDashboardGridProps) { | ||
const { Link } = useUiTheme() | ||
const theme = useMantineTheme() | ||
|
||
const items = links.map((item, index) => ( | ||
<UnstyledButton component={Link} to={item.to} key={item.label} className={classes.item}> | ||
<item.icon color={theme.colors[item.color ?? getColorByIndex(index)][6]} size={64} /> | ||
<Text size="xs" mt={7}> | ||
{item.label} | ||
</Text> | ||
</UnstyledButton> | ||
)) | ||
|
||
return ( | ||
<SimpleGrid cols={{ xs: 1, sm: 2, md: 3 }} spacing={{ base: 'sm', md: 'xl' }}> | ||
{items} | ||
</SimpleGrid> | ||
) | ||
} |
Oops, something went wrong.