Skip to content

Commit 9662b81

Browse files
authored
chore: speed up workflows (#119)
1 parent eaa78c6 commit 9662b81

File tree

128 files changed

+1508
-2149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+1508
-2149
lines changed

.dumi/components/SemanticPreview.tsx

+65-77
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,68 @@
1-
import React from 'react';
2-
import { Col, ConfigProvider, Flex, Row, Tag, theme, Typography } from 'antd';
1+
import { Col, ConfigProvider, Flex, Row, Tag, Typography, theme } from 'antd';
32
import { createStyles, css } from 'antd-style';
43
import classnames from 'classnames';
4+
import React from 'react';
55

66
const MARK_BORDER_SIZE = 2;
77

8-
const useStyle = createStyles(
9-
({ token }, markPos: [number, number, number, number]) => ({
10-
container: css`
11-
position: relative;
12-
`,
13-
colWrap: css`
14-
border-right: 1px solid ${token.colorBorderSecondary};
15-
display: flex;
16-
justify-content: center;
17-
align-items: center;
18-
padding: ${token.paddingMD}px;
19-
overflow: hidden;
20-
`,
21-
listWrap: css`
22-
display: flex;
23-
flex-direction: column;
24-
list-style: none;
25-
margin: 0;
26-
padding: 0;
27-
overflow: hidden;
28-
`,
29-
listItem: css`
30-
cursor: pointer;
31-
padding: ${token.paddingSM}px;
32-
transition: background-color ${token.motionDurationFast} ease;
33-
&:hover {
34-
background-color: ${token.controlItemBgHover};
35-
}
36-
&:not(:first-of-type) {
37-
border-top: 1px solid ${token.colorBorderSecondary};
38-
}
39-
`,
40-
marker: css`
41-
position: absolute;
42-
border: ${MARK_BORDER_SIZE}px solid ${token.colorWarning};
43-
box-sizing: border-box;
44-
z-index: 999999;
45-
box-shadow: 0 0 0 1px #fff;
46-
pointer-events: none;
47-
left: ${markPos[0] - MARK_BORDER_SIZE}px;
48-
top: ${markPos[1] - MARK_BORDER_SIZE}px;
49-
width: ${markPos[2] + MARK_BORDER_SIZE * 2}px;
50-
height: ${markPos[3] + MARK_BORDER_SIZE * 2}px;
51-
`,
52-
markerActive: css`
53-
opacity: 1;
54-
`,
55-
markerNotActive: css`
56-
opacity: 0;
57-
`,
58-
markerMotion: css`
59-
transition:
60-
opacity ${token.motionDurationSlow} ease,
61-
all ${token.motionDurationSlow} ease;
62-
`,
63-
markerNotMotion: css`
64-
transition: opacity ${token.motionDurationSlow} ease;
65-
`,
66-
}),
67-
);
8+
const useStyle = createStyles(({ token }, markPos: [number, number, number, number]) => ({
9+
container: css`
10+
position: relative;
11+
`,
12+
colWrap: css`
13+
border-right: 1px solid ${token.colorBorderSecondary};
14+
display: flex;
15+
justify-content: center;
16+
align-items: center;
17+
padding: ${token.paddingMD}px;
18+
overflow: hidden;
19+
`,
20+
listWrap: css`
21+
display: flex;
22+
flex-direction: column;
23+
list-style: none;
24+
margin: 0;
25+
padding: 0;
26+
overflow: hidden;
27+
`,
28+
listItem: css`
29+
cursor: pointer;
30+
padding: ${token.paddingSM}px;
31+
transition: background-color ${token.motionDurationFast} ease;
32+
&:hover {
33+
background-color: ${token.controlItemBgHover};
34+
}
35+
&:not(:first-of-type) {
36+
border-top: 1px solid ${token.colorBorderSecondary};
37+
}
38+
`,
39+
marker: css`
40+
position: absolute;
41+
border: ${MARK_BORDER_SIZE}px solid ${token.colorWarning};
42+
box-sizing: border-box;
43+
z-index: 999999;
44+
box-shadow: 0 0 0 1px #fff;
45+
pointer-events: none;
46+
inset-inline-start: ${markPos[0] - MARK_BORDER_SIZE}px;
47+
top: ${markPos[1] - MARK_BORDER_SIZE}px;
48+
width: ${markPos[2] + MARK_BORDER_SIZE * 2}px;
49+
height: ${markPos[3] + MARK_BORDER_SIZE * 2}px;
50+
`,
51+
markerActive: css`
52+
opacity: 1;
53+
`,
54+
markerNotActive: css`
55+
opacity: 0;
56+
`,
57+
markerMotion: css`
58+
transition:
59+
opacity ${token.motionDurationSlow} ease,
60+
all ${token.motionDurationSlow} ease;
61+
`,
62+
markerNotMotion: css`
63+
transition: opacity ${token.motionDurationSlow} ease;
64+
`,
65+
}));
6866

6967
export interface SemanticPreviewProps {
7068
semantics: { name: string; desc: string; version?: string }[];
@@ -103,18 +101,14 @@ const SemanticPreview: React.FC<SemanticPreviewProps> = (props) => {
103101

104102
const [positionMotion, setPositionMotion] = React.useState<boolean>(false);
105103
const [hoverSemantic, setHoverSemantic] = React.useState<string | null>(null);
106-
const [markPos, setMarkPos] = React.useState<
107-
[number, number, number, number]
108-
>([0, 0, 0, 0]);
104+
const [markPos, setMarkPos] = React.useState<[number, number, number, number]>([0, 0, 0, 0]);
109105

110106
const { styles } = useStyle(markPos);
111107

112108
React.useEffect(() => {
113109
if (hoverSemantic) {
114110
const targetClassName = getMarkClassName(hoverSemantic);
115-
const targetElement = containerRef.current?.querySelector<HTMLElement>(
116-
`.${targetClassName}`,
117-
);
111+
const targetElement = containerRef.current?.querySelector<HTMLElement>(`.${targetClassName}`);
118112
const containerRect = containerRef.current?.getBoundingClientRect();
119113
const targetRect = targetElement?.getBoundingClientRect();
120114
setMarkPos([
@@ -143,9 +137,7 @@ const SemanticPreview: React.FC<SemanticPreviewProps> = (props) => {
143137
<div className={classnames(styles.container)} ref={containerRef}>
144138
<Row style={{ minHeight: height }}>
145139
<Col span={16} className={classnames(styles.colWrap)}>
146-
<ConfigProvider theme={{ token: { motion: false } }}>
147-
{cloneNode}
148-
</ConfigProvider>
140+
<ConfigProvider theme={{ token: { motion: false } }}>{cloneNode}</ConfigProvider>
149141
</Col>
150142
<Col span={8}>
151143
<ul className={classnames(styles.listWrap)}>
@@ -161,13 +153,9 @@ const SemanticPreview: React.FC<SemanticPreviewProps> = (props) => {
161153
<Typography.Title level={5} style={{ margin: 0 }}>
162154
{semantic.name}
163155
</Typography.Title>
164-
{semantic.version && (
165-
<Tag color="blue">{semantic.version}</Tag>
166-
)}
156+
{semantic.version && <Tag color="blue">{semantic.version}</Tag>}
167157
</Flex>
168-
<Typography.Paragraph
169-
style={{ margin: 0, fontSize: token.fontSizeSM }}
170-
>
158+
<Typography.Paragraph style={{ margin: 0, fontSize: token.fontSizeSM }}>
171159
{semantic.desc}
172160
</Typography.Paragraph>
173161
</Flex>

.dumi/global.css

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.demo-logo {
2+
width: 120px;
3+
min-width: 120px;
4+
height: 32px;
5+
background: rgba(255, 255, 255, 0.2);
6+
border-radius: 6px;
7+
margin-inline-end: 24px;
8+
}
9+
10+
.demo-logo-vertical {
11+
height: 32px;
12+
margin: 16px;
13+
background: rgba(255, 255, 255, 0.2);
14+
border-radius: 6px;
15+
}
16+
17+
html {
18+
scrollbar-width: thin;
19+
scrollbar-color: unset;
20+
}

.dumi/hooks/use.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ function use<T>(promise: PromiseLike<T>): T {
99
}
1010
if (internal.status === 'rejected') {
1111
throw internal.reason;
12-
} else if (internal.status === 'pending') {
13-
throw internal;
14-
} else {
15-
internal.status = 'pending';
16-
internal.then(
17-
(result) => {
18-
internal.status = 'fulfilled';
19-
internal.value = result;
20-
},
21-
(reason) => {
22-
internal.status = 'rejected';
23-
internal.reason = reason;
24-
},
25-
);
12+
}
13+
if (internal.status === 'pending') {
2614
throw internal;
2715
}
16+
internal.status = 'pending';
17+
internal.then(
18+
(result) => {
19+
internal.status = 'fulfilled';
20+
internal.value = result;
21+
},
22+
(reason) => {
23+
internal.status = 'rejected';
24+
internal.reason = reason;
25+
},
26+
);
27+
throw internal;
2828
}
2929

3030
export default use;

.dumi/hooks/useFetch/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fetch from 'cross-fetch';
2+
23
import use from '../use';
34
import FetchCache from './cache';
45

.dumi/hooks/useLocation.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useLocation as useDumiLocation } from 'dumi';
22
import * as React from 'react';
3+
34
import useLocale from './useLocale';
45

56
function clearPath(path: string) {

.dumi/hooks/useMenu.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React, { useMemo } from 'react';
21
import type { MenuProps } from 'antd';
3-
import { Tag, version } from 'antd';
2+
import { Space, Tag, version } from 'antd';
43
import { createStyles } from 'antd-style';
54
import classnames from 'classnames';
65
import { useFullSidebarData, useSidebarData } from 'dumi';
6+
import React, { useMemo } from 'react';
77

88
import Link from '../theme/common/Link';
99
import useLocation from './useLocation';
@@ -22,7 +22,6 @@ const useStyle = createStyles(({ css, token }) => ({
2222
margin-inline-end: 0;
2323
`,
2424
subtitle: css`
25-
margin-inline-start: ${token.marginXS}px;
2625
font-weight: normal;
2726
font-size: ${token.fontSizeSM}px;
2827
opacity: 0.8;
@@ -46,10 +45,10 @@ const MenuItemLabelWithTag: React.FC<MenuItemLabelProps> = (props) => {
4645
if (!before && !after) {
4746
return (
4847
<Link to={`${link}${search}`} className={classnames(className, { [styles.link]: tag })}>
49-
<span>
50-
{title}
48+
<Space>
49+
<span>{title}</span>
5150
{subtitle && <span className={styles.subtitle}>{subtitle}</span>}
52-
</span>
51+
</Space>
5352
{tag && (
5453
<Tag
5554
bordered={false}

0 commit comments

Comments
 (0)