import PropTypes from 'prop-types';
import { createTheme, ThemeProvider } from '@arcblock/ux/lib/Theme';

const defaultTheme = createTheme();

/**
 * 允许 theme 被覆盖的 ThemeProvider 组件, 默认使用 ux default theme, 可以传入 theme 进行覆盖
 */
export default function OverridableThemeProvider({ theme: themeOverrides = null, children }) {
  const theme = themeOverrides ? createTheme(themeOverrides) : defaultTheme;
  return <ThemeProvider theme={theme}>{children}</ThemeProvider>;
}

OverridableThemeProvider.propTypes = {
  children: PropTypes.any.isRequired,
  theme: PropTypes.object,
};
