idea-react 2.0.0-rc.7 → 2.0.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReadMe.md +208 -206
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +47 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/eslint.config.ts +69 -0
- package/package.json +70 -53
- package/source/CodeBlock.tsx +1 -1
- package/source/Dialog.tsx +41 -41
- package/source/Editor.tsx +46 -46
- package/source/EditorHTML.tsx +21 -23
- package/source/HorizontalMarquee/index.module.less +52 -52
- package/source/HorizontalMarquee/index.tsx +67 -65
- package/source/Loading.tsx +21 -21
- package/source/MonthCalendar.tsx +1 -1
- package/source/PageNav.tsx +102 -102
- package/source/Select.tsx +84 -84
- package/source/ShareBox.tsx +99 -99
- package/source/TableSpinner.tsx +24 -24
- package/source/Time.tsx +14 -0
- package/source/TimeDistance.tsx +41 -41
- package/source/Timeline/index.module.less +53 -0
- package/source/Timeline/index.tsx +70 -0
- package/source/TypeEcho.tsx +49 -49
- package/source/UserRank/index.tsx +122 -120
- package/source/VerticalMarquee/index.module.less +43 -43
- package/source/VerticalMarquee/index.tsx +27 -26
- package/source/index.ts +25 -23
- package/tsconfig.build.json +11 -11
- package/tsconfig.json +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "idea-react",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.9",
|
|
4
4
|
"license": "LGPL-3.0-or-later",
|
|
5
5
|
"author": "shiy2008@gmail.com",
|
|
6
6
|
"description": "A React advanced components library based on TypeScript & Bootstrap, built by idea2app remote developers team.",
|
|
@@ -22,79 +22,93 @@
|
|
|
22
22
|
"types": "dist/index.d.ts",
|
|
23
23
|
"main": "dist/index.js",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@editorjs/editorjs": "^2.30.
|
|
26
|
-
"@editorjs/paragraph": "^2.11.
|
|
25
|
+
"@editorjs/editorjs": "^2.30.8",
|
|
26
|
+
"@editorjs/paragraph": "^2.11.7",
|
|
27
27
|
"@react-editor-js/core": "^2.1.0",
|
|
28
|
-
"@swc/helpers": "^0.5.
|
|
28
|
+
"@swc/helpers": "^0.5.15",
|
|
29
29
|
"classnames": "^2.5.1",
|
|
30
|
-
"editorjs-html": "^
|
|
30
|
+
"editorjs-html": "^4.0.5",
|
|
31
31
|
"html2canvas": "^1.4.1",
|
|
32
32
|
"iterable-observer": "^1.1.0",
|
|
33
33
|
"lodash": "^4.17.21",
|
|
34
|
-
"mobx": "
|
|
35
|
-
"mobx-react": "
|
|
34
|
+
"mobx": "^6.13.7",
|
|
35
|
+
"mobx-react": "^9.2.0",
|
|
36
36
|
"mobx-react-helper": "^0.3.1",
|
|
37
|
-
"prismjs": "^1.
|
|
38
|
-
"react-bootstrap": "^2.10.
|
|
37
|
+
"prismjs": "^1.30.0",
|
|
38
|
+
"react-bootstrap": "^2.10.9",
|
|
39
39
|
"react-editor-js": "^2.1.0",
|
|
40
40
|
"react-element-to-jsx-string": "^15.0.0",
|
|
41
|
-
"web-utility": "^4.4.
|
|
41
|
+
"web-utility": "^4.4.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=16",
|
|
45
45
|
"react-dom": ">=16"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@babel/plugin-proposal-decorators": "^7.25.
|
|
49
|
-
"@babel/preset-typescript": "^7.
|
|
50
|
-
"@eslint/compat": "^1.2.
|
|
51
|
-
"@eslint/js": "^9.
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"@parcel/
|
|
55
|
-
"@parcel/
|
|
56
|
-
"@parcel/
|
|
57
|
-
"@parcel/transformer-
|
|
58
|
-
"@
|
|
48
|
+
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
49
|
+
"@babel/preset-typescript": "^7.27.0",
|
|
50
|
+
"@eslint/compat": "^1.2.8",
|
|
51
|
+
"@eslint/js": "^9.24.0",
|
|
52
|
+
"@mdx-js/react": "^3.1.0",
|
|
53
|
+
"@microsoft/api-extractor": "^7.52.3",
|
|
54
|
+
"@parcel/config-default": "~2.14.4",
|
|
55
|
+
"@parcel/config-storybook": "^0.0.2",
|
|
56
|
+
"@parcel/packager-ts": "~2.14.4",
|
|
57
|
+
"@parcel/transformer-less": "~2.14.4",
|
|
58
|
+
"@parcel/transformer-mdx": "~2.13.3",
|
|
59
|
+
"@parcel/transformer-typescript-tsc": "~2.14.4",
|
|
60
|
+
"@parcel/transformer-typescript-types": "~2.14.4",
|
|
61
|
+
"@softonus/prettier-plugin-duplicate-remover": "^1.1.2",
|
|
59
62
|
"@storybook/addon-console": "^3.0.0",
|
|
60
|
-
"@storybook/addon-
|
|
61
|
-
"@storybook/addon-
|
|
62
|
-
"@storybook/addon-
|
|
63
|
-
"@storybook/addon-
|
|
64
|
-
"@storybook/
|
|
65
|
-
"@storybook/
|
|
66
|
-
"@storybook/react
|
|
67
|
-
"@storybook/
|
|
68
|
-
"@types/lodash": "^4.17.
|
|
69
|
-
"@types/node": "^
|
|
70
|
-
"@types/prismjs": "^1.26.
|
|
71
|
-
"@types/react": "^
|
|
72
|
-
"@types/react-dom": "^
|
|
73
|
-
"
|
|
74
|
-
"eslint": "^9.
|
|
75
|
-
"eslint-config-prettier": "^
|
|
76
|
-
"eslint-plugin-react": "^7.37.
|
|
63
|
+
"@storybook/addon-docs": "^8.6.12",
|
|
64
|
+
"@storybook/addon-essentials": "^8.6.12",
|
|
65
|
+
"@storybook/addon-interactions": "^8.6.12",
|
|
66
|
+
"@storybook/addon-links": "^8.6.12",
|
|
67
|
+
"@storybook/addon-storysource": "^8.6.12",
|
|
68
|
+
"@storybook/blocks": "^8.6.12",
|
|
69
|
+
"@storybook/react": "^8.6.12",
|
|
70
|
+
"@storybook/test": "^8.6.12",
|
|
71
|
+
"@types/lodash": "^4.17.16",
|
|
72
|
+
"@types/node": "^22.14.0",
|
|
73
|
+
"@types/prismjs": "^1.26.5",
|
|
74
|
+
"@types/react": "^19.1.0",
|
|
75
|
+
"@types/react-dom": "^19.1.2",
|
|
76
|
+
"buffer": "^6.0.3",
|
|
77
|
+
"eslint": "^9.24.0",
|
|
78
|
+
"eslint-config-prettier": "^10.1.2",
|
|
79
|
+
"eslint-plugin-react": "^7.37.5",
|
|
77
80
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
78
|
-
"globals": "^
|
|
79
|
-
"husky": "^9.1.
|
|
81
|
+
"globals": "^16.0.0",
|
|
82
|
+
"husky": "^9.1.7",
|
|
83
|
+
"jiti": "^2.4.2",
|
|
80
84
|
"koapache": "^2.2.2",
|
|
81
|
-
"less": "^4.
|
|
82
|
-
"lint-staged": "^15.
|
|
83
|
-
"parcel": "~2.
|
|
84
|
-
"postcss
|
|
85
|
-
"prettier": "^3.
|
|
85
|
+
"less": "^4.3.0",
|
|
86
|
+
"lint-staged": "^15.5.0",
|
|
87
|
+
"parcel": "~2.14.4",
|
|
88
|
+
"postcss": "^8.5.3",
|
|
89
|
+
"prettier": "^3.5.3",
|
|
86
90
|
"prettier-plugin-css-order": "^2.1.2",
|
|
87
91
|
"process": "^0.11.10",
|
|
88
92
|
"prop-types": "15.8.1",
|
|
89
|
-
"react": "^
|
|
90
|
-
"react-dom": "^
|
|
93
|
+
"react": "^19.1.0",
|
|
94
|
+
"react-dom": "^19.1.0",
|
|
95
|
+
"remark-gfm": "^4.0.1",
|
|
91
96
|
"rimraf": "^6.0.1",
|
|
92
|
-
"storybook": "^
|
|
93
|
-
"
|
|
94
|
-
"typedoc
|
|
95
|
-
"
|
|
96
|
-
"typescript
|
|
97
|
-
"
|
|
97
|
+
"storybook": "^8.6.12",
|
|
98
|
+
"storybook-react-parcel": "^0.0.1",
|
|
99
|
+
"typedoc": "^0.28.2",
|
|
100
|
+
"typedoc-plugin-mdn-links": "^5.0.1",
|
|
101
|
+
"typescript": "~5.8.3",
|
|
102
|
+
"typescript-eslint": "^8.29.1"
|
|
103
|
+
},
|
|
104
|
+
"pnpm": {
|
|
105
|
+
"onlyBuiltDependencies": [
|
|
106
|
+
"@parcel/watcher",
|
|
107
|
+
"@swc/core",
|
|
108
|
+
"esbuild",
|
|
109
|
+
"lmdb",
|
|
110
|
+
"msgpackr-extract"
|
|
111
|
+
]
|
|
98
112
|
},
|
|
99
113
|
"prettier": {
|
|
100
114
|
"singleQuote": true,
|
|
@@ -110,6 +124,9 @@
|
|
|
110
124
|
"*.{md,less,json,yml,js,mjs,ts,tsx}": "prettier --write",
|
|
111
125
|
"*.{js,ts,tsx}": "eslint --fix"
|
|
112
126
|
},
|
|
127
|
+
"@parcel/resolver-default": {
|
|
128
|
+
"packageExports": true
|
|
129
|
+
},
|
|
113
130
|
"browserslist": "> 0.5%, last 2 versions, not dead, IE 11",
|
|
114
131
|
"targets": {
|
|
115
132
|
"main": {
|
package/source/CodeBlock.tsx
CHANGED
package/source/Dialog.tsx
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { Defer } from 'iterable-observer';
|
|
2
|
-
import { observable } from 'mobx';
|
|
3
|
-
import { observer } from 'mobx-react';
|
|
4
|
-
import { FC } from 'react';
|
|
5
|
-
|
|
6
|
-
export class DialogClose extends Error {
|
|
7
|
-
constructor(message = 'Dialog closed') {
|
|
8
|
-
super(message);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface DialogProps<T = any> {
|
|
13
|
-
defer?: Defer<T>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class Dialog<I extends object = {}, O = any> {
|
|
17
|
-
@observable
|
|
18
|
-
accessor input = {} as I;
|
|
19
|
-
|
|
20
|
-
@observable
|
|
21
|
-
accessor defer: Defer<O> | undefined;
|
|
22
|
-
|
|
23
|
-
Component: FC<I>;
|
|
24
|
-
|
|
25
|
-
constructor(Factory: FC<I & DialogProps<O>>) {
|
|
26
|
-
this.Component = observer(props => (
|
|
27
|
-
<Factory {...props} {...this.input} defer={this.defer} />
|
|
28
|
-
));
|
|
29
|
-
this.Component.displayName = 'DialogComponent';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
open(input?: I) {
|
|
33
|
-
if (input) this.input = input;
|
|
34
|
-
|
|
35
|
-
this.defer = new Defer();
|
|
36
|
-
|
|
37
|
-
this.defer.promise.finally(() => (this.defer = undefined));
|
|
38
|
-
|
|
39
|
-
return this.defer.promise;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
import { Defer } from 'iterable-observer';
|
|
2
|
+
import { observable } from 'mobx';
|
|
3
|
+
import { observer } from 'mobx-react';
|
|
4
|
+
import { FC } from 'react';
|
|
5
|
+
|
|
6
|
+
export class DialogClose extends Error {
|
|
7
|
+
constructor(message = 'Dialog closed') {
|
|
8
|
+
super(message);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DialogProps<T = any> {
|
|
13
|
+
defer?: Defer<T>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class Dialog<I extends object = {}, O = any> {
|
|
17
|
+
@observable
|
|
18
|
+
accessor input = {} as I;
|
|
19
|
+
|
|
20
|
+
@observable
|
|
21
|
+
accessor defer: Defer<O> | undefined;
|
|
22
|
+
|
|
23
|
+
Component: FC<I>;
|
|
24
|
+
|
|
25
|
+
constructor(Factory: FC<I & DialogProps<O>>) {
|
|
26
|
+
this.Component = observer(props => (
|
|
27
|
+
<Factory {...props} {...this.input} defer={this.defer} />
|
|
28
|
+
));
|
|
29
|
+
this.Component.displayName = 'DialogComponent';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
open(input?: I) {
|
|
33
|
+
if (input) this.input = input;
|
|
34
|
+
|
|
35
|
+
this.defer = new Defer();
|
|
36
|
+
|
|
37
|
+
this.defer.promise.finally(() => (this.defer = undefined));
|
|
38
|
+
|
|
39
|
+
return this.defer.promise;
|
|
40
|
+
}
|
|
41
|
+
}
|
package/source/Editor.tsx
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { EditorCore, WrapperProps } from '@react-editor-js/core';
|
|
2
|
-
import { observable } from 'mobx';
|
|
3
|
-
import { observer } from 'mobx-react';
|
|
4
|
-
import { Component, InputHTMLAttributes, PropsWithoutRef } from 'react';
|
|
5
|
-
import { createReactEditorJS } from 'react-editor-js';
|
|
6
|
-
|
|
7
|
-
const ReactEditorJS = createReactEditorJS();
|
|
8
|
-
|
|
9
|
-
export type EditorProps = PropsWithoutRef<
|
|
10
|
-
WrapperProps &
|
|
11
|
-
Pick<InputHTMLAttributes<HTMLInputElement>, 'name' | 'required'>
|
|
12
|
-
>;
|
|
13
|
-
|
|
14
|
-
@observer
|
|
15
|
-
export class Editor extends Component<EditorProps> {
|
|
16
|
-
static displayName = 'Editor';
|
|
17
|
-
|
|
18
|
-
private core?: EditorCore;
|
|
19
|
-
|
|
20
|
-
@observable
|
|
21
|
-
accessor innerValue = this.props.defaultValue;
|
|
22
|
-
|
|
23
|
-
save = async () => this.core && (this.innerValue = await this.core.save());
|
|
24
|
-
|
|
25
|
-
render() {
|
|
26
|
-
const { name, required, children, ...editorProps } = this.props,
|
|
27
|
-
{ innerValue } = this;
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<div className="form-control" tabIndex={-1} onBlur={this.save}>
|
|
31
|
-
<input
|
|
32
|
-
hidden
|
|
33
|
-
{...{ name, required }}
|
|
34
|
-
value={JSON.stringify(innerValue)}
|
|
35
|
-
/>
|
|
36
|
-
<ReactEditorJS
|
|
37
|
-
{...editorProps}
|
|
38
|
-
onInitialize={core => {
|
|
39
|
-
this.core = core;
|
|
40
|
-
editorProps.onInitialize?.(core);
|
|
41
|
-
}}
|
|
42
|
-
/>
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
import { EditorCore, WrapperProps } from '@react-editor-js/core';
|
|
2
|
+
import { observable } from 'mobx';
|
|
3
|
+
import { observer } from 'mobx-react';
|
|
4
|
+
import { Component, InputHTMLAttributes, PropsWithoutRef } from 'react';
|
|
5
|
+
import { createReactEditorJS } from 'react-editor-js';
|
|
6
|
+
|
|
7
|
+
const ReactEditorJS = createReactEditorJS();
|
|
8
|
+
|
|
9
|
+
export type EditorProps = PropsWithoutRef<
|
|
10
|
+
WrapperProps &
|
|
11
|
+
Pick<InputHTMLAttributes<HTMLInputElement>, 'name' | 'required'>
|
|
12
|
+
>;
|
|
13
|
+
|
|
14
|
+
@observer
|
|
15
|
+
export class Editor extends Component<EditorProps> {
|
|
16
|
+
static displayName = 'Editor';
|
|
17
|
+
|
|
18
|
+
private core?: EditorCore;
|
|
19
|
+
|
|
20
|
+
@observable
|
|
21
|
+
accessor innerValue = this.props.defaultValue;
|
|
22
|
+
|
|
23
|
+
save = async () => this.core && (this.innerValue = await this.core.save());
|
|
24
|
+
|
|
25
|
+
render() {
|
|
26
|
+
const { name, required, children, ...editorProps } = this.props,
|
|
27
|
+
{ innerValue } = this;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="form-control" tabIndex={-1} onBlur={this.save}>
|
|
31
|
+
<input
|
|
32
|
+
hidden
|
|
33
|
+
{...{ name, required }}
|
|
34
|
+
value={JSON.stringify(innerValue)}
|
|
35
|
+
/>
|
|
36
|
+
<ReactEditorJS
|
|
37
|
+
{...editorProps}
|
|
38
|
+
onInitialize={core => {
|
|
39
|
+
this.core = core;
|
|
40
|
+
editorProps.onInitialize?.(core);
|
|
41
|
+
}}
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
package/source/EditorHTML.tsx
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import { OutputData } from '@editorjs/editorjs';
|
|
2
|
-
import createParser from 'editorjs-html';
|
|
3
|
-
import { FC, PropsWithoutRef } from 'react';
|
|
4
|
-
|
|
5
|
-
export const parser = createParser({
|
|
6
|
-
link: ({ data: { link } }: Record<string, any>) =>
|
|
7
|
-
`<a href="${link}">${link}</a>`
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
export type EditorHTMLProps = PropsWithoutRef<{
|
|
11
|
-
className?: string;
|
|
12
|
-
data: OutputData;
|
|
13
|
-
}>;
|
|
14
|
-
|
|
15
|
-
export const EditorHTML: FC<EditorHTMLProps> = ({ className, data }) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
EditorHTML.displayName = 'EditorHTML';
|
|
1
|
+
import { OutputData } from '@editorjs/editorjs';
|
|
2
|
+
import createParser from 'editorjs-html';
|
|
3
|
+
import { FC, PropsWithoutRef } from 'react';
|
|
4
|
+
|
|
5
|
+
export const parser = createParser({
|
|
6
|
+
link: ({ data: { link } }: Record<string, any>) =>
|
|
7
|
+
`<a href="${link}">${link}</a>`
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export type EditorHTMLProps = PropsWithoutRef<{
|
|
11
|
+
className?: string;
|
|
12
|
+
data: OutputData;
|
|
13
|
+
}>;
|
|
14
|
+
|
|
15
|
+
export const EditorHTML: FC<EditorHTMLProps> = ({ className, data }) => (
|
|
16
|
+
<article
|
|
17
|
+
dangerouslySetInnerHTML={{ __html: parser.parse(data) }}
|
|
18
|
+
className={className}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
EditorHTML.displayName = 'EditorHTML';
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
@keyframes scrollItem {
|
|
2
|
-
0%,
|
|
3
|
-
10% {
|
|
4
|
-
transform: translateX(0);
|
|
5
|
-
}
|
|
6
|
-
90%,
|
|
7
|
-
100% {
|
|
8
|
-
transform: translateX(-100%);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
@keyframes scrollWrap {
|
|
12
|
-
0%,
|
|
13
|
-
10% {
|
|
14
|
-
transform: translateX(0);
|
|
15
|
-
}
|
|
16
|
-
90%,
|
|
17
|
-
100% {
|
|
18
|
-
transform: translateX(100%);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.scrollWrap {
|
|
23
|
-
animation: scrollWrap linear 4s alternate infinite;
|
|
24
|
-
.scrollItem {
|
|
25
|
-
animation: scrollItem linear 4s alternate infinite;
|
|
26
|
-
}
|
|
27
|
-
&:hover {
|
|
28
|
-
animation-play-state: paused;
|
|
29
|
-
.scrollItem {
|
|
30
|
-
animation-play-state: paused;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.scrollHeightWrap {
|
|
36
|
-
--scroll-height: 20px;
|
|
37
|
-
height: var(--scroll-height);
|
|
38
|
-
.scrollContainer {
|
|
39
|
-
transform: translateY(
|
|
40
|
-
calc(calc(-100% + var(--scroll-height) + var(--scroll-height)) * 2)
|
|
41
|
-
);
|
|
42
|
-
max-height: calc(var(--scroll-height) * 3);
|
|
43
|
-
.unScrollItem {
|
|
44
|
-
max-height: calc(var(--scroll-height) * 2);
|
|
45
|
-
line-height: var(--scroll-height);
|
|
46
|
-
}
|
|
47
|
-
.scrollItem {
|
|
48
|
-
height: var(--scroll-height);
|
|
49
|
-
line-height: var(--scroll-height);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
1
|
+
@keyframes scrollItem {
|
|
2
|
+
0%,
|
|
3
|
+
10% {
|
|
4
|
+
transform: translateX(0);
|
|
5
|
+
}
|
|
6
|
+
90%,
|
|
7
|
+
100% {
|
|
8
|
+
transform: translateX(-100%);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
@keyframes scrollWrap {
|
|
12
|
+
0%,
|
|
13
|
+
10% {
|
|
14
|
+
transform: translateX(0);
|
|
15
|
+
}
|
|
16
|
+
90%,
|
|
17
|
+
100% {
|
|
18
|
+
transform: translateX(100%);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.scrollWrap {
|
|
23
|
+
animation: scrollWrap linear 4s alternate infinite;
|
|
24
|
+
.scrollItem {
|
|
25
|
+
animation: scrollItem linear 4s alternate infinite;
|
|
26
|
+
}
|
|
27
|
+
&:hover {
|
|
28
|
+
animation-play-state: paused;
|
|
29
|
+
.scrollItem {
|
|
30
|
+
animation-play-state: paused;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.scrollHeightWrap {
|
|
36
|
+
--scroll-height: 20px;
|
|
37
|
+
height: var(--scroll-height);
|
|
38
|
+
.scrollContainer {
|
|
39
|
+
transform: translateY(
|
|
40
|
+
calc(calc(-100% + var(--scroll-height) + var(--scroll-height)) * 2)
|
|
41
|
+
);
|
|
42
|
+
max-height: calc(var(--scroll-height) * 3);
|
|
43
|
+
.unScrollItem {
|
|
44
|
+
max-height: calc(var(--scroll-height) * 2);
|
|
45
|
+
line-height: var(--scroll-height);
|
|
46
|
+
}
|
|
47
|
+
.scrollItem {
|
|
48
|
+
height: var(--scroll-height);
|
|
49
|
+
line-height: var(--scroll-height);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,65 +1,67 @@
|
|
|
1
|
-
import { FC, HTMLAttributes } from 'react';
|
|
2
|
-
|
|
3
|
-
import * as style from './index.module.less';
|
|
4
|
-
|
|
5
|
-
export type HorizontalMarqueeProps = HTMLAttributes<HTMLDivElement> &
|
|
6
|
-
Partial<Record<'maxWidth' | 'duration' | 'height', string>>;
|
|
7
|
-
|
|
8
|
-
export const HorizontalMarquee: FC<HorizontalMarqueeProps> = ({
|
|
9
|
-
className = '',
|
|
10
|
-
children,
|
|
11
|
-
maxWidth = '100%',
|
|
12
|
-
duration,
|
|
13
|
-
height,
|
|
14
|
-
...props
|
|
15
|
-
}) => (
|
|
16
|
-
<div className={`overflow-hidden mw-100 ${className}`} {...props}>
|
|
17
|
-
<div
|
|
18
|
-
className={`d-inline-block align-top text-nowrap ${style.scrollWrap}`}
|
|
19
|
-
style={{
|
|
20
|
-
maxWidth,
|
|
21
|
-
animationDuration: duration,
|
|
22
|
-
height,
|
|
23
|
-
lineHeight: height
|
|
24
|
-
}}
|
|
25
|
-
>
|
|
26
|
-
<div
|
|
27
|
-
className={`d-inline-block ${style.scrollItem}`}
|
|
28
|
-
style={{ animationDuration: duration }}
|
|
29
|
-
>
|
|
30
|
-
{children}
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
export const HorizontalMarqueeBox: FC<HorizontalMarqueeProps> = ({
|
|
37
|
-
children,
|
|
38
|
-
maxWidth,
|
|
39
|
-
duration,
|
|
40
|
-
height
|
|
41
|
-
}) =>
|
|
42
|
-
height ? (
|
|
43
|
-
<div
|
|
44
|
-
className={`overflow-hidden ${style.scrollHeightWrap}`}
|
|
45
|
-
// @ts-expect-error remove after React 19 released
|
|
46
|
-
style={{ maxWidth: maxWidth, '--scroll-height': height }}
|
|
47
|
-
>
|
|
48
|
-
<div
|
|
49
|
-
className={`d-inline-block overflow-hidden mw-100 ${style.scrollContainer}`}
|
|
50
|
-
>
|
|
51
|
-
<div
|
|
52
|
-
className={`d-block overflow-hidden text-wrap text-break ${style.unScrollItem}`}
|
|
53
|
-
>
|
|
54
|
-
{children}
|
|
55
|
-
</div>
|
|
56
|
-
<HorizontalMarquee duration={duration}>
|
|
57
|
-
{children}
|
|
58
|
-
</HorizontalMarquee>
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
) : (
|
|
62
|
-
<HorizontalMarquee {...{ maxWidth, duration, height }}>
|
|
63
|
-
{children}
|
|
64
|
-
</HorizontalMarquee>
|
|
65
|
-
);
|
|
1
|
+
import { FC, HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
import * as style from './index.module.less';
|
|
4
|
+
|
|
5
|
+
export type HorizontalMarqueeProps = HTMLAttributes<HTMLDivElement> &
|
|
6
|
+
Partial<Record<'maxWidth' | 'duration' | 'height', string>>;
|
|
7
|
+
|
|
8
|
+
export const HorizontalMarquee: FC<HorizontalMarqueeProps> = ({
|
|
9
|
+
className = '',
|
|
10
|
+
children,
|
|
11
|
+
maxWidth = '100%',
|
|
12
|
+
duration,
|
|
13
|
+
height,
|
|
14
|
+
...props
|
|
15
|
+
}) => (
|
|
16
|
+
<div className={`overflow-hidden mw-100 ${className}`} {...props}>
|
|
17
|
+
<div
|
|
18
|
+
className={`d-inline-block align-top text-nowrap ${style.scrollWrap}`}
|
|
19
|
+
style={{
|
|
20
|
+
maxWidth,
|
|
21
|
+
animationDuration: duration,
|
|
22
|
+
height,
|
|
23
|
+
lineHeight: height
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
<div
|
|
27
|
+
className={`d-inline-block ${style.scrollItem}`}
|
|
28
|
+
style={{ animationDuration: duration }}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export const HorizontalMarqueeBox: FC<HorizontalMarqueeProps> = ({
|
|
37
|
+
children,
|
|
38
|
+
maxWidth,
|
|
39
|
+
duration,
|
|
40
|
+
height
|
|
41
|
+
}) =>
|
|
42
|
+
height ? (
|
|
43
|
+
<div
|
|
44
|
+
className={`overflow-hidden ${style.scrollHeightWrap}`}
|
|
45
|
+
// @ts-expect-error remove after React 19 released
|
|
46
|
+
style={{ maxWidth: maxWidth, '--scroll-height': height }}
|
|
47
|
+
>
|
|
48
|
+
<div
|
|
49
|
+
className={`d-inline-block overflow-hidden mw-100 ${style.scrollContainer}`}
|
|
50
|
+
>
|
|
51
|
+
<div
|
|
52
|
+
className={`d-block overflow-hidden text-wrap text-break ${style.unScrollItem}`}
|
|
53
|
+
>
|
|
54
|
+
{children}
|
|
55
|
+
</div>
|
|
56
|
+
<HorizontalMarquee duration={duration}>
|
|
57
|
+
{children}
|
|
58
|
+
</HorizontalMarquee>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
) : (
|
|
62
|
+
<HorizontalMarquee {...{ maxWidth, duration, height }}>
|
|
63
|
+
{children}
|
|
64
|
+
</HorizontalMarquee>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
HorizontalMarquee.displayName = 'HorizontalMarquee';
|