Skip to content

Commit

Permalink
feat: improve
Browse files Browse the repository at this point in the history
  • Loading branch information
Pagebakers committed Nov 15, 2024
1 parent 8804082 commit 4ca3e77
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 100 deletions.
6 changes: 3 additions & 3 deletions packages/saas-ui-core/src/error-boundary/error-boundary.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'

import { SuiContext } from '../provider'
import { ErrorContext } from './error-provider.tsx'

export interface ErrorBoundaryProps {
fallback?: React.ReactNode
Expand All @@ -21,9 +21,9 @@ export interface ErrorBoundaryState {
export class ErrorBoundary extends React.Component<ErrorBoundaryProps> {
state: ErrorBoundaryState

static contextType = SuiContext
static contextType = ErrorContext

declare context: React.ContextType<typeof SuiContext>
declare context: React.ContextType<typeof ErrorContext>

constructor(props: ErrorBoundaryProps) {
super(props)
Expand Down
6 changes: 3 additions & 3 deletions packages/saas-ui-core/src/error-boundary/error-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ export interface ErrorContextValue {
onError?: (error: Error, errorInfo: React.ErrorInfo) => void
}

const context = React.createContext<ErrorContextValue>({})
export const ErrorContext = React.createContext<ErrorContextValue>({})

export const ErrorProvider = (props: ErrorProviderProps) => {
const { children, onError } = props

const value = React.useMemo(() => ({ onError }), [onError])

return <context.Provider value={value}>{children}</context.Provider>
return <ErrorContext.Provider value={value}>{children}</ErrorContext.Provider>
}

export const useErrorContext = () => React.useContext(context)
export const useErrorContext = () => React.useContext(ErrorContext)
3 changes: 0 additions & 3 deletions packages/saas-ui-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
export { defaultSystem, defaultConfig } from '../../saas-ui-react/src/preset'
export { createSystem } from '@chakra-ui/react'

export { SuiProvider, useLink, useSui } from './provider'
export type { SuiContext, SuiContextValue, SuiProviderProps } from './provider'

export { ErrorBoundary } from './error-boundary'
export type { ErrorBoundaryProps, ErrorBoundaryState } from './error-boundary'

Expand Down
75 changes: 0 additions & 75 deletions packages/saas-ui-core/src/system/factory.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const buttonRecipe = defineRecipe({
h: '7',
minW: '8',
textStyle: 'sm',
borderRadius: 'sm',
borderRadius: 'md',
px: '3',
},
md: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ import {
type AvatarRootProps,
HTMLChakraProps,
type ImageProps,
} from '@chakra-ui/react'

import {
type HTMLSystemProps,
SlotRecipeProps,
chakra,
createSlotRecipeContext,
sui,
} from '#system'

import { dataAttr } from '../utils'
} from '@chakra-ui/react'
import { dataAttr } from '@saas-ui/core/utils'

const {
useStyles: usePersonaStyles,
Expand Down Expand Up @@ -97,7 +92,7 @@ export const PersonaRoot = withProvider<HTMLDivElement, PersonaRootProps>(
const { outOfOffice, presence, ...rest } = props

return (
<sui.div
<chakra.div
ref={ref}
{...rest}
data-out-of-office={dataAttr(outOfOffice)}
Expand Down Expand Up @@ -171,14 +166,14 @@ export const PersonaAvatar = forwardRef<HTMLDivElement, PersonaAvatarProps>(
},
)

export interface PersonaPresenceBadgeProps extends HTMLSystemProps<'span'> {}
export interface PersonaPresenceBadgeProps extends HTMLChakraProps<'span'> {}

export const PersonaPresenceBadge = withContext<
HTMLSpanElement,
PersonaPresenceBadgeProps
>('span', 'presence')

export interface PersonaDetailsProps extends HTMLSystemProps<'div'> {}
export interface PersonaDetailsProps extends HTMLChakraProps<'div'> {}

/**
* Wrapper component for the labels.
Expand All @@ -190,7 +185,7 @@ export const PersonaDetails = withContext<HTMLDivElement, PersonaDetailsProps>(
'details',
)

export interface PersonaLabelProps extends HTMLSystemProps<'span'> {}
export interface PersonaLabelProps extends HTMLChakraProps<'span'> {}

/**
* The main label, usually a name.
Expand Down
2 changes: 1 addition & 1 deletion packages/saas-ui-react/src/components/persona/persona.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'

import * as PersonaPrimitive from './namespace.tsx'
import * as PersonaPrimitive from './namespace.ts'

interface PersonaOptions {
/**
Expand Down
4 changes: 2 additions & 2 deletions packages/saas-ui-react/src/components/sidebar/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export {
SidebarNavItem as NavItem,
SidebarNavButton as NavButton,
SidebarNavItemEndElement as NavItemEndElement,
} from './sidebar.ts'
} from './sidebar.tsx'

export type {
SidebarRootProps as RootProps,
SidebarNavButtonProps as NavButtonProps,
SidebarFlyoutTriggerProps as FlyoutTriggerProps,
SidebarProviderProps as ProviderProps,
SidebarTriggerProps as TriggerProps,
} from './sidebar.ts'
} from './sidebar.tsx'

0 comments on commit 4ca3e77

Please sign in to comment.