Skip to content

Commit

Permalink
feat: add back button
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Dec 3, 2023
1 parent cb6f1dd commit e6531a2
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 0 deletions.
9 changes: 9 additions & 0 deletions apps/web/src/app/features/demo/demo-feature-back.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { UiBack, UiCard } from '@pubkey-ui/core'

export function DemoFeatureBack() {
return (
<UiCard title="Back">
<UiBack />
</UiCard>
)
}
2 changes: 2 additions & 0 deletions apps/web/src/app/features/demo/demo-feature.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UiContainer, UiNotFound, UiStack } from '@pubkey-ui/core'
import { ReactNode } from 'react'
import { Link, Navigate, useLocation, useRoutes } from 'react-router-dom'
import { DemoFeatureAlerts } from './demo-feature-alerts'
import { DemoFeatureBack } from './demo-feature-back'
import { DemoFeatureCard } from './demo-feature-card'
import { DemoFeatureCopy } from './demo-feature-copy'
import { DemoFeatureDashboardGrid } from './demo-feature-dashboard-grid'
Expand All @@ -26,6 +27,7 @@ export function DemoFeature() {
element: ReactNode
}[] = [
{ path: 'alerts', label: 'Alerts', element: <DemoFeatureAlerts /> },
{ path: 'back', label: 'Back', element: <DemoFeatureBack /> },
{ path: 'card', label: 'Card', element: <DemoFeatureCard /> },
{ path: 'copy', label: 'Copy', element: <DemoFeatureCopy /> },
{ path: 'dashboard-grid', label: 'Dashboard Grid', element: <DemoFeatureDashboardGrid /> },
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './ui-alert'
export * from './ui-back'
export * from './ui-card'
export * from './ui-container'
export * from './ui-copy'
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/lib/ui-back/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ui-back'
13 changes: 13 additions & 0 deletions packages/core/src/lib/ui-back/ui-back.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ActionIcon } from '@mantine/core'
import { IconArrowLeft } from '@tabler/icons-react'
import { useUiTheme } from '../ui-theme'

export function UiBack({ to = '../' }: { to?: string }) {
const { Link } = useUiTheme()

return (
<ActionIcon color="brand" component={Link} to={to} variant="light">
<IconArrowLeft />
</ActionIcon>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface ComponentGeneratorSchema {
*/
type:
| 'alert'
| 'back'
| 'card'
| 'container'
| 'copy'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"description": "The type of component to create",
"enum": [
"alert",
"back",
"card",
"container",
"copy",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ActionIcon } from '@mantine/core'
import { IconArrowLeft } from '@tabler/icons-react'
import { use<%= prefix.className %>Theme } from '../<%= prefix.fileName %>-theme'

export function <%= prefix.className %>Back({ to = '../' }: { to?: string }) {
const { Link } = use<%= prefix.className %>Theme()

return (
<ActionIcon color="brand" component={Link} to={to} variant="light">
<IconArrowLeft />
</ActionIcon>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './<%= prefixFileName %>-back'
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ComponentGeneratorSchema } from '../component/component-generator-schem

export const components: ComponentGeneratorSchema['type'][] = [
'alert',
'back',
'card',
'container',
'copy',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { UiBack, UiCard } from '@pubkey-ui/core'

export function DemoFeatureBack() {
return (
<UiCard title="Back">
<UiBack />
</UiCard>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { <%= prefix.className %>Container, <%= prefix.className %>NotFound, <%=
import { ReactNode } from 'react'
import { Link, Navigate, useLocation, useRoutes } from 'react-router-dom'
import { DemoFeatureAlerts } from './demo-feature-alerts'
import { DemoFeatureBack } from './demo-feature-back'
import { DemoFeatureCard } from './demo-feature-card'
import { DemoFeatureCopy } from './demo-feature-copy'
import { DemoFeatureDashboardGrid } from './demo-feature-dashboard-grid'
Expand All @@ -26,6 +27,7 @@ label: string
element: ReactNode
}[] = [
{ path: 'alerts', label: 'Alerts', element: <DemoFeatureAlerts /> },
{ path: 'back', label: 'Back', element: <DemoFeatureBack /> },
{ path: 'card', label: 'Card', element: <DemoFeatureCard /> },
{ path: 'copy', label: 'Copy', element: <DemoFeatureCopy /> },
{ path: 'dashboard-grid', label: 'Dashboard Grid', element: <DemoFeatureDashboardGrid /> },
Expand Down

0 comments on commit e6531a2

Please sign in to comment.