Skip to content

Commit 4a64231

Browse files
authored
feat: rename cookies folder to useCookieListener and support className/style for all components (#527)
1 parent fcc232b commit 4a64231

File tree

14 files changed

+39
-14
lines changed

14 files changed

+39
-14
lines changed

src/empty/index.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { ReactNode } from 'react';
22
import { Empty as AntdEmpty, EmptyProps as AntdEmptyProps } from 'antd';
3+
import classNames from 'classnames';
34

45
import './style.scss';
56

@@ -28,6 +29,8 @@ const Empty = (props: EmptyProps) => {
2829
image,
2930
imageStyle,
3031
extra,
32+
className,
33+
style,
3134
...restProps
3235
} = props;
3336

@@ -39,7 +42,7 @@ const Empty = (props: EmptyProps) => {
3942
const height = size === 'default' ? 80 : 100;
4043

4144
return showEmpty ? (
42-
<div className="dtc-empty">
45+
<div className={classNames('dtc-empty', className)} style={style}>
4346
<AntdEmpty {...restProps} image={newImage} imageStyle={{ height, ...imageStyle }}>
4447
{extra}
4548
</AntdEmpty>

src/filterRules/ruleController/index.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ interface IProps<T> {
1616
disabled?: boolean; // 编辑/查看状态
1717
maxLevel: number; // 节点最深层级数
1818
maxSize: number; // 节点最大子节点数量
19+
className?: string;
20+
style?: React.CSSProperties;
1921
component: (props: IComponentProps<T>) => React.ReactNode; // 自定义展示组件
2022
onAddCondition: (value: { key: string; isOut?: boolean }) => void; // 新增节点
2123
onDeleteCondition: (key: string) => void; // 删除节点
@@ -35,6 +37,8 @@ export const RulesController = <T,>(props: IProps<T>) => {
3537
disabled,
3638
maxLevel,
3739
maxSize,
40+
className,
41+
style,
3842
component,
3943
onAddCondition,
4044
onDeleteCondition,
@@ -233,7 +237,7 @@ export const RulesController = <T,>(props: IProps<T>) => {
233237
calculateTreeItemHeight(value, !!disabled);
234238

235239
return (
236-
<div className="dtc-ruleController">
240+
<div className={classnames('dtc-ruleController', className)} style={style}>
237241
{renderCondition(value, [], !!disabled || !!value.disabled)}
238242
</div>
239243
);

src/globalLoading/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface IGlobalLoadingProps {
99
mainBackground?: string;
1010
circleBackground?: string;
1111
titleColor?: string;
12+
style?: React.CSSProperties;
1213
}
1314

1415
const GlobalLoading: React.FC<IGlobalLoadingProps> = function (props) {
@@ -18,13 +19,14 @@ const GlobalLoading: React.FC<IGlobalLoadingProps> = function (props) {
1819
circleBackground = '#1D78FF',
1920
titleColor = '#3D446E',
2021
className = '',
22+
style,
2123
} = props;
2224
const prefixCls = 'dtc-global-loading';
2325

2426
return (
2527
<div
2628
className={classNames(`${prefixCls}-wrapper`, className)}
27-
style={{ background: mainBackground }}
29+
style={{ background: mainBackground, ...style }}
2830
data-testid="test-globalLoading"
2931
>
3032
<div className={`${prefixCls}-center`}>

src/image/index.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const ImageComponent = (props: IProps) => {
5151
};
5252

5353
const LazyImage = (props: IProps) => {
54-
const { src, ...rest } = props;
54+
const { src, className, style, ...rest } = props;
5555
const imgRef = useIntersectionObserver<HTMLImageElement>(([entry]) => {
5656
const { target, isIntersecting } = entry;
5757
if (isIntersecting) {
@@ -62,13 +62,13 @@ const LazyImage = (props: IProps) => {
6262
};
6363
}
6464
});
65-
return <img ref={imgRef} {...rest} data-src={src} />;
65+
return <img className={className} style={style} ref={imgRef} {...rest} data-src={src} />;
6666
};
6767

6868
const NormalImage = (props: IProps) => {
69-
const { src: originSrc, loader = <Spin spinning />, ...rest } = props;
69+
const { src: originSrc, className, style, loader = <Spin spinning />, ...rest } = props;
7070
const { src, isLoading } = useImage({ src: originSrc });
71-
if (src) return <img {...rest} src={src} />;
71+
if (src) return <img {...rest} className={className} style={style} src={src} />;
7272
if (isLoading) return loader;
7373
return null;
7474
};

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ export { default as Catalogue } from './catalogue';
33
export { default as CollapsibleActionItems } from './collapsibleActionItems';
44
export { default as ContentLayout } from './contentLayout';
55
export { default as ContextMenu } from './contextMenu';
6-
export { default as useCookieListener } from './cookies';
76
export { default as Copy } from './copy';
87
export { default as Drawer } from './drawer';
98
export { default as Dropdown } from './dropdown';
@@ -28,6 +27,7 @@ export { default as SpreadSheet } from './spreadSheet';
2827
export { default as StatusTag } from './statusTag';
2928
export { default as Table } from './table';
3029
export { default as TinyTag } from './tinyTag';
30+
export { default as useCookieListener } from './useCookieListener';
3131
export { default as useDebounce } from './useDebounce';
3232
export { default as useIntersectionObserver } from './useIntersectionObserver';
3333
export { default as useList } from './useList';

src/markdownRender/index.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@ export interface IMarkdownRenderProps {
1010
* 当前渲染的值
1111
*/
1212
value?: string;
13+
style?: React.CSSProperties;
1314
className?: string;
1415
/**
1516
* 暗黑模式
1617
*/
1718
dark?: boolean;
1819
}
1920

20-
export default function MarkdownRender({ value = '', className, dark }: IMarkdownRenderProps) {
21+
export default function MarkdownRender({
22+
value = '',
23+
className,
24+
style,
25+
dark,
26+
}: IMarkdownRenderProps) {
2127
const result = useMemo(() => {
2228
const converter = new showdown.Converter({
2329
extensions: [sqlHighlightExtension],
@@ -33,6 +39,7 @@ export default function MarkdownRender({ value = '', className, dark }: IMarkdow
3339
dark ? 'dtc-vs-dark' : 'dtc-vs',
3440
className
3541
)}
42+
style={style}
3643
dangerouslySetInnerHTML={{ __html: result }}
3744
/>
3845
);

src/notFound/index.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import React from 'react';
22
import { FrownOutlined } from '@ant-design/icons';
3+
import classNames from 'classnames';
34

45
import './style.scss';
56

6-
const NotFound: React.FC<any> = function () {
7+
const NotFound: React.FC<any> = function ({
8+
className,
9+
style,
10+
}: {
11+
className?: string;
12+
style?: React.CSSProperties;
13+
}) {
714
return (
8-
<div className="dtc-not-found">
15+
<div className={classNames('dtc-not-found', className)} style={style}>
916
<h1>
1017
<FrownOutlined /> 亲,是不是走错地方了?
1118
</h1>

src/progressLine/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface IProgressLineProps {
1616
width?: number | string;
1717
// 顶部左侧内容默认通过 tooltip hover 展示
1818
tooltipProps?: TooltipProps;
19+
style?: React.CSSProperties;
1920
}
2021

2122
const ProgressLine = (props: IProgressLineProps) => {
@@ -26,11 +27,12 @@ const ProgressLine = (props: IProgressLineProps) => {
2627
className = '',
2728
width = '280px',
2829
tooltipProps,
30+
style,
2931
} = props;
3032
const prefixCls = 'dtc-progress-line';
3133

3234
return (
33-
<div className={`${prefixCls} ${className}`}>
35+
<div className={`${prefixCls} ${className}`} style={style}>
3436
<div className={`${prefixCls}-title`} style={{ width }}>
3537
{/* 顶部左侧的内容 */}
3638
<Tooltip title={title} {...tooltipProps}>

src/tinyTag/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ const useSvgWidth = (): UseSvgWidthResult => {
3131
return [ref, svgWidth, rectWidth];
3232
};
3333

34-
export default function TinyTag({ value, className, ...restProps }: ITinyTag) {
34+
export default function TinyTag({ value, className, style, ...restProps }: ITinyTag) {
3535
const [ref, svgWidth, rectWidth] = useSvgWidth();
3636
return (
37-
<span className={classNames('dtc-tinyTag', className)} {...restProps}>
37+
<span className={classNames('dtc-tinyTag', className)} style={style} {...restProps}>
3838
<svg
3939
width={svgWidth}
4040
height="15"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)