Skip to content

Commit 13eb34a

Browse files
committed
feat: update config-provider config
1 parent d8a6833 commit 13eb34a

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

packages/ui/src/components/config-provider/ConfigProvider.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import { ConfigContext } from './context';
44
import type { ComponentConfig, ConfigProviderProps } from './types';
55

6-
const COMPONENT_KEYS = ['accordion'] satisfies (keyof ComponentConfig)[];
6+
const COMPONENT_KEYS = ['accordion', 'alert', 'icon'] satisfies (keyof ComponentConfig)[];
77

8-
export const ConfigProvider = (props: ConfigProviderProps) => {
8+
const ConfigProvider = (props: ConfigProviderProps) => {
99
const { children, direction = 'ltr', size = 'md', theme = { color: 'default' }, ...rest } = props;
1010

1111
const componentConfig = Object.fromEntries(
@@ -21,3 +21,5 @@ export const ConfigProvider = (props: ConfigProviderProps) => {
2121

2222
return <ConfigContext.Provider value={componentConfig}>{children}</ConfigContext.Provider>;
2323
};
24+
25+
export default ConfigProvider;

packages/ui/src/components/config-provider/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { ComponentConfig } from './types';
66

77
export const ConfigContext = createContext<ComponentConfig>({});
88

9-
export const useComponentConfig = <T extends keyof ComponentConfig>(component: T) => {
9+
export const useComponentConfig = <T extends keyof ComponentConfig>(component: T): ComponentConfig[T] => {
1010
const config = useContext(ConfigContext);
1111

1212
if (!config) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export * from './ConfigProvider';
1+
export { default as ConfigProvider } from './ConfigProvider';
22

33
export * from './types';

packages/ui/src/components/config-provider/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import type { ThemeOptions } from '@soybean-react-ui/tailwind-plugin';
33
import type { ThemeSize } from '@/types/other';
44

55
import type { AccordionProps } from '../accordion/types';
6+
import type { AlertProps } from '../alert';
7+
import type { IconProps } from '../icon';
68

79
export interface ConfigProviderProps extends ConfigProps {
810
children: React.ReactNode;
@@ -16,6 +18,15 @@ export interface ConfigProps extends ComponentConfig {
1618

1719
export type ComponentConfig = {
1820
accordion?: AccordionConfig;
21+
alert?: AlertConfig;
22+
icon?: IconConfig;
1923
};
2024

2125
export type AccordionConfig = Pick<AccordionProps, 'className' | 'classNames' | 'dir' | 'size' | 'triggerIcon'>;
26+
27+
export type AlertConfig = Pick<
28+
AlertProps,
29+
'className' | 'classNames' | 'color' | 'icon' | 'leading' | 'size' | 'trailing' | 'variant'
30+
>;
31+
32+
export type IconConfig = Pick<IconProps, 'className' | 'color' | 'height' | 'inline' | 'width'>;

0 commit comments

Comments
 (0)