From 59be31e542c0a25a39eec8728cdf44319a36dfb4 Mon Sep 17 00:00:00 2001 From: dengfuping Date: Thu, 25 Apr 2024 17:58:31 +0800 Subject: [PATCH] feat(ui): Boundary add className prop & built in ob-boundary-error, ob-boundary-403 and ob-boundary-404 className --- packages/ui/src/Boundary/Components/Code.tsx | 16 +++++++++++++--- .../ui/src/Boundary/Components/Exception.tsx | 19 ++++++++++++++++--- .../ui/src/Boundary/Components/Function.tsx | 10 +++++++--- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/packages/ui/src/Boundary/Components/Code.tsx b/packages/ui/src/Boundary/Components/Code.tsx index 836bbf82b..77370fcc6 100644 --- a/packages/ui/src/Boundary/Components/Code.tsx +++ b/packages/ui/src/Boundary/Components/Code.tsx @@ -6,8 +6,9 @@ import type { CodeType } from '../constant'; import { CODE_PRESET } from '../constant'; import type { BoundaryLocale } from '../IBoundary'; import zhCN from '../locale/zh-CN'; +import classNames from 'classnames'; -export interface IBoundaryCode extends LocaleWrapperProps { +export interface IBoundaryCode extends LocaleWrapperProps, React.HTMLProps { code: CodeType; onClick?: () => void; children?: React.ReactNode; @@ -18,7 +19,8 @@ export interface IBoundaryCode extends LocaleWrapperProps { } const BoundaryCode: React.FC = props => { - const { children, onClick, code, imageUrl, title, buttonText, locale } = props; + const { children, onClick, code, imageUrl, title, buttonText, locale, className, ...restProps } = + props; const info = useMemo(() => { const data = CODE_PRESET(locale); @@ -27,7 +29,15 @@ const BoundaryCode: React.FC = props => { }, [code, locale]); return ( -
+

{title || info.title}

diff --git a/packages/ui/src/Boundary/Components/Exception.tsx b/packages/ui/src/Boundary/Components/Exception.tsx index cd42a7422..4ca210562 100644 --- a/packages/ui/src/Boundary/Components/Exception.tsx +++ b/packages/ui/src/Boundary/Components/Exception.tsx @@ -5,8 +5,9 @@ import LocaleWrapper from '../../locale/LocaleWrapper'; import { EXCEPTION_PRESET } from '../constant'; import type { BoundaryLocale } from '../IBoundary'; import zhCN from '../locale/zh-CN'; +import classNames from 'classnames'; -export interface ExceptionProps extends LocaleWrapperProps { +export interface ExceptionProps extends LocaleWrapperProps, React.HTMLProps { children?: React.ReactNode; style?: React.CSSProperties; imageUrl?: string; @@ -62,6 +63,8 @@ class BoundaryException extends React.PureComponent +

{title || errorInfo.title}

@@ -105,7 +111,14 @@ class BoundaryException extends React.PureComponent +

{title || notCompatibleInfo.title}

diff --git a/packages/ui/src/Boundary/Components/Function.tsx b/packages/ui/src/Boundary/Components/Function.tsx index 4025a8930..881fbbdc1 100644 --- a/packages/ui/src/Boundary/Components/Function.tsx +++ b/packages/ui/src/Boundary/Components/Function.tsx @@ -1,8 +1,9 @@ import { Button } from '@oceanbase/design'; import React, { useMemo } from 'react'; import type { FunctionConfigType, FunctionStateType } from '../constant'; +import classNames from 'classnames'; -export interface IBoundaryFunction { +export interface IBoundaryFunction extends React.HTMLProps { children?: React.ReactNode; state: FunctionStateType; config: FunctionConfigType; @@ -10,13 +11,16 @@ export interface IBoundaryFunction { } export const BoundaryFunction: React.FC = props => { - const { children, state, config, onClick } = props; + const { children, state, config, onClick, className, ...restProps } = props; const info = useMemo(() => { return state ? config[state] : config[Object.keys(config)[0]]; }, [config, state]); return ( -
+

{info.title}