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

View File

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