Skip to content

Commit 39b7edd

Browse files
site: use css logical attributes (ant-design#56388)
Co-authored-by: 遇见同学 <1875694521@qq.com>
1 parent dbf71b5 commit 39b7edd

2 files changed

Lines changed: 42 additions & 46 deletions

File tree

.dumi/hooks/useMenu.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const useStyle = createStyles(({ css, cssVar }) => ({
4646
font-weight: normal;
4747
font-size: ${cssVar.fontSizeSM};
4848
opacity: 0.8;
49-
margin-left: 4px;
49+
margin-inline-start: ${cssVar.marginSM};
5050
`,
5151
}));
5252

@@ -66,14 +66,15 @@ const MenuItemLabelWithTag: React.FC<MenuItemLabelProps> = (props) => {
6666
const { before, after, link, title, subtitle, search, tag, className } = props;
6767

6868
const [locale] = useLocale(locales);
69+
6970
const getLocale = (name: string) => {
7071
return (locale as any)[name.toLowerCase()] ?? name;
7172
};
7273

7374
if (!before && !after) {
7475
return (
7576
<Link to={`${link}${search}`} className={clsx(className, { [styles.link]: tag })}>
76-
<Flex justify="flex-start" align="center" gap="small">
77+
<Flex justify="flex-start" align="center">
7778
<span>{title}</span>
7879
{subtitle && <span className={styles.subtitle}>{subtitle}</span>}
7980
</Flex>

.dumi/theme/common/BehaviorMap/useMermaidCode.ts

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,45 @@ import { useMemo } from 'react';
22

33
import type { BehaviorMapItem } from './BehaviorMap';
44

5-
export const useMermaidCode = (data: BehaviorMapItem): string => {
6-
const generateMermaidCode = (root: BehaviorMapItem): string => {
7-
const lines: string[] = [];
8-
9-
lines.push('graph LR');
10-
11-
lines.push(`classDef baseNode fill:#fff,stroke:none,stroke-width:0px,rx:5,ry:5,font-size:14px`);
12-
13-
const traverse = (node: BehaviorMapItem, parentId?: string) => {
14-
const safeId = `node_${node.id.replace(/[^a-z0-9]/gi, '_')}`;
15-
let labelText = node.label.replace(/"/g, "'");
16-
17-
if (!parentId) {
18-
lines.push(`style ${safeId} font-size:16px`);
19-
labelText = `**${labelText}**`;
20-
} else if (node.targetType === 'mvp') {
21-
const blueDot = `<span style="display:inline-block;width:8px;height:8px;background-color:rgb(22, 119, 255);border-radius:50%;margin-right:8px;vertical-align:middle;"></span>`;
22-
labelText = `${blueDot}${labelText}`;
23-
} else if (node.targetType === 'extension') {
24-
const grayDot = `<span style="display:inline-block;width:8px;height:8px;background-color:rgb(160, 160, 160);border-radius:50%;margin-right:8px;vertical-align:middle;"></span>`;
25-
labelText = `${grayDot}${labelText}`;
26-
}
27-
lines.push(`${safeId}["${labelText}"]:::baseNode`);
28-
29-
if (node.link) {
30-
lines.push(`click ${safeId} "#${node.link}"`);
31-
}
32-
33-
if (parentId) {
34-
lines.push(`${parentId} --> ${safeId}`);
35-
}
36-
37-
if (node.children && node.children.length > 0) {
38-
node.children.forEach((child) => traverse(child, safeId));
39-
}
40-
};
41-
42-
traverse(root);
43-
return lines.join('\n');
5+
const generateMermaidCode = (root: BehaviorMapItem) => {
6+
const lines: string[] = [];
7+
8+
lines.push('graph LR');
9+
10+
lines.push(`classDef baseNode fill:#fff,stroke:none,stroke-width:0px,rx:5,ry:5,font-size:14px`);
11+
12+
const traverse = (node: BehaviorMapItem, parentId?: string) => {
13+
const safeId = `node_${node.id.replace(/[^a-z0-9]/gi, '_')}`;
14+
let labelText = node.label.replace(/"/g, "'");
15+
16+
if (!parentId) {
17+
lines.push(`style ${safeId} font-size:16px`);
18+
labelText = `**${labelText}**`;
19+
} else if (node.targetType === 'mvp') {
20+
const blueDot = `<span style="display:inline-block;width:8px;height:8px;background-color:rgb(22, 119, 255);border-radius:50%;margin-inline-end:8px;vertical-align:middle;"></span>`;
21+
labelText = `${blueDot}${labelText}`;
22+
} else if (node.targetType === 'extension') {
23+
const grayDot = `<span style="display:inline-block;width:8px;height:8px;background-color:rgb(160, 160, 160);border-radius:50%;margin-inline-end:8px;vertical-align:middle;"></span>`;
24+
labelText = `${grayDot}${labelText}`;
25+
}
26+
lines.push(`${safeId}["${labelText}"]:::baseNode`);
27+
28+
if (node.link) {
29+
lines.push(`click ${safeId} "#${node.link}"`);
30+
}
31+
32+
if (parentId) {
33+
lines.push(`${parentId} --> ${safeId}`);
34+
}
35+
36+
if (node.children && node.children.length > 0) {
37+
node.children.forEach((child) => traverse(child, safeId));
38+
}
4439
};
40+
traverse(root);
41+
return lines.join('\n');
42+
};
4543

46-
const mermaidCode = useMemo(() => {
47-
return generateMermaidCode(data);
48-
}, [data]);
49-
50-
return mermaidCode;
44+
export const useMermaidCode = (data: BehaviorMapItem) => {
45+
return useMemo(() => generateMermaidCode(data), [data]);
5146
};

0 commit comments

Comments
 (0)