-
+
{primaryColor}
{this.renderColorValidation()}
@@ -59,3 +57,5 @@ export default class ColorPaletteTool extends Component {
);
}
}
+
+export default ColorPaletteTool;
diff --git a/.dumi/theme/common/Color/ColorPaletteToolDark.jsx b/.dumi/theme/common/Color/ColorPaletteToolDark.tsx
similarity index 77%
rename from .dumi/theme/common/Color/ColorPaletteToolDark.jsx
rename to .dumi/theme/common/Color/ColorPaletteToolDark.tsx
index 2559b1afee..fdcf68e6fd 100644
--- a/.dumi/theme/common/Color/ColorPaletteToolDark.jsx
+++ b/.dumi/theme/common/Color/ColorPaletteToolDark.tsx
@@ -1,3 +1,4 @@
+import type { ChangeEvent } from 'react';
import React, { Component } from 'react';
import { FormattedMessage } from 'dumi';
import { Row, Col } from 'antd';
@@ -7,26 +8,25 @@ import ColorPatterns from './ColorPatterns';
const primaryMinSaturation = 70; // 主色推荐最小饱和度
const primaryMinBrightness = 70; // 主色推荐最小亮度
-export default class ColorPaletteTool extends Component {
+class ColorPaletteTool extends Component {
state = {
primaryColor: '#1890ff',
backgroundColor: '#141414',
primaryColorInstance: null,
};
- handleChangeColor = (e, color) => {
- const value = e.target ? e.target.value : e;
- this.setState({
- primaryColor: value,
- primaryColorInstance: color,
- });
+ handleChangeColor = (e: string | ChangeEvent, color: { hex: string }) => {
+ const value = (e as ChangeEvent
).target
+ ? (e as ChangeEvent).target.value
+ : e;
+ this.setState({ primaryColor: value, primaryColorInstance: color });
};
- handleChangeBackgroundColor = (e) => {
- const value = e.target ? e.target.value : e;
- this.setState({
- backgroundColor: value,
- });
+ handleChangeBackgroundColor = (e: string | ChangeEvent) => {
+ const value = (e as ChangeEvent).target
+ ? (e as ChangeEvent).target.value
+ : e;
+ this.setState({ backgroundColor: value });
};
renderColorValidation() {
@@ -56,7 +56,7 @@ export default class ColorPaletteTool extends Component {
return (
-
+ {ColorPatterns({ color: primaryColor, dark: true, backgroundColor })}
@@ -67,11 +67,7 @@ export default class ColorPaletteTool extends Component {
-
+
{primaryColor}
@@ -87,7 +83,6 @@ export default class ColorPaletteTool extends Component {
@@ -105,3 +100,5 @@ export default class ColorPaletteTool extends Component {
);
}
}
+
+export default ColorPaletteTool;
diff --git a/.dumi/theme/common/Color/ColorPalettes.jsx b/.dumi/theme/common/Color/ColorPalettes.jsx
deleted file mode 100644
index f7411668d6..0000000000
--- a/.dumi/theme/common/Color/ColorPalettes.jsx
+++ /dev/null
@@ -1,94 +0,0 @@
-import React from 'react';
-import cls from 'classnames';
-import Palette from './Palette';
-
-const ColorPalettes = (props) => {
- const { dark } = props;
-
- const colors = [
- {
- name: 'red',
- english: 'Dust Red',
- chinese: '薄暮',
- description: '斗志、奔放',
- },
- {
- name: 'volcano',
- english: 'Volcano',
- chinese: '火山',
- description: '醒目、澎湃',
- },
- {
- name: 'orange',
- english: 'Sunset Orange',
- chinese: '日暮',
- description: '温暖、欢快',
- },
- {
- name: 'gold',
- english: 'Calendula Gold',
- chinese: '金盏花',
- description: '活力、积极',
- },
- {
- name: 'yellow',
- english: 'Sunrise Yellow',
- chinese: '日出',
- description: '出生、阳光',
- },
- {
- name: 'lime',
- english: 'Lime',
- chinese: '青柠',
- description: '自然、生机',
- },
- {
- name: 'green',
- english: 'Polar Green',
- chinese: '极光绿',
- description: '健康、创新',
- },
- {
- name: 'cyan',
- english: 'Cyan',
- chinese: '明青',
- description: '希望、坚强',
- },
- {
- name: 'blue',
- english: 'Daybreak Blue',
- chinese: '拂晓蓝',
- description: '包容、科技、普惠',
- },
- {
- name: 'geekblue',
- english: 'Geek Blue',
- chinese: '极客蓝',
- description: '探索、钻研',
- },
- {
- name: 'purple',
- english: 'Golden Purple',
- chinese: '酱紫',
- description: '优雅、浪漫',
- },
- {
- name: 'magenta',
- english: 'Magenta',
- chinese: '法式洋红',
- description: '明快、感性',
- },
- ];
- const colorCls = cls('color-palettes', {
- 'color-palettes-dark': !!dark,
- });
- return (
-
- {colors.map((color) => (
-
- ))}
-
- );
-};
-
-export default ColorPalettes;
diff --git a/.dumi/theme/common/Color/ColorPalettes.tsx b/.dumi/theme/common/Color/ColorPalettes.tsx
new file mode 100644
index 0000000000..b380e3f60d
--- /dev/null
+++ b/.dumi/theme/common/Color/ColorPalettes.tsx
@@ -0,0 +1,94 @@
+import React from 'react';
+import cls from 'classnames';
+import Palette from './Palette';
+
+const colors = [
+ {
+ name: 'red',
+ english: 'Dust Red',
+ chinese: '薄暮',
+ description: '斗志、奔放',
+ },
+ {
+ name: 'volcano',
+ english: 'Volcano',
+ chinese: '火山',
+ description: '醒目、澎湃',
+ },
+ {
+ name: 'orange',
+ english: 'Sunset Orange',
+ chinese: '日暮',
+ description: '温暖、欢快',
+ },
+ {
+ name: 'gold',
+ english: 'Calendula Gold',
+ chinese: '金盏花',
+ description: '活力、积极',
+ },
+ {
+ name: 'yellow',
+ english: 'Sunrise Yellow',
+ chinese: '日出',
+ description: '出生、阳光',
+ },
+ {
+ name: 'lime',
+ english: 'Lime',
+ chinese: '青柠',
+ description: '自然、生机',
+ },
+ {
+ name: 'green',
+ english: 'Polar Green',
+ chinese: '极光绿',
+ description: '健康、创新',
+ },
+ {
+ name: 'cyan',
+ english: 'Cyan',
+ chinese: '明青',
+ description: '希望、坚强',
+ },
+ {
+ name: 'blue',
+ english: 'Daybreak Blue',
+ chinese: '拂晓蓝',
+ description: '包容、科技、普惠',
+ },
+ {
+ name: 'geekblue',
+ english: 'Geek Blue',
+ chinese: '极客蓝',
+ description: '探索、钻研',
+ },
+ {
+ name: 'purple',
+ english: 'Golden Purple',
+ chinese: '酱紫',
+ description: '优雅、浪漫',
+ },
+ {
+ name: 'magenta',
+ english: 'Magenta',
+ chinese: '法式洋红',
+ description: '明快、感性',
+ },
+];
+
+const ColorPalettes: React.FC<{ dark?: boolean }> = (props) => {
+ const { dark } = props;
+ const colorCls = cls('color-palettes', {
+ 'color-palettes-dark': !!dark,
+ });
+ return (
+
+ {colors.map((color) => (
+
+ ))}
+
+ );
+};
+
+export default ColorPalettes;
diff --git a/.dumi/theme/common/Color/ColorPatterns.jsx b/.dumi/theme/common/Color/ColorPatterns.tsx
similarity index 63%
rename from .dumi/theme/common/Color/ColorPatterns.jsx
rename to .dumi/theme/common/Color/ColorPatterns.tsx
index 6989b20215..d40d88a0c9 100644
--- a/.dumi/theme/common/Color/ColorPatterns.jsx
+++ b/.dumi/theme/common/Color/ColorPatterns.tsx
@@ -3,9 +3,17 @@ import { generate } from '@ant-design/colors';
import uniq from 'lodash/uniq';
import ColorBlock from './ColorBlock';
-export default function ColorPatterns({ color, dark, backgroundColor }) {
+interface ColorPatternsProps {
+ color?: string;
+ dark?: boolean;
+ backgroundColor?: string;
+}
+
+const ColorPatterns = ({ color, dark, backgroundColor }: ColorPatternsProps) => {
const colors = generate(color, dark ? { theme: 'dark', backgroundColor } : {});
return uniq(colors).map((colorString, i) => (
));
-}
+};
+
+export default ColorPatterns;
diff --git a/.dumi/theme/common/Color/ColorPicker.tsx b/.dumi/theme/common/Color/ColorPicker.tsx
index 5e7fe77f5b..e6b5d92871 100644
--- a/.dumi/theme/common/Color/ColorPicker.tsx
+++ b/.dumi/theme/common/Color/ColorPicker.tsx
@@ -5,11 +5,11 @@ const noop = () => {};
interface ColorPickerProps {
color?: string;
- small: boolean;
- position: string;
+ small?: boolean;
+ position?: string;
presetColors?: string[];
- onChange: (hex: string, color: { hex: string }) => void;
- onChangeComplete: (hex: string) => void;
+ onChange?: (hex: string, color: { hex: string }) => void;
+ onChangeComplete?: (hex: string) => void;
}
export default class ColorPicker extends Component {
diff --git a/.dumi/theme/common/Color/ColorStyle.tsx b/.dumi/theme/common/Color/ColorStyle.tsx
index 58ebe6d3ab..9de6c08de0 100644
--- a/.dumi/theme/common/Color/ColorStyle.tsx
+++ b/.dumi/theme/common/Color/ColorStyle.tsx
@@ -48,89 +48,89 @@ ${makeGrayPalette(index + 1)}
return (
);
};
diff --git a/.dumi/theme/common/Color/Palette.jsx b/.dumi/theme/common/Color/Palette.tsx
similarity index 83%
rename from .dumi/theme/common/Color/Palette.jsx
rename to .dumi/theme/common/Color/Palette.tsx
index 5b35b6a365..3f5f624653 100644
--- a/.dumi/theme/common/Color/Palette.jsx
+++ b/.dumi/theme/common/Color/Palette.tsx
@@ -3,7 +3,7 @@ import { message } from 'antd';
import CopyToClipboard from 'react-copy-to-clipboard';
import { presetDarkPalettes } from '@ant-design/colors';
-const rgbToHex = (rgbString) => {
+const rgbToHex = (rgbString: string): string => {
const rgb = rgbString.match(/\d+/g);
let r = parseInt(rgb[0], 10).toString(16);
let g = parseInt(rgb[1], 10).toString(16);
@@ -14,10 +14,21 @@ const rgbToHex = (rgbString) => {
return `#${r}${g}${b}`;
};
-export default class Palette extends React.Component {
+interface PaletteProps {
+ showTitle?: boolean;
+ direction?: 'horizontal' | 'vertical';
+ dark?: boolean;
+ color?: any;
+}
+
+class Palette extends React.Component {
+ hexColors: Record;
+
+ colorNodes: Record;
+
componentDidMount() {
this.hexColors = {};
- Object.keys(this.colorNodes).forEach((key) => {
+ Object.keys(this.colorNodes || {}).forEach((key) => {
const computedColor = getComputedStyle(this.colorNodes[key])['background-color'];
if (computedColor.includes('rgba')) {
this.hexColors[key] = computedColor;
@@ -34,10 +45,10 @@ export default class Palette extends React.Component {
showTitle,
direction,
dark,
- color: { name, description, english, chinese, count = 10 },
+ color: { name, description, english, chinese, count } = { name: 'gray', count: 13 },
} = this.props;
const className = direction === 'horizontal' ? 'color-palette-horizontal' : 'color-palette';
- const colors = [];
+ const colors: React.ReactNode[] = [];
const colorName = `${english} / ${chinese}`;
const colorPaletteMap = {
dark: ['#fff', 'unset'],
@@ -88,6 +99,4 @@ export default class Palette extends React.Component {
}
}
-Palette.defaultProps = {
- color: { name: 'gray', count: 13 },
-};
+export default Palette;
diff --git a/.dumi/theme/common/ExternalLinkIcon.jsx b/.dumi/theme/common/ExternalLinkIcon.tsx
similarity index 79%
rename from .dumi/theme/common/ExternalLinkIcon.jsx
rename to .dumi/theme/common/ExternalLinkIcon.tsx
index a0429db503..f193d6a695 100644
--- a/.dumi/theme/common/ExternalLinkIcon.jsx
+++ b/.dumi/theme/common/ExternalLinkIcon.tsx
@@ -1,13 +1,15 @@
import React from 'react';
import Icon from '@ant-design/icons';
-const SVGIcon = ({ color = 'currentColor' }) => (
+const SVGIcon: React.FC<{ color?: string }> = ({ color = 'currentColor' }) => (
);
-const ExternalLinkIcon = (props) => ;
+const ExternalLinkIcon: React.FC<{ className?: string }> = (props) => (
+
+);
export default ExternalLinkIcon;
diff --git a/.dumi/theme/common/PrevAndNext.tsx b/.dumi/theme/common/PrevAndNext.tsx
index 1a36a40a0d..4752705ee6 100644
--- a/.dumi/theme/common/PrevAndNext.tsx
+++ b/.dumi/theme/common/PrevAndNext.tsx
@@ -96,7 +96,7 @@ const flattenMenu = (menuItems: MenuProps['items']): MenuProps['items'] | null =
return null;
};
-const PrevAndNext = () => {
+const PrevAndNext: React.FC = () => {
const styles = useStyle();
const [menuItems, selectedKey] = useMenu({
diff --git a/.dumi/theme/common/RiddleIcon.jsx b/.dumi/theme/common/RiddleIcon.tsx
similarity index 94%
rename from .dumi/theme/common/RiddleIcon.jsx
rename to .dumi/theme/common/RiddleIcon.tsx
index e8efd77dc5..2c46a24152 100644
--- a/.dumi/theme/common/RiddleIcon.jsx
+++ b/.dumi/theme/common/RiddleIcon.tsx
@@ -1,12 +1,14 @@
import React from 'react';
import Icon from '@ant-design/icons';
-const SVGIcon = () => (
+const SVGIcon: React.FC = () => (
);
-const RiddleIcon = (props) => ;
+const RiddleIcon: React.FC<{ className?: string }> = (props) => (
+
+);
export default RiddleIcon;
diff --git a/.dumi/theme/common/ThemeSwitch/ThemeIcon.tsx b/.dumi/theme/common/ThemeSwitch/ThemeIcon.tsx
index cbf413a5d3..724f5a8c84 100644
--- a/.dumi/theme/common/ThemeSwitch/ThemeIcon.tsx
+++ b/.dumi/theme/common/ThemeSwitch/ThemeIcon.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import Icon from '@ant-design/icons';
-const ThemeIcon = (props: any) => {
+const ThemeIcon: React.FC<{ className?: string }> = (props) => {
const SVGIcon = React.useCallback(
() => (