Skip to content

Commit 01a33db

Browse files
authored
fix: react default (#1961)
* fix: image show * chore: Upgraded ant to latest * fix: defaultProps
1 parent bd68ed6 commit 01a33db

File tree

7 files changed

+174
-104
lines changed

7 files changed

+174
-104
lines changed

src/components/BaseComponents/Card/index.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ interface IProps extends ICommonProps {
1313
}
1414
const Card: FC<IProps> = ({
1515
children,
16-
padding,
16+
padding = [28, 24],
1717
className,
1818
href,
19-
isDownload,
19+
isDownload = false,
2020
style,
2121
onClick,
2222
}): ReactElement => {
@@ -39,8 +39,4 @@ const Card: FC<IProps> = ({
3939
</>
4040
);
4141
};
42-
Card.defaultProps = {
43-
padding: [28, 24],
44-
isDownload: false,
45-
};
4642
export default Card;
Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
// Copyright 2023 DatabendLabs.
2-
import React, { FC, ReactElement, useState } from 'react';
2+
import React, { FC, ReactElement, useState } from "react";
33
// refs: https://databendcloud.github.io/databend-logos/
4-
import { LightDatabendSingleSvg } from 'databend-logos';
4+
import { LightDatabendSingleSvg } from "databend-logos";
55
// @ts-ignore
6-
import { LazyLoadImage } from 'react-lazy-load-image-component';
7-
import clsx from 'clsx';
6+
import { LazyLoadImage } from "react-lazy-load-image-component";
7+
import clsx from "clsx";
88
interface IProps {
99
src: string;
1010
width?: number | string;
1111
className?: string;
1212
}
13-
const LoadLazyImg: FC<IProps> = ({src, width, className}): ReactElement=> {
13+
const LoadLazyImg: FC<IProps> = ({
14+
src,
15+
width = "100%",
16+
className,
17+
}): ReactElement => {
1418
const [isLoaded, setIsLoaded] = useState(false);
1519
const handleImageLoad = () => {
1620
setIsLoaded(true);
1721
};
1822
return (
1923
<>
20-
{!isLoaded && <LightDatabendSingleSvg width={width}></LightDatabendSingleSvg>}
21-
<LazyLoadImage
22-
placeholder={<div></div>}
23-
onLoad={()=> handleImageLoad()}
24-
className={clsx('g-w100', className, isLoaded ? 'g-db' :'g-dn')}
25-
src={src} />
24+
{!isLoaded && (
25+
<LightDatabendSingleSvg width={width}></LightDatabendSingleSvg>
26+
)}
27+
<LazyLoadImage
28+
placeholder={<div></div>}
29+
onLoad={() => handleImageLoad()}
30+
className={clsx("g-w100", className, isLoaded ? "g-db" : "g-dn")}
31+
src={src}
32+
/>
2633
</>
27-
2834
);
2935
};
30-
LoadLazyImg.defaultProps = {
31-
width: "100%"
32-
}
33-
export default LoadLazyImg;
36+
37+
export default LoadLazyImg;
Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,48 @@
11
// Copyright 2023 DatabendLabs.
2-
import { FC, ReactElement } from 'react';
3-
import React from 'react';
2+
import { FC, ReactElement } from "react";
3+
import React from "react";
44
interface IProps {
55
width?: number;
66
style?: React.CSSProperties;
77
}
8-
const LogoSvg: FC<IProps> = ({width, style}): ReactElement=> {
8+
const LogoSvg: FC<IProps> = ({ width = 30, style }): ReactElement => {
99
return (
10-
<svg width={width} id="图层_1" style={style} data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 142.481 62.109"><title>Databend LOGO</title><path d="M118.8,52.156c-.732.733-3.571-1.776-4.536-3.23.174,1.772-.469,5.307-1.344,5.273-1.655-.064-2.721-4.841-2.1-8.047C100.447,40.2,89.9,45.4,89.9,45.4l.044.013c1.3.165,4.354.5,4.271,1.86-.055.9-4,3.6-16.377,2.59-3.891,3.288-19.6,10.347-33.5,8.03-10.087-2.361-15.489-7.034-18.308-11.884,2.577,1.809,13.382,7.9,34.6,1.181,24.479-7.758,32.3-12.017,52.583-6.729.006.019.012.032.019.051a17.022,17.022,0,0,1,1.117,3.529v.007C117.72,46.186,119.779,51.181,118.8,52.156Z" style={{"fill":"#b7e3ff"}}/><path d="M108.763,32.909a33.238,33.238,0,0,1,4.444,7.555c-20.283-5.288-28.1-1.029-52.583,6.729-21.216,6.723-32.021.628-34.6-1.181-.006-.012-.019-.031-.025-.044s-.013-.019-.013-.019a23.371,23.371,0,0,1-2.406-15.966c.444-.464.971-.965,1.562-1.486,2.323,2.1,13.686,10.888,35.81,5.346C60.954,33.843,95.635,25.057,108.763,32.909Z" style={{fill:"#52aaff"}}/><path d="M97.184,22.784a41.256,41.256,0,0,1,11.579,10.125c-13.128-7.852-47.809.934-47.809.934C38.83,39.385,27.467,30.6,25.144,28.5A56.869,56.869,0,0,1,45.007,17.616h.013A30.361,30.361,0,0,0,62.11,19.94C72.445,18.473,84.621,18.245,97.184,22.784Z" style={{fill:"#0175f2"}}/><path d="M92.315,20.213a51.143,51.143,0,0,1,4.869,2.571C84.621,18.245,72.445,18.473,62.11,19.94a30.416,30.416,0,0,1-17.1-2.324,67.405,67.405,0,0,1,39.106-.476A60.067,60.067,0,0,1,92.315,20.213Z" style={{fill:"#015bcb"}}/><path d="M61.062,2.5a2.516,2.516,0,0,1-1.53,2.3v.007A10.668,10.668,0,0,0,54.7,9.637a10.679,10.679,0,0,1,1.739-8.45c.089-.133.184-.254.286-.381A2.461,2.461,0,0,1,58.555,0,2.5,2.5,0,0,1,61.062,2.5Z" style={{fill:"#015bcb"}}/><path d="M52.428,12.17c0,.393-.025.78-.063,1.161a10.494,10.494,0,0,0-4.393-2.679.365.365,0,0,0-.121-.031,2.655,2.655,0,1,1,3.13-3.8A10.542,10.542,0,0,1,52.428,12.17Z" style={{fill:"#015bcb"}}/><circle cx="62.872" cy="46.714" r="2.28" style={{fill:"#0175f2"}}/></svg>
10+
<svg
11+
width={width}
12+
id="图层_1"
13+
style={style}
14+
data-name="图层 1"
15+
xmlns="http://www.w3.org/2000/svg"
16+
viewBox="0 0 142.481 62.109"
17+
>
18+
<title>Databend LOGO</title>
19+
<path
20+
d="M118.8,52.156c-.732.733-3.571-1.776-4.536-3.23.174,1.772-.469,5.307-1.344,5.273-1.655-.064-2.721-4.841-2.1-8.047C100.447,40.2,89.9,45.4,89.9,45.4l.044.013c1.3.165,4.354.5,4.271,1.86-.055.9-4,3.6-16.377,2.59-3.891,3.288-19.6,10.347-33.5,8.03-10.087-2.361-15.489-7.034-18.308-11.884,2.577,1.809,13.382,7.9,34.6,1.181,24.479-7.758,32.3-12.017,52.583-6.729.006.019.012.032.019.051a17.022,17.022,0,0,1,1.117,3.529v.007C117.72,46.186,119.779,51.181,118.8,52.156Z"
21+
style={{ fill: "#b7e3ff" }}
22+
/>
23+
<path
24+
d="M108.763,32.909a33.238,33.238,0,0,1,4.444,7.555c-20.283-5.288-28.1-1.029-52.583,6.729-21.216,6.723-32.021.628-34.6-1.181-.006-.012-.019-.031-.025-.044s-.013-.019-.013-.019a23.371,23.371,0,0,1-2.406-15.966c.444-.464.971-.965,1.562-1.486,2.323,2.1,13.686,10.888,35.81,5.346C60.954,33.843,95.635,25.057,108.763,32.909Z"
25+
style={{ fill: "#52aaff" }}
26+
/>
27+
<path
28+
d="M97.184,22.784a41.256,41.256,0,0,1,11.579,10.125c-13.128-7.852-47.809.934-47.809.934C38.83,39.385,27.467,30.6,25.144,28.5A56.869,56.869,0,0,1,45.007,17.616h.013A30.361,30.361,0,0,0,62.11,19.94C72.445,18.473,84.621,18.245,97.184,22.784Z"
29+
style={{ fill: "#0175f2" }}
30+
/>
31+
<path
32+
d="M92.315,20.213a51.143,51.143,0,0,1,4.869,2.571C84.621,18.245,72.445,18.473,62.11,19.94a30.416,30.416,0,0,1-17.1-2.324,67.405,67.405,0,0,1,39.106-.476A60.067,60.067,0,0,1,92.315,20.213Z"
33+
style={{ fill: "#015bcb" }}
34+
/>
35+
<path
36+
d="M61.062,2.5a2.516,2.516,0,0,1-1.53,2.3v.007A10.668,10.668,0,0,0,54.7,9.637a10.679,10.679,0,0,1,1.739-8.45c.089-.133.184-.254.286-.381A2.461,2.461,0,0,1,58.555,0,2.5,2.5,0,0,1,61.062,2.5Z"
37+
style={{ fill: "#015bcb" }}
38+
/>
39+
<path
40+
d="M52.428,12.17c0,.393-.025.78-.063,1.161a10.494,10.494,0,0,0-4.393-2.679.365.365,0,0,0-.121-.031,2.655,2.655,0,1,1,3.13-3.8A10.542,10.542,0,0,1,52.428,12.17Z"
41+
style={{ fill: "#015bcb" }}
42+
/>
43+
<circle cx="62.872" cy="46.714" r="2.28" style={{ fill: "#0175f2" }} />
44+
</svg>
1145
);
1246
};
13-
LogoSvg.defaultProps = {
14-
width: 30
15-
}
16-
export default LogoSvg;
47+
48+
export default LogoSvg;
Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright 2023 DatabendLabs.
2-
import React, { FC, ReactElement } from 'react';
3-
import styles from './styles.module.scss';
4-
import Avatar from '@site/static/img/avatar/default-avatar.jpeg';
5-
import clsx from 'clsx';
2+
import React, { FC, ReactElement } from "react";
3+
import styles from "./styles.module.scss";
4+
import Avatar from "@site/static/img/avatar/default-avatar.jpeg";
5+
import clsx from "clsx";
66
interface IProps {
77
name: string;
88
position: string;
@@ -11,29 +11,39 @@ interface IProps {
1111
avatar?: string;
1212
linkForDate?: string;
1313
}
14-
const CustomerVoiceCard: FC<IProps> = ({ name, position, description, date, avatar, linkForDate }): ReactElement=> {
14+
const CustomerVoiceCard: FC<IProps> = ({
15+
name,
16+
position,
17+
description,
18+
date,
19+
avatar = Avatar,
20+
linkForDate,
21+
}): ReactElement => {
1522
return (
1623
<div className={styles.card}>
1724
<div className={styles.top}>
18-
<a><img className={styles.avatar} src={avatar}/></a>
19-
<div style={{flex: 1}}>
25+
<a>
26+
<img className={styles.avatar} src={avatar} />
27+
</a>
28+
<div style={{ flex: 1 }}>
2029
<div className={styles.name}>{name}</div>
2130
<div className={styles.position}>{position}</div>
2231
</div>
2332
</div>
24-
<div className={styles.description}>
25-
{description}
26-
</div>
27-
{
28-
linkForDate
29-
? <a className={clsx(styles.date, styles.linkDate)} target='_blank' href={linkForDate}>{date}</a>
30-
: <div className={styles.date}>{date}</div>
31-
}
32-
33+
<div className={styles.description}>{description}</div>
34+
{linkForDate ? (
35+
<a
36+
className={clsx(styles.date, styles.linkDate)}
37+
target="_blank"
38+
href={linkForDate}
39+
>
40+
{date}
41+
</a>
42+
) : (
43+
<div className={styles.date}>{date}</div>
44+
)}
3345
</div>
3446
);
3547
};
36-
CustomerVoiceCard.defaultProps = {
37-
avatar: Avatar
38-
}
39-
export default CustomerVoiceCard;
48+
49+
export default CustomerVoiceCard;

src/components/EEFeature/index.tsx

Lines changed: 60 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,82 @@
1-
21
// Copyright 2023 DatabendLabs.
3-
import clsx from 'clsx';
4-
import React, { FC, ReactElement, useEffect } from 'react';
5-
import styles from './styles.module.scss';
6-
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
2+
import clsx from "clsx";
3+
import React, { FC, ReactElement, useEffect } from "react";
4+
import styles from "./styles.module.scss";
5+
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
76
interface IProps {
87
featureTitle?: string;
98
featureName: string;
109
wholeDesc?: string;
11-
1210
}
13-
const EEFeature: FC<IProps> = ({ featureName, wholeDesc, featureTitle }): ReactElement => {
14-
const {siteConfig: {customFields: { isChina } } } = useDocusaurusContext() as any;
11+
const EEFeature: FC<IProps> = ({
12+
featureName,
13+
wholeDesc,
14+
featureTitle = "ENTERPRISE EDITION FEATURE",
15+
}): ReactElement => {
16+
const {
17+
siteConfig: {
18+
customFields: { isChina },
19+
},
20+
} = useDocusaurusContext() as any;
1521
function A() {
1622
return (
1723
<>
18-
{
19-
isChina
20-
? <>如需获取许可证,请<a target='_blank' href={'https://www.databend.cn/contact-us'}>联系 Databend 支持团队</a></>
21-
: <>Contact <a target='_blank' href={'https://www.databend.com/contact-us'}>Databend Support</a> for a license.</>
22-
}
24+
{isChina ? (
25+
<>
26+
如需获取许可证,请
27+
<a target="_blank" href={"https://www.databend.cn/contact-us"}>
28+
联系 Databend 支持团队
29+
</a>
30+
31+
</>
32+
) : (
33+
<>
34+
Contact{" "}
35+
<a target="_blank" href={"https://www.databend.com/contact-us"}>
36+
Databend Support
37+
</a>{" "}
38+
for a license.
39+
</>
40+
)}
2341
</>
24-
)
42+
);
2543
}
2644
useEffect(() => {
27-
const h1 = document?.querySelector('.theme-doc-markdown')?.querySelector('header')?.firstChild as HTMLElement;
45+
const h1 = document
46+
?.querySelector(".theme-doc-markdown")
47+
?.querySelector("header")?.firstChild as HTMLElement;
2848
if (h1) {
29-
h1?.classList?.add('DOCITEM-PAGE-EE-TIPS-BEFORE-DOM');
49+
h1?.classList?.add("DOCITEM-PAGE-EE-TIPS-BEFORE-DOM");
3050
}
31-
}, [])
51+
}, []);
3252
return (
33-
<div className='DOCITEM-PAGE-EE-TIPS'>
53+
<div className="DOCITEM-PAGE-EE-TIPS">
3454
<div className={clsx(styles.wrap)}>
35-
<div className={styles.button}>{ isChina ? '企业版功能' : featureTitle }</div>
55+
<div className={styles.button}>
56+
{isChina ? "企业版功能" : featureTitle}
57+
</div>
3658
<div className={styles.desc}>
37-
{
38-
wholeDesc
39-
? <>
40-
{wholeDesc} <A />
41-
</>
42-
: <>
43-
{
44-
isChina
45-
? <>{featureName}是企业版功能。 <A /></>
46-
: <>{featureName} is an Enterprise Edition feature. <A /></>
47-
}
48-
</>
49-
}
59+
{wholeDesc ? (
60+
<>
61+
{wholeDesc} <A />
62+
</>
63+
) : (
64+
<>
65+
{isChina ? (
66+
<>
67+
{featureName}是企业版功能。 <A />
68+
</>
69+
) : (
70+
<>
71+
{featureName} is an Enterprise Edition feature. <A />
72+
</>
73+
)}
74+
</>
75+
)}
5076
</div>
5177
</div>
5278
</div>
5379
);
5480
};
55-
EEFeature.defaultProps = {
56-
featureTitle: 'ENTERPRISE EDITION FEATURE'
57-
}
58-
export default EEFeature;
81+
82+
export default EEFeature;
Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
// Copyright 2023 DatabendLabs.
2-
import React, { FC, ReactElement, useEffect } from 'react';
3-
import styles from './styles.module.scss';
4-
import clsx from 'clsx';
5-
import Tag from '@site/src/components/BaseComponents/Tag';
2+
import React, { FC, ReactElement, useEffect } from "react";
3+
import styles from "./styles.module.scss";
4+
import clsx from "clsx";
5+
import Tag from "@site/src/components/BaseComponents/Tag";
66
interface IProps {
77
description: string;
88
includesEETip?: boolean;
99
}
1010

11-
const FunctionDescription: FC<IProps> = ({ description, includesEETip }): ReactElement=> {
11+
const FunctionDescription: FC<IProps> = ({
12+
description,
13+
includesEETip = false,
14+
}): ReactElement => {
1215
useEffect(() => {
13-
const h1 = document?.querySelector('.theme-doc-markdown')?.querySelector('header')?.firstChild as HTMLElement;
16+
const h1 = document
17+
?.querySelector(".theme-doc-markdown")
18+
?.querySelector("header")?.firstChild as HTMLElement;
1419
if (h1) {
15-
h1?.classList?.add('DOCITEM-PAGE-FUNCTION-DESCRIPTION-DOM');
20+
h1?.classList?.add("DOCITEM-PAGE-FUNCTION-DESCRIPTION-DOM");
1621
}
17-
}, [])
22+
}, []);
1823
return (
19-
<div className={clsx(styles.description, includesEETip && styles.descriptionIncludesEE)}>
24+
<div
25+
className={clsx(
26+
styles.description,
27+
includesEETip && styles.descriptionIncludesEE
28+
)}
29+
>
2030
<Tag>{description}</Tag>
2131
</div>
2232
);
2333
};
24-
FunctionDescription.defaultProps = {
25-
includesEETip: false
26-
}
27-
28-
export default FunctionDescription;
34+
export default FunctionDescription;

src/components/Tags/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import EnterPriseSvg from "@site/static/icons/enterprise";
66
interface IProps {
77
list?: string[];
88
}
9-
const DatabendTags: FC<IProps> = ({ list }): ReactElement => {
9+
const DatabendTags: FC<IProps> = ({ list = ["Enterprise"] }): ReactElement => {
1010
return (
1111
<div className={styles.wrap}>
1212
{list?.map((item) => {
@@ -24,7 +24,5 @@ const DatabendTags: FC<IProps> = ({ list }): ReactElement => {
2424
</div>
2525
);
2626
};
27-
DatabendTags.defaultProps = {
28-
list: ["Enterprise"],
29-
};
27+
3028
export default DatabendTags;

0 commit comments

Comments
 (0)