Skip to content

Commit 07daffe

Browse files
committed
feat(ui): add rating component
1 parent 6b83ccb commit 07daffe

74 files changed

Lines changed: 491 additions & 412 deletions

Some content is hidden

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"react-router-dom": "^6.2.1",
4141
"regenerator-runtime": "^0.13.9",
4242
"rfs": "^9.0.6",
43-
"rxjs": "^7.5.3",
43+
"rxjs": "^7.5.4",
4444
"scrollview-resize": "^1.0.2",
4545
"tslib": "^2.3.1"
4646
},
@@ -64,7 +64,7 @@
6464
"@types/jest": "^27.4.0",
6565
"@types/lodash": "^4.14.177",
6666
"@types/marked": "^4.0.2",
67-
"@types/node": "^17.0.16",
67+
"@types/node": "^17.0.17",
6868
"@types/react": "^17.0.39",
6969
"@types/react-dom": "^17.0.11",
7070
"@typescript-eslint/eslint-plugin": "^5.11.0",
@@ -76,7 +76,7 @@
7676
"eslint-config-prettier": "^8.3.0",
7777
"eslint-plugin-cypress": "^2.12.1",
7878
"eslint-plugin-import": "^2.25.4",
79-
"eslint-plugin-jsdoc": "^37.8.0",
79+
"eslint-plugin-jsdoc": "^37.8.2",
8080
"eslint-plugin-jsx-a11y": "^6.5.1",
8181
"eslint-plugin-markdown": "^2.2.1",
8282
"eslint-plugin-prettier": "^4.0.0",

packages/site/src/app/components/route/component/ComponentRouteArticle.tsx

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { useLayoutEffect } from 'react';
22
import { useTranslation } from 'react-i18next';
33

4-
import { DTooltip, DIcon } from '@react-devui/ui';
5-
64
import { AppRouteArticle } from '../RouteArticle';
75
import marked, { toString } from '../utils';
86
import './ComponentRouteArticle.scss';
@@ -32,37 +30,27 @@ export function AppComponentRouteArticle(props: AppComponentRouteArticleProps) {
3230
};
3331
}, [i18n.language, subtitle, title]);
3432

35-
useLayoutEffect(() => {
36-
const descriptionEl = document.querySelector(`meta[name="description"]`);
37-
const description = descriptionEl?.getAttribute('content') ?? '';
38-
descriptionEl?.setAttribute(
39-
'content',
40-
document.querySelector('.app-component-route-article__description > p:first-child')?.textContent ?? description
41-
);
42-
return () => {
43-
descriptionEl?.setAttribute('content', description);
44-
};
45-
}, [i18n.language]);
33+
// useLayoutEffect(() => {
34+
// const descriptionEl = document.querySelector(`meta[name="description"]`);
35+
// const description = descriptionEl?.getAttribute('content') ?? '';
36+
// descriptionEl?.setAttribute(
37+
// 'content',
38+
// document.querySelector('.app-component-route-article__description > p:first-child')?.textContent ?? description
39+
// );
40+
// return () => {
41+
// descriptionEl?.setAttribute('content', description);
42+
// };
43+
// }, [i18n.language]);
4644

4745
return (
4846
<AppRouteArticle links={links}>
4947
<h1 id="title" className="app-component-route-article__title">
5048
{title}
5149
{i18n.language !== 'en-US' && <span className="app-component-route-article__subtitle">{subtitle}</span>}
52-
<DTooltip dTitle={t('Edit this page on GitHub')}>
53-
<DIcon className="app-icon-button" style={{ marginLeft: 4 }} viewBox="64 64 896 896" role="button" dSize={20}>
54-
<path d="M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"></path>
55-
</DIcon>
56-
</DTooltip>
5750
</h1>
5851
<section className="app-component-route-article__description" dangerouslySetInnerHTML={{ __html: description }} />
5952
<h2 id="Examples" className="app-component-route-article__examples">
6053
{t('Examples')}
61-
<DTooltip dTitle={t('Expand all code')}>
62-
<DIcon className="app-icon-button" style={{ marginLeft: 4 }} viewBox="64 64 896 896" role="button" dSize={24}>
63-
<path d="M516 673c0 4.4 3.4 8 7.5 8h185c4.1 0 7.5-3.6 7.5-8v-48c0-4.4-3.4-8-7.5-8h-185c-4.1 0-7.5 3.6-7.5 8v48zm-194.9 6.1l192-161c3.8-3.2 3.8-9.1 0-12.3l-192-160.9A7.95 7.95 0 00308 351v62.7c0 2.4 1 4.6 2.9 6.1L420.7 512l-109.8 92.2a8.1 8.1 0 00-2.9 6.1V673c0 6.8 7.9 10.5 13.1 6.1zM880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"></path>
64-
</DIcon>
65-
</DTooltip>
6654
</h2>
6755
<section className="app-component-route-article__demos">{demos}</section>
6856
<section className="app-component-route-article__api" dangerouslySetInnerHTML={{ __html: api }} />

packages/site/src/app/components/route/component/DemoBox.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,7 @@ ${'```'}
8888
>
8989
<div className="app-demo-box__renderer">{renderer}</div>
9090
<div className="app-demo-box__info">
91-
<div className="app-demo-box__title">
92-
{title}
93-
<DTooltip dTitle={t('Edit this demo on GitHub')}>
94-
<DIcon className="app-icon-button" style={{ marginLeft: 4 }} viewBox="64 64 896 896" role="button" dSize={16}>
95-
<path d="M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"></path>
96-
</DIcon>
97-
</DTooltip>
98-
</div>
91+
<div className="app-demo-box__title">{title}</div>
9992
<div className="app-demo-box__description" dangerouslySetInnerHTML={{ __html: description }} />
10093
</div>
10194
<div className="app-demo-box__toolbar">

packages/site/src/app/configs/icons.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,16 @@
154154
]
155155
}
156156
]
157+
},
158+
{
159+
"name": "heart",
160+
"list": [
161+
{
162+
"viewBox": "64 64 896 896",
163+
"paths": [
164+
"M923 283.6a260.04 260.04 0 00-56.9-82.8 264.4 264.4 0 00-84-55.5A265.34 265.34 0 00679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 00-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9z"
165+
]
166+
}
167+
]
157168
}
158169
]

packages/ui/src/components/_popup/Popup.tsx

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
useContentSVChangeConfig,
1919
} from '../../hooks';
2020
import { getClassName, getPopupPlacementStyle, mergeStyle } from '../../utils';
21-
import { checkOutEl } from './utils';
2221

2322
export interface DTriggerRenderProps {
2423
[key: `data-${string}popup-trigger`]: string;
@@ -102,12 +101,10 @@ const Popup: React.ForwardRefRenderFunction<DPopupRef, DPopupProps> = (props, re
102101

103102
const dataRef = useRef<{
104103
clearTid: (() => void) | null;
105-
hasCancelLeave: boolean;
106104
transitionState?: DTransitionStateList;
107105
triggerRect?: { top: number; left: number };
108106
}>({
109107
clearTid: null,
110-
hasCancelLeave: false,
111108
});
112109

113110
const asyncCapture = useAsync();
@@ -294,7 +291,6 @@ const Popup: React.ForwardRefRenderFunction<DPopupRef, DPopupProps> = (props, re
294291
dVisible,
295292
dCallbackList: {
296293
beforeEnter: () => {
297-
dataRef.current.hasCancelLeave = false;
298294
updatePosition();
299295
setRendered(true);
300296
onRendered?.();
@@ -304,9 +300,6 @@ const Popup: React.ForwardRefRenderFunction<DPopupRef, DPopupProps> = (props, re
304300
beforeLeave: () => dataRef.current.transitionState,
305301
},
306302
afterEnter: () => {
307-
if (dataRef.current.hasCancelLeave && checkMouseLeave()) {
308-
changeVisible(false);
309-
}
310303
afterVisibleChange?.(true);
311304
},
312305
afterLeave: () => {
@@ -329,18 +322,6 @@ const Popup: React.ForwardRefRenderFunction<DPopupRef, DPopupProps> = (props, re
329322
}
330323
}, [dPrefix, dZIndex, hidden, isFixed, maxZIndex]);
331324

332-
// `onMouseEnter` and `onMouseLeave` trigger time is uncertain.
333-
// Very strange, sometimes popup element emit `onMouseEnter` before
334-
// trigger element emit `onMouseLeave`.
335-
// It's also no emit `onMouseEnter` when enter to popup element sometimes.
336-
const checkMouseLeave = useCallback(() => {
337-
if (popupEl && triggerEl) {
338-
return checkOutEl(popupEl) && checkOutEl(triggerEl);
339-
}
340-
341-
return false;
342-
}, [popupEl, triggerEl]);
343-
344325
const handleMouseEnter = useCallback(
345326
(e) => {
346327
onMouseEnter?.(e);
@@ -364,15 +345,11 @@ const Popup: React.ForwardRefRenderFunction<DPopupRef, DPopupProps> = (props, re
364345
dataRef.current.clearTid && dataRef.current.clearTid();
365346
dataRef.current.clearTid = asyncCapture.setTimeout(() => {
366347
dataRef.current.clearTid = null;
367-
if (checkMouseLeave()) {
368-
changeVisible(false);
369-
} else {
370-
dataRef.current.hasCancelLeave = true;
371-
}
348+
changeVisible(false);
372349
}, dMouseLeaveDelay);
373350
}
374351
},
375-
[onMouseLeave, dTrigger, asyncCapture, dMouseLeaveDelay, checkMouseLeave, changeVisible]
352+
[onMouseLeave, dTrigger, asyncCapture, dMouseLeaveDelay, changeVisible]
376353
);
377354

378355
const handleFocus = useCallback(
@@ -429,11 +406,7 @@ const Popup: React.ForwardRefRenderFunction<DPopupRef, DPopupProps> = (props, re
429406
dataRef.current.clearTid && dataRef.current.clearTid();
430407
dataRef.current.clearTid = asyncCapture.setTimeout(() => {
431408
dataRef.current.clearTid = null;
432-
if (checkMouseLeave()) {
433-
flushSync(() => changeVisible(false));
434-
} else {
435-
dataRef.current.hasCancelLeave = true;
436-
}
409+
flushSync(() => changeVisible(false));
437410
}, dMouseLeaveDelay);
438411
},
439412
});
@@ -467,7 +440,7 @@ const Popup: React.ForwardRefRenderFunction<DPopupRef, DPopupProps> = (props, re
467440
asyncCapture.deleteGroup(asyncId);
468441
};
469442
}
470-
}, [asyncCapture, checkMouseLeave, dMouseEnterDelay, dMouseLeaveDelay, dTrigger, dTriggerEl, changeVisible, triggerEl]);
443+
}, [asyncCapture, dMouseEnterDelay, dMouseLeaveDelay, dTrigger, dTriggerEl, changeVisible, triggerEl]);
471444

472445
useEffect(() => {
473446
const [asyncGroup, asyncId] = asyncCapture.createGroup();
@@ -566,12 +539,7 @@ const Popup: React.ForwardRefRenderFunction<DPopupRef, DPopupProps> = (props, re
566539
triggerRenderProps.onMouseLeave = () => {
567540
dataRef.current.clearTid && dataRef.current.clearTid();
568541
dataRef.current.clearTid = asyncCapture.setTimeout(() => {
569-
dataRef.current.clearTid = null;
570-
if (checkMouseLeave()) {
571-
changeVisible(false);
572-
} else {
573-
dataRef.current.hasCancelLeave = true;
574-
}
542+
changeVisible(false);
575543
}, dMouseLeaveDelay);
576544
};
577545
}
@@ -592,7 +560,7 @@ const Popup: React.ForwardRefRenderFunction<DPopupRef, DPopupProps> = (props, re
592560
}
593561

594562
return triggerRenderProps;
595-
}, [asyncCapture, checkMouseLeave, dMouseEnterDelay, dMouseLeaveDelay, dPrefix, dTrigger, uniqueId, changeVisible]);
563+
}, [asyncCapture, dMouseEnterDelay, dMouseLeaveDelay, dPrefix, dTrigger, uniqueId, changeVisible]);
596564

597565
return (
598566
<>

packages/ui/src/components/_popup/utils.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/ui/src/components/affix/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ group: Layout
33
title: Affix
44
---
55

6-
Pin the page nodes to the visible range.
7-
8-
## When To Use
9-
10-
Need more flexible `sticky` positioning.
11-
126
## API
137

148
### DAffixProps

packages/ui/src/components/affix/README.zh-Hant.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
title: 固钉
33
---
44

5-
将页面节点钉在可视范围。
6-
7-
## 何时使用
8-
9-
需要更灵活的 `sticky` 定位。
10-
115
## API
126

137
### DAffixProps

packages/ui/src/components/anchor/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ group: Navigation
33
title: Anchor
44
---
55

6-
Jump to the specified location on the page.
7-
8-
## When To Use
9-
10-
Need to show the anchor links available for jumping on the current page, and quickly jump between anchor points.
11-
126
## API
137

148
### DAnchorProps

packages/ui/src/components/anchor/README.zh-Hant.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
title: 锚点
33
---
44

5-
跳转到页面指定位置。
6-
7-
## 何时使用
8-
9-
需要展现当前页面上可供跳转的锚点链接,以及快速在锚点之间跳转。
10-
115
## API
126

137
### DAnchorProps

0 commit comments

Comments
 (0)