Prompt 的 form 主题保持一致

This commit is contained in:
2betop 2020-06-30 09:39:26 +08:00
parent ef1e9c0ade
commit beb44605f5
2 changed files with 13 additions and 6 deletions

View File

@ -201,7 +201,8 @@ export class Alert extends React.Component<AlertProps, AlertState> {
title, title,
confirmBtnLevel, confirmBtnLevel,
alertBtnLevel, alertBtnLevel,
classnames: cx classnames: cx,
theme
} = this.props; } = this.props;
const __ = this.props.translate; const __ = this.props.translate;
const finalTitle = __(this.state.title ?? title); const finalTitle = __(this.state.title ?? title);
@ -226,7 +227,8 @@ export class Alert extends React.Component<AlertProps, AlertState> {
this.state.controls, this.state.controls,
this.state.value, this.state.value,
this.handleFormSubmit, this.handleFormSubmit,
this.scopeRef this.scopeRef,
theme
) )
) : ( ) : (
<Html html={this.state.content} /> <Html html={this.state.content} />
@ -258,7 +260,8 @@ function renderForm(
controls: Array<any>, controls: Array<any>,
value: PlainObject = {}, value: PlainObject = {},
callback?: (values: PlainObject) => void, callback?: (values: PlainObject) => void,
scopeRef?: (value: any) => void scopeRef?: (value: any) => void,
theme?: string
) { ) {
return renderSchema( return renderSchema(
{ {
@ -271,7 +274,8 @@ function renderForm(
{ {
data: value, data: value,
onFinished: callback, onFinished: callback,
scopeRef scopeRef,
theme
}, },
{ {
session: 'prompt' session: 'prompt'

View File

@ -120,10 +120,11 @@ export interface ThemeProps {
className?: string; className?: string;
classPrefix: string; classPrefix: string;
classnames: ClassNamesFn; classnames: ClassNamesFn;
theme?: string;
} }
export const ThemeContext = React.createContext('theme');
export let defaultTheme: string = 'default'; export let defaultTheme: string = 'default';
export const ThemeContext = React.createContext(undefined);
export function themeable< export function themeable<
T extends React.ComponentType<React.ComponentProps<T> & ThemeProps> & { T extends React.ComponentType<React.ComponentProps<T> & ThemeProps> & {
@ -156,9 +157,11 @@ export function themeable<
const injectedProps: { const injectedProps: {
classPrefix: string; classPrefix: string;
classnames: ClassNamesFn; classnames: ClassNamesFn;
theme: string;
} = { } = {
classPrefix: config.classPrefix as string, classPrefix: config.classPrefix as string,
classnames: config.classnames classnames: config.classnames,
theme
}; };
return ( return (