-
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
34 changed files
with
2,272 additions
and
155 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import { UiThemeProvider } from '@pubkey-ui/core' | ||
import { Link } from 'react-router-dom' | ||
import { AppLayout } from './app-layout' | ||
|
||
import { AppRoutes } from './app-routes' | ||
|
||
export function App() { | ||
return ( | ||
<AppLayout> | ||
<AppRoutes /> | ||
</AppLayout> | ||
<UiThemeProvider link={({ children, ...props }) => <Link {...props}>{children}</Link>}> | ||
<AppLayout> | ||
<AppRoutes /> | ||
</AppLayout> | ||
</UiThemeProvider> | ||
) | ||
} |
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,24 @@ | ||
import { Button, SimpleGrid } from '@mantine/core' | ||
import { toastError, toastInfo, toastSuccess, toastWarning } from '@pubkey-ui/core' | ||
import { DemoCard } from './demo-card' | ||
|
||
export function DemoFeatureToast() { | ||
return ( | ||
<DemoCard title="Toast"> | ||
<SimpleGrid cols={2}> | ||
<Button color="green" onClick={() => toastSuccess('This is a success toast')}> | ||
Toast Success | ||
</Button> | ||
<Button color="red" onClick={() => toastError('This is an error toast')}> | ||
Toast Error | ||
</Button> | ||
<Button color="yellow" onClick={() => toastWarning('This is a warning toast')}> | ||
Toast Warning | ||
</Button> | ||
<Button color="cyan" onClick={() => toastInfo('This is an info toast')}> | ||
Toast Info | ||
</Button> | ||
</SimpleGrid> | ||
</DemoCard> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,5 +1,17 @@ | ||
import { UiContainer } from '@pubkey-ui/core' | ||
import { Anchor, Button } from '@mantine/core' | ||
import { UiCard, UiContainer, useUiTheme } from '@pubkey-ui/core' | ||
|
||
export function DevFeatureSearch() { | ||
return <UiContainer>xx</UiContainer> | ||
const { Link } = useUiTheme() | ||
return ( | ||
<UiContainer> | ||
<UiCard>TEST</UiCard> | ||
<Anchor component={Link} to="/demo"> | ||
Go to demo | ||
</Anchor> | ||
<Button component={Link} to="/demo"> | ||
Go to demo | ||
</Button> | ||
</UiContainer> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,12 +1,5 @@ | ||
import { UiContainer, UiStack } from '@pubkey-ui/core' | ||
import { DevFeatureSearch } from './dev-feature-search' | ||
|
||
export function DevFeature() { | ||
return ( | ||
<UiContainer> | ||
<UiStack> | ||
<DevFeatureSearch /> | ||
</UiStack> | ||
</UiContainer> | ||
) | ||
return <DevFeatureSearch /> | ||
} |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from './ui-color-scheme-provider' | ||
export * from './ui-theme' | ||
export * from './ui-theme-provider' | ||
export * from './use-ui-breakpoints' |
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,58 @@ | ||
import { ColorSchemeScript, createTheme, DEFAULT_THEME, Loader, MantineProvider } from '@mantine/core' | ||
import { ModalsProvider } from '@mantine/modals' | ||
import { Notifications } from '@mantine/notifications' | ||
import { createContext, FunctionComponent, ReactNode, Suspense, useContext } from 'react' | ||
import { UiColorSchemeProvider } from './ui-color-scheme-provider' | ||
|
||
// Import the mantine theme styles | ||
import './ui-theme-styles' | ||
|
||
const theme = createTheme({ | ||
colors: { | ||
brand: DEFAULT_THEME.colors.blue, | ||
}, | ||
primaryColor: 'brand', | ||
}) | ||
|
||
export type UiThemeLink = FunctionComponent<{ | ||
children: ReactNode | ||
to: string | ||
target?: HTMLAnchorElement['target'] | ||
rel?: HTMLAnchorElement['rel'] | ||
}> | ||
|
||
export const defaultUiThemeLink: UiThemeLink = ({ children, ...props }) => ( | ||
<a href={props.to} {...props}> | ||
{children} | ||
</a> | ||
) | ||
|
||
export interface UiThemeProviderContext { | ||
Link: UiThemeLink | ||
} | ||
|
||
const Context = createContext<UiThemeProviderContext>({} as UiThemeProviderContext) | ||
|
||
export function UiThemeProvider({ children, link }: { children: ReactNode; link?: UiThemeLink }) { | ||
const value: UiThemeProviderContext = { | ||
Link: link ?? defaultUiThemeLink, | ||
} | ||
|
||
return ( | ||
<Context.Provider value={value}> | ||
<ColorSchemeScript defaultColorScheme="auto" /> | ||
<MantineProvider theme={theme} defaultColorScheme="auto"> | ||
<UiColorSchemeProvider> | ||
<ModalsProvider> | ||
<Notifications /> | ||
<Suspense fallback={<Loader />}>{children}</Suspense> | ||
</ModalsProvider> | ||
</UiColorSchemeProvider> | ||
</MantineProvider> | ||
</Context.Provider> | ||
) | ||
} | ||
|
||
export function useUiTheme() { | ||
return useContext(Context) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ui-toast' |
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,37 @@ | ||
import { NotificationData, notifications } from '@mantine/notifications' | ||
|
||
export type ToastProps = string | NotificationData | ||
|
||
export function toastSuccess(notification: ToastProps) { | ||
notification = typeof notification === 'string' ? { message: notification } : notification | ||
notifications.show({ | ||
color: notification?.color ?? 'green', | ||
title: notification?.title ?? 'Success', | ||
message: notification?.message, | ||
}) | ||
} | ||
|
||
export function toastError(notification: ToastProps) { | ||
notification = typeof notification === 'string' ? { message: notification } : notification | ||
notifications.show({ | ||
color: notification?.color ?? 'red', | ||
title: notification?.title ?? 'Error', | ||
message: notification?.message, | ||
}) | ||
} | ||
export function toastWarning(notification: ToastProps) { | ||
notification = typeof notification === 'string' ? { message: notification } : notification | ||
notifications.show({ | ||
color: notification?.color ?? 'yellow', | ||
title: notification?.title ?? 'Warning', | ||
message: notification?.message, | ||
}) | ||
} | ||
export function toastInfo(notification: ToastProps) { | ||
notification = typeof notification === 'string' ? { message: notification } : notification | ||
notifications.show({ | ||
color: notification?.color ?? 'cyan', | ||
title: notification?.title ?? 'Info', | ||
message: notification?.message, | ||
}) | ||
} |
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
Oops, something went wrong.