Skip to content

Commit

Permalink
chore(ui-kit): updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sashathor committed Mar 28, 2024
1 parent bbb9f3c commit 5a04145
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
9 changes: 8 additions & 1 deletion app/storybook/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ const GlobalStyles = () => {
return null
}

const MyCustomButton = ({ children }: React.ComponentPropsWithoutRef<'button'>) => <button>{children}</button>

const withThemeProvider = (Story: React.FC, context: StoryContext) => {
if (context.parameters.skipThemeProvider) {
return <Story />
}

return (
<ThemeProvider baseTheme={context.globals.theme}>
<ThemeProvider
baseTheme={context.globals.theme}
// components={{
// Button: (props) => <MyCustomButton {...props} />
// }}
>
<GlobalStyles />
<Story />
</ThemeProvider>
Expand Down
8 changes: 6 additions & 2 deletions app/storybook/documentation/ui-kit/Fallbacks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Meta, Source, Canvas } from '@storybook/blocks'
import { SourceCode } from '../../.storybook/blocks/SourceCode'
import * as CounterStories from '../../../../packages/ui-kit/src/components/Counter/Counter.stories'

<Meta title="Customization/Fallbacks" />
<Meta title="Customization/Default components" />

# Fallbacks
# Default components

It's possible to customize the `Loading`, `Error`, and `Empty` states of the UI Kit components. This is useful when you
want to provide a consistent look and feel across your app. You can customize the fallbacks globally for all components
Expand All @@ -23,6 +23,10 @@ via `ThemeProvider`.
renderLoader={() => <div>Loading...</div>}
errorFallback={() => <h1>Error</h1>}
renderEmpty={() => <span>No Data</span>}
components={{
Input: ({ props }) => <MyCustomInput {...props} />
Button: ({ props }) => <MyCustomButton {...props} />
}}
>
<Counter />
Expand Down
5 changes: 5 additions & 0 deletions packages/ui-kit/src/components/shared.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ import { FilterInput, MetricInput, TimeRangeInput } from '../helpers'
import type { ErrorFallback as ErrorFallbackComponent, ErrorFallbackProps } from './ErrorFallback'
import type { Loader as LoaderComponent, LoaderProps } from './Loader'
import type { ThemeStateProps } from './ThemeProvider/ThemeProvider.types'
import { ButtonProps } from './Button'

/** Shared props for the data components. */

export interface FallbackComponents {
components?: {
Button?: (props: ButtonProps) => React.ReactElement
}

/**
* A fallback react component that will be used when the component is in error state.
*
Expand Down

0 comments on commit 5a04145

Please sign in to comment.