@alfalab/core-components-page-indicator 1.0.0
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/Component.d.ts +5 -0
- package/Component.js +15 -0
- package/components/bullet/Component.d.ts +4 -0
- package/components/bullet/Component.js +64 -0
- package/components/bullet/default.css +41 -0
- package/components/bullet/index.css +64 -0
- package/components/bullet/index.d.ts +1 -0
- package/components/bullet/index.js +9 -0
- package/components/bullet/inverted.css +41 -0
- package/components/bullet/static-inverted.css +41 -0
- package/components/bullet/static.css +41 -0
- package/components/bullet/utils/index.d.ts +1 -0
- package/components/bullet/utils/index.js +9 -0
- package/components/bullet/utils/utils.d.ts +9 -0
- package/components/bullet/utils/utils.js +120 -0
- package/components/dynamic/Component.d.ts +5 -0
- package/components/dynamic/Component.js +93 -0
- package/components/dynamic/default.css +43 -0
- package/components/dynamic/index.css +53 -0
- package/components/dynamic/index.d.ts +1 -0
- package/components/dynamic/index.js +9 -0
- package/components/dynamic/inverted.css +43 -0
- package/components/dynamic/static-inverted.css +43 -0
- package/components/dynamic/static.css +43 -0
- package/components/runner/Component.d.ts +5 -0
- package/components/runner/Component.js +45 -0
- package/components/runner/default.css +41 -0
- package/components/runner/index.css +37 -0
- package/components/runner/index.d.ts +1 -0
- package/components/runner/index.js +9 -0
- package/components/runner/inverted.css +41 -0
- package/components/runner/static-inverted.css +41 -0
- package/components/runner/static.css +41 -0
- package/components/step/Component.d.ts +5 -0
- package/components/step/Component.js +44 -0
- package/components/step/default.css +41 -0
- package/components/step/index.css +44 -0
- package/components/step/index.d.ts +1 -0
- package/components/step/index.js +9 -0
- package/components/step/inverted.css +41 -0
- package/components/step/static-inverted.css +41 -0
- package/components/step/static.css +41 -0
- package/cssm/Component.d.ts +5 -0
- package/cssm/Component.js +15 -0
- package/cssm/components/bullet/Component.d.ts +4 -0
- package/cssm/components/bullet/Component.js +59 -0
- package/cssm/components/bullet/default.module.css +40 -0
- package/cssm/components/bullet/index.d.ts +1 -0
- package/cssm/components/bullet/index.js +9 -0
- package/cssm/components/bullet/index.module.css +63 -0
- package/cssm/components/bullet/inverted.module.css +40 -0
- package/cssm/components/bullet/static-inverted.module.css +40 -0
- package/cssm/components/bullet/static.module.css +40 -0
- package/cssm/components/bullet/utils/index.d.ts +1 -0
- package/cssm/components/bullet/utils/index.js +9 -0
- package/cssm/components/bullet/utils/utils.d.ts +9 -0
- package/cssm/components/bullet/utils/utils.js +120 -0
- package/cssm/components/dynamic/Component.d.ts +5 -0
- package/cssm/components/dynamic/Component.js +88 -0
- package/cssm/components/dynamic/default.module.css +42 -0
- package/cssm/components/dynamic/index.d.ts +1 -0
- package/cssm/components/dynamic/index.js +9 -0
- package/cssm/components/dynamic/index.module.css +52 -0
- package/cssm/components/dynamic/inverted.module.css +42 -0
- package/cssm/components/dynamic/static-inverted.module.css +42 -0
- package/cssm/components/dynamic/static.module.css +42 -0
- package/cssm/components/runner/Component.d.ts +5 -0
- package/cssm/components/runner/Component.js +40 -0
- package/cssm/components/runner/default.module.css +40 -0
- package/cssm/components/runner/index.d.ts +1 -0
- package/cssm/components/runner/index.js +9 -0
- package/cssm/components/runner/index.module.css +36 -0
- package/cssm/components/runner/inverted.module.css +40 -0
- package/cssm/components/runner/static-inverted.module.css +40 -0
- package/cssm/components/runner/static.module.css +40 -0
- package/cssm/components/step/Component.d.ts +5 -0
- package/cssm/components/step/Component.js +39 -0
- package/cssm/components/step/default.module.css +40 -0
- package/cssm/components/step/index.d.ts +1 -0
- package/cssm/components/step/index.js +9 -0
- package/cssm/components/step/index.module.css +43 -0
- package/cssm/components/step/inverted.module.css +40 -0
- package/cssm/components/step/static-inverted.module.css +40 -0
- package/cssm/components/step/static.module.css +40 -0
- package/cssm/index.d.ts +1 -0
- package/cssm/index.js +15 -0
- package/cssm/types.d.ts +129 -0
- package/cssm/types.js +2 -0
- package/cssm/vars.css +32 -0
- package/esm/Component.d.ts +5 -0
- package/esm/Component.js +4 -0
- package/esm/components/bullet/Component.d.ts +4 -0
- package/esm/components/bullet/Component.js +55 -0
- package/esm/components/bullet/default.css +41 -0
- package/esm/components/bullet/index.css +64 -0
- package/esm/components/bullet/index.d.ts +1 -0
- package/esm/components/bullet/index.js +1 -0
- package/esm/components/bullet/inverted.css +41 -0
- package/esm/components/bullet/static-inverted.css +41 -0
- package/esm/components/bullet/static.css +41 -0
- package/esm/components/bullet/utils/index.d.ts +1 -0
- package/esm/components/bullet/utils/index.js +1 -0
- package/esm/components/bullet/utils/utils.d.ts +9 -0
- package/esm/components/bullet/utils/utils.js +116 -0
- package/esm/components/dynamic/Component.d.ts +5 -0
- package/esm/components/dynamic/Component.js +84 -0
- package/esm/components/dynamic/default.css +43 -0
- package/esm/components/dynamic/index.css +53 -0
- package/esm/components/dynamic/index.d.ts +1 -0
- package/esm/components/dynamic/index.js +1 -0
- package/esm/components/dynamic/inverted.css +43 -0
- package/esm/components/dynamic/static-inverted.css +43 -0
- package/esm/components/dynamic/static.css +43 -0
- package/esm/components/runner/Component.d.ts +5 -0
- package/esm/components/runner/Component.js +36 -0
- package/esm/components/runner/default.css +41 -0
- package/esm/components/runner/index.css +37 -0
- package/esm/components/runner/index.d.ts +1 -0
- package/esm/components/runner/index.js +1 -0
- package/esm/components/runner/inverted.css +41 -0
- package/esm/components/runner/static-inverted.css +41 -0
- package/esm/components/runner/static.css +41 -0
- package/esm/components/step/Component.d.ts +5 -0
- package/esm/components/step/Component.js +35 -0
- package/esm/components/step/default.css +41 -0
- package/esm/components/step/index.css +44 -0
- package/esm/components/step/index.d.ts +1 -0
- package/esm/components/step/index.js +1 -0
- package/esm/components/step/inverted.css +41 -0
- package/esm/components/step/static-inverted.css +41 -0
- package/esm/components/step/static.css +41 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +4 -0
- package/esm/types.d.ts +129 -0
- package/esm/types.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +15 -0
- package/modern/Component.d.ts +5 -0
- package/modern/Component.js +4 -0
- package/modern/components/bullet/Component.d.ts +4 -0
- package/modern/components/bullet/Component.js +50 -0
- package/modern/components/bullet/default.css +41 -0
- package/modern/components/bullet/index.css +64 -0
- package/modern/components/bullet/index.d.ts +1 -0
- package/modern/components/bullet/index.js +1 -0
- package/modern/components/bullet/inverted.css +41 -0
- package/modern/components/bullet/static-inverted.css +41 -0
- package/modern/components/bullet/static.css +41 -0
- package/modern/components/bullet/utils/index.d.ts +1 -0
- package/modern/components/bullet/utils/index.js +1 -0
- package/modern/components/bullet/utils/utils.d.ts +9 -0
- package/modern/components/bullet/utils/utils.js +114 -0
- package/modern/components/dynamic/Component.d.ts +5 -0
- package/modern/components/dynamic/Component.js +83 -0
- package/modern/components/dynamic/default.css +43 -0
- package/modern/components/dynamic/index.css +53 -0
- package/modern/components/dynamic/index.d.ts +1 -0
- package/modern/components/dynamic/index.js +1 -0
- package/modern/components/dynamic/inverted.css +43 -0
- package/modern/components/dynamic/static-inverted.css +43 -0
- package/modern/components/dynamic/static.css +43 -0
- package/modern/components/runner/Component.d.ts +5 -0
- package/modern/components/runner/Component.js +33 -0
- package/modern/components/runner/default.css +41 -0
- package/modern/components/runner/index.css +37 -0
- package/modern/components/runner/index.d.ts +1 -0
- package/modern/components/runner/index.js +1 -0
- package/modern/components/runner/inverted.css +41 -0
- package/modern/components/runner/static-inverted.css +41 -0
- package/modern/components/runner/static.css +41 -0
- package/modern/components/step/Component.d.ts +5 -0
- package/modern/components/step/Component.js +29 -0
- package/modern/components/step/default.css +41 -0
- package/modern/components/step/index.css +44 -0
- package/modern/components/step/index.d.ts +1 -0
- package/modern/components/step/index.js +1 -0
- package/modern/components/step/inverted.css +41 -0
- package/modern/components/step/static-inverted.css +41 -0
- package/modern/components/step/static.css +41 -0
- package/modern/index.d.ts +1 -0
- package/modern/index.js +4 -0
- package/modern/types.d.ts +129 -0
- package/modern/types.js +1 -0
- package/moderncssm/Component.d.ts +5 -0
- package/moderncssm/Component.js +4 -0
- package/moderncssm/components/bullet/Component.d.ts +4 -0
- package/moderncssm/components/bullet/Component.js +40 -0
- package/moderncssm/components/bullet/default.module.css +22 -0
- package/moderncssm/components/bullet/index.d.ts +1 -0
- package/moderncssm/components/bullet/index.js +1 -0
- package/moderncssm/components/bullet/index.module.css +56 -0
- package/moderncssm/components/bullet/inverted.module.css +22 -0
- package/moderncssm/components/bullet/static-inverted.module.css +22 -0
- package/moderncssm/components/bullet/static.module.css +22 -0
- package/moderncssm/components/bullet/utils/index.d.ts +1 -0
- package/moderncssm/components/bullet/utils/index.js +1 -0
- package/moderncssm/components/bullet/utils/utils.d.ts +9 -0
- package/moderncssm/components/bullet/utils/utils.js +114 -0
- package/moderncssm/components/dynamic/Component.d.ts +5 -0
- package/moderncssm/components/dynamic/Component.js +73 -0
- package/moderncssm/components/dynamic/default.module.css +24 -0
- package/moderncssm/components/dynamic/index.d.ts +1 -0
- package/moderncssm/components/dynamic/index.js +1 -0
- package/moderncssm/components/dynamic/index.module.css +40 -0
- package/moderncssm/components/dynamic/inverted.module.css +24 -0
- package/moderncssm/components/dynamic/static-inverted.module.css +24 -0
- package/moderncssm/components/dynamic/static.module.css +24 -0
- package/moderncssm/components/runner/Component.d.ts +5 -0
- package/moderncssm/components/runner/Component.js +23 -0
- package/moderncssm/components/runner/default.module.css +22 -0
- package/moderncssm/components/runner/index.d.ts +1 -0
- package/moderncssm/components/runner/index.js +1 -0
- package/moderncssm/components/runner/index.module.css +18 -0
- package/moderncssm/components/runner/inverted.module.css +22 -0
- package/moderncssm/components/runner/static-inverted.module.css +22 -0
- package/moderncssm/components/runner/static.module.css +22 -0
- package/moderncssm/components/step/Component.d.ts +5 -0
- package/moderncssm/components/step/Component.js +19 -0
- package/moderncssm/components/step/default.module.css +22 -0
- package/moderncssm/components/step/index.d.ts +1 -0
- package/moderncssm/components/step/index.js +1 -0
- package/moderncssm/components/step/index.module.css +27 -0
- package/moderncssm/components/step/inverted.module.css +22 -0
- package/moderncssm/components/step/static-inverted.module.css +22 -0
- package/moderncssm/components/step/static.module.css +22 -0
- package/moderncssm/index.d.ts +1 -0
- package/moderncssm/index.js +4 -0
- package/moderncssm/types.d.ts +129 -0
- package/moderncssm/types.js +1 -0
- package/moderncssm/vars.css +12 -0
- package/package.json +28 -0
- package/src/Component.tsx +6 -0
- package/src/components/bullet/Component.tsx +84 -0
- package/src/components/bullet/default.module.css +9 -0
- package/src/components/bullet/index.module.css +42 -0
- package/src/components/bullet/index.ts +1 -0
- package/src/components/bullet/inverted.module.css +9 -0
- package/src/components/bullet/static-inverted.module.css +9 -0
- package/src/components/bullet/static.module.css +9 -0
- package/src/components/bullet/utils/index.ts +1 -0
- package/src/components/bullet/utils/utils.ts +153 -0
- package/src/components/dynamic/Component.tsx +126 -0
- package/src/components/dynamic/default.module.css +11 -0
- package/src/components/dynamic/index.module.css +25 -0
- package/src/components/dynamic/index.ts +1 -0
- package/src/components/dynamic/inverted.module.css +11 -0
- package/src/components/dynamic/static-inverted.module.css +11 -0
- package/src/components/dynamic/static.module.css +11 -0
- package/src/components/runner/Component.tsx +39 -0
- package/src/components/runner/default.module.css +9 -0
- package/src/components/runner/index.module.css +6 -0
- package/src/components/runner/index.ts +1 -0
- package/src/components/runner/inverted.module.css +9 -0
- package/src/components/runner/static-inverted.module.css +9 -0
- package/src/components/runner/static.module.css +9 -0
- package/src/components/step/Component.tsx +37 -0
- package/src/components/step/default.module.css +9 -0
- package/src/components/step/index.module.css +14 -0
- package/src/components/step/index.ts +1 -0
- package/src/components/step/inverted.module.css +9 -0
- package/src/components/step/static-inverted.module.css +9 -0
- package/src/components/step/static.module.css +9 -0
- package/src/index.ts +1 -0
- package/src/types.ts +131 -0
- package/src/vars.css +22 -0
- package/types.d.ts +129 -0
- package/types.js +2 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
|
|
5
|
+
/* default */
|
|
6
|
+
|
|
7
|
+
/* inverted */
|
|
8
|
+
|
|
9
|
+
/* static */
|
|
10
|
+
|
|
11
|
+
/* static-inverted */
|
|
12
|
+
--page-indicator-color-static-inverted: var(--color-static-neutral-translucent-300-inverted);
|
|
13
|
+
--page-indicator-active-color-static-inverted: var(--color-static-neutral-1300-inverted);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.pageIndicator {
|
|
17
|
+
background: var(--page-indicator-color-static-inverted);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.element {
|
|
21
|
+
background: var(--page-indicator-active-color-static-inverted);
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
|
|
5
|
+
/* default */
|
|
6
|
+
|
|
7
|
+
/* inverted */
|
|
8
|
+
|
|
9
|
+
/* static */
|
|
10
|
+
--page-indicator-color-static: var(--color-static-neutral-translucent-300);
|
|
11
|
+
--page-indicator-active-color-static: var(--color-static-neutral-1300);
|
|
12
|
+
|
|
13
|
+
/* static-inverted */
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.pageIndicator {
|
|
17
|
+
background: var(--page-indicator-color-static);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.element {
|
|
21
|
+
background: var(--page-indicator-active-color-static);
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import defaultColors from './default.module.css';
|
|
4
|
+
import styles from './index.module.css';
|
|
5
|
+
import invertedColors from './inverted.module.css';
|
|
6
|
+
import staticColors from './static.module.css';
|
|
7
|
+
import staticInvertedColors from './static-inverted.module.css';
|
|
8
|
+
|
|
9
|
+
const colorsStyle = {
|
|
10
|
+
inverted: invertedColors,
|
|
11
|
+
default: defaultColors,
|
|
12
|
+
static: staticColors,
|
|
13
|
+
'static-inverted': staticInvertedColors,
|
|
14
|
+
};
|
|
15
|
+
const PageIndicatorStep = ({ activeElement, elements: count = 10, size = 4, gap = 4, colors = 'default', }) => (React.createElement("ol", { className: styles.pageIndicator, style: { height: size, gap } }, Array.from({ length: count }, (_, index) => (React.createElement("li", { key: index, style: { height: size, borderRadius: size / 2 }, className: cn(styles.element, colorsStyle[colors].element, {
|
|
16
|
+
[colorsStyle[colors].active]: index === activeElement,
|
|
17
|
+
}) })))));
|
|
18
|
+
|
|
19
|
+
export { PageIndicatorStep };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
|
|
5
|
+
/* default */
|
|
6
|
+
--page-indicator-color: var(--color-light-neutral-translucent-300);
|
|
7
|
+
--page-indicator-active-color: var(--color-light-neutral-translucent-1300);
|
|
8
|
+
|
|
9
|
+
/* inverted */
|
|
10
|
+
|
|
11
|
+
/* static */
|
|
12
|
+
|
|
13
|
+
/* static-inverted */
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.element {
|
|
17
|
+
background: var(--page-indicator-color)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.element.active {
|
|
21
|
+
background: var(--page-indicator-active-color);
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PageIndicatorStep } from './Component.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
--page-indicator-animation-duration: 0.2s;
|
|
5
|
+
--page-indicator-animation-timing-function: ease-in-out;
|
|
6
|
+
|
|
7
|
+
/* default */
|
|
8
|
+
|
|
9
|
+
/* inverted */
|
|
10
|
+
|
|
11
|
+
/* static */
|
|
12
|
+
|
|
13
|
+
/* static-inverted */
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.pageIndicator {
|
|
17
|
+
margin: 0;
|
|
18
|
+
padding: 0;
|
|
19
|
+
display: flex;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.element {
|
|
23
|
+
list-style-type: none;
|
|
24
|
+
flex-grow: 1;
|
|
25
|
+
transition: backgroud var(--page-indicator-animation-duration)
|
|
26
|
+
var(--page-indicator-animation-timing-function);
|
|
27
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
|
|
5
|
+
/* default */
|
|
6
|
+
|
|
7
|
+
/* inverted */
|
|
8
|
+
--page-indicator-color-inverted: var(--color-light-neutral-translucent-300-inverted);
|
|
9
|
+
--page-indicator-active-color-inverted: var(--color-light-neutral-translucent-1300-inverted);
|
|
10
|
+
|
|
11
|
+
/* static */
|
|
12
|
+
|
|
13
|
+
/* static-inverted */
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.element {
|
|
17
|
+
background: var(--page-indicator-color-inverted)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.element.active {
|
|
21
|
+
background: var(--page-indicator-active-color-inverted);
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
|
|
5
|
+
/* default */
|
|
6
|
+
|
|
7
|
+
/* inverted */
|
|
8
|
+
|
|
9
|
+
/* static */
|
|
10
|
+
|
|
11
|
+
/* static-inverted */
|
|
12
|
+
--page-indicator-color-static-inverted: var(--color-static-neutral-translucent-300-inverted);
|
|
13
|
+
--page-indicator-active-color-static-inverted: var(--color-static-neutral-1300-inverted);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.element {
|
|
17
|
+
background: var(--page-indicator-color-static-inverted)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.element.active {
|
|
21
|
+
background: var(--page-indicator-active-color-static-inverted);
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
|
|
5
|
+
/* default */
|
|
6
|
+
|
|
7
|
+
/* inverted */
|
|
8
|
+
|
|
9
|
+
/* static */
|
|
10
|
+
--page-indicator-color-static: var(--color-static-neutral-translucent-300);
|
|
11
|
+
--page-indicator-active-color-static: var(--color-static-neutral-1300);
|
|
12
|
+
|
|
13
|
+
/* static-inverted */
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.element {
|
|
17
|
+
background: var(--page-indicator-color-static)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.element.active {
|
|
21
|
+
background: var(--page-indicator-active-color-static);
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { PageIndicatorBullet } from './components/bullet/Component.js';
|
|
2
|
+
export { PageIndicatorDynamic } from './components/dynamic/Component.js';
|
|
3
|
+
export { PageIndicatorRunner } from './components/runner/Component.js';
|
|
4
|
+
export { PageIndicatorStep } from './components/step/Component.js';
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
interface PageIndicatorDynamicProps {
|
|
2
|
+
/**
|
|
3
|
+
* Индекс выбранного элемента по-умолчанию
|
|
4
|
+
* @default 0
|
|
5
|
+
*/
|
|
6
|
+
defaultActiveElement?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Индекс выбранного элемента
|
|
9
|
+
*/
|
|
10
|
+
activeElement?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Количество элементов (минимум 2)
|
|
13
|
+
* @default 10
|
|
14
|
+
*/
|
|
15
|
+
elements?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Высота компонента
|
|
18
|
+
* @default 8
|
|
19
|
+
*/
|
|
20
|
+
size?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Ширина выбранного элемента
|
|
23
|
+
* @default size * 7
|
|
24
|
+
*/
|
|
25
|
+
activeElementWidth?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Расстояние между элементами
|
|
28
|
+
* @default 8
|
|
29
|
+
*/
|
|
30
|
+
gap?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Продолжительность прогресса выбранного элемента, в миллисекундах
|
|
33
|
+
* @default 3000
|
|
34
|
+
*/
|
|
35
|
+
duration?: (activeElement: number) => number | number;
|
|
36
|
+
/**
|
|
37
|
+
* Обработчик при изменении выбранного элемента. Вызывается при заполнении прогресса предыдущего выбранного элемента
|
|
38
|
+
*/
|
|
39
|
+
onActiveElementChange?: (nextActiveElement: number) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Зациклен ли обход элементов
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
cycle?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Активен ли прогресс выбранного элемента
|
|
47
|
+
* @default true
|
|
48
|
+
*/
|
|
49
|
+
active?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Набор цветов для компонента
|
|
52
|
+
* @default default
|
|
53
|
+
*/
|
|
54
|
+
colors?: 'default' | 'inverted' | 'static' | 'static-inverted';
|
|
55
|
+
}
|
|
56
|
+
interface PageIndicatorBulletProps {
|
|
57
|
+
/**
|
|
58
|
+
* Индекс выбранного элемента
|
|
59
|
+
*/
|
|
60
|
+
activeElement: number;
|
|
61
|
+
/**
|
|
62
|
+
* Количество элементов (минимум 2)
|
|
63
|
+
* @default 10
|
|
64
|
+
*/
|
|
65
|
+
elements?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Высота компонента
|
|
68
|
+
* @default 8
|
|
69
|
+
*/
|
|
70
|
+
size?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Расстояние между элементами
|
|
73
|
+
* @default 8
|
|
74
|
+
*/
|
|
75
|
+
gap?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Набор цветов для компонента
|
|
78
|
+
* @default default
|
|
79
|
+
*/
|
|
80
|
+
colors?: 'default' | 'inverted' | 'static' | 'static-inverted';
|
|
81
|
+
}
|
|
82
|
+
interface PageIndicatorStepProps {
|
|
83
|
+
/**
|
|
84
|
+
* Индекс выбранного элемента
|
|
85
|
+
*/
|
|
86
|
+
activeElement: number;
|
|
87
|
+
/**
|
|
88
|
+
* Количество элементов (минимум 2)
|
|
89
|
+
* @default 10
|
|
90
|
+
*/
|
|
91
|
+
elements?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Высота компонента
|
|
94
|
+
* @default 4
|
|
95
|
+
*/
|
|
96
|
+
size?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Расстояние между элементами
|
|
99
|
+
* @default 4
|
|
100
|
+
*/
|
|
101
|
+
gap?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Набор цветов для компонента
|
|
104
|
+
* @default default
|
|
105
|
+
*/
|
|
106
|
+
colors?: 'default' | 'inverted' | 'static' | 'static-inverted';
|
|
107
|
+
}
|
|
108
|
+
interface PageIndicatorRunnerProps {
|
|
109
|
+
/**
|
|
110
|
+
* Индекс выбранного элемента
|
|
111
|
+
*/
|
|
112
|
+
activeElement: number;
|
|
113
|
+
/**
|
|
114
|
+
* Количество элементов (минимум 2)
|
|
115
|
+
* @default 10
|
|
116
|
+
*/
|
|
117
|
+
elements?: number;
|
|
118
|
+
/**
|
|
119
|
+
* Высота компонента
|
|
120
|
+
* @default 4
|
|
121
|
+
*/
|
|
122
|
+
size?: number;
|
|
123
|
+
/**
|
|
124
|
+
* Набор цветов для компонента
|
|
125
|
+
* @default default
|
|
126
|
+
*/
|
|
127
|
+
colors?: 'default' | 'inverted' | 'static' | 'static-inverted';
|
|
128
|
+
}
|
|
129
|
+
export { PageIndicatorDynamicProps, PageIndicatorBulletProps, PageIndicatorStepProps, PageIndicatorRunnerProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alfalab/core-components-page-indicator",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "PageIndicator component",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"module": "./esm/index.js",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public",
|
|
11
|
+
"directory": "dist"
|
|
12
|
+
},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"react": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@alfalab/core-components-shared": "^0.16.0",
|
|
18
|
+
"classnames": "^2.5.1",
|
|
19
|
+
"react-transition-group": "^4.4.5",
|
|
20
|
+
"tslib": "^2.4.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/react-transition-group": "^4.4.5"
|
|
24
|
+
},
|
|
25
|
+
"themesVersion": "13.7.1",
|
|
26
|
+
"varsVersion": "9.18.0",
|
|
27
|
+
"sideEffects": false
|
|
28
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { createRef, FC, useMemo } from 'react';
|
|
2
|
+
import { CSSTransition } from 'react-transition-group';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
|
|
5
|
+
import { PageIndicatorBulletProps } from '../../types';
|
|
6
|
+
|
|
7
|
+
import { calcParams } from './utils';
|
|
8
|
+
|
|
9
|
+
import defaultColors from './default.module.css';
|
|
10
|
+
import styles from './index.module.css';
|
|
11
|
+
import invertedColors from './inverted.module.css';
|
|
12
|
+
import staticColors from './static.module.css';
|
|
13
|
+
import staticInvertedColors from './static-inverted.module.css';
|
|
14
|
+
|
|
15
|
+
const colorsStyle = {
|
|
16
|
+
inverted: invertedColors,
|
|
17
|
+
default: defaultColors,
|
|
18
|
+
static: staticColors,
|
|
19
|
+
'static-inverted': staticInvertedColors,
|
|
20
|
+
} as const;
|
|
21
|
+
|
|
22
|
+
const transitionClassess = {} as const;
|
|
23
|
+
|
|
24
|
+
export const PageIndicatorBullet: FC<PageIndicatorBulletProps> = ({
|
|
25
|
+
elements: count = 10,
|
|
26
|
+
activeElement: activeElementIndex,
|
|
27
|
+
size = 8,
|
|
28
|
+
gap = 8,
|
|
29
|
+
colors = 'default',
|
|
30
|
+
}) => {
|
|
31
|
+
const refs = useMemo(() => Array.from({ length: count }, createRef<HTMLLIElement>), [count]);
|
|
32
|
+
const [height, width, offset, elementSize, firstVisibleElementIndex, lastVisibleElementIndex] =
|
|
33
|
+
useMemo(
|
|
34
|
+
() => calcParams(size, gap, activeElementIndex, count),
|
|
35
|
+
[activeElementIndex, count, gap, size],
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div className={cn(styles.pageIndicator, styles.bullet)} style={{ height, width }}>
|
|
40
|
+
<ol
|
|
41
|
+
className={styles.elementsList}
|
|
42
|
+
style={{ gap, transform: `translate(${offset}px)` }}
|
|
43
|
+
>
|
|
44
|
+
{refs.map((ref, index) => {
|
|
45
|
+
const sizeOfElement = elementSize(index);
|
|
46
|
+
const isActive = activeElementIndex === index;
|
|
47
|
+
const isVisible =
|
|
48
|
+
firstVisibleElementIndex <= index && index <= lastVisibleElementIndex;
|
|
49
|
+
const addListTransitionEndListener = (done: () => void) => {
|
|
50
|
+
const parentElement = ref.current?.parentElement;
|
|
51
|
+
|
|
52
|
+
parentElement?.addEventListener('transitionend', done, { once: true });
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<CSSTransition
|
|
57
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
58
|
+
key={index}
|
|
59
|
+
nodeRef={ref}
|
|
60
|
+
addEndListener={addListTransitionEndListener}
|
|
61
|
+
in={isVisible}
|
|
62
|
+
// passed empty object so any classes aren't added
|
|
63
|
+
classNames={transitionClassess}
|
|
64
|
+
>
|
|
65
|
+
{(status) => (
|
|
66
|
+
<li
|
|
67
|
+
ref={ref}
|
|
68
|
+
data-index={index}
|
|
69
|
+
className={cn(
|
|
70
|
+
styles.element,
|
|
71
|
+
colorsStyle[colors].element,
|
|
72
|
+
{ [colorsStyle[colors].active]: isActive },
|
|
73
|
+
styles[status],
|
|
74
|
+
)}
|
|
75
|
+
style={{ height: sizeOfElement, width: sizeOfElement }}
|
|
76
|
+
/>
|
|
77
|
+
)}
|
|
78
|
+
</CSSTransition>
|
|
79
|
+
);
|
|
80
|
+
})}
|
|
81
|
+
</ol>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@import '../../vars.css';
|
|
2
|
+
|
|
3
|
+
.pageIndicator {
|
|
4
|
+
&.bullet {
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.elementsList {
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
will-change: transform;
|
|
15
|
+
transition: transform var(--page-indicator-animation-duration)
|
|
16
|
+
var(--page-indicator-animation-timing-function);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.element {
|
|
20
|
+
list-style-type: none;
|
|
21
|
+
flex-shrink: 0;
|
|
22
|
+
transition: background var(--page-indicator-animation-duration)
|
|
23
|
+
var(--page-indicator-animation-timing-function);
|
|
24
|
+
border-radius: var(--border-radius-circle);
|
|
25
|
+
|
|
26
|
+
&.entering {
|
|
27
|
+
opacity: 0;
|
|
28
|
+
}
|
|
29
|
+
&.entered {
|
|
30
|
+
opacity: 1;
|
|
31
|
+
transition: background var(--page-indicator-animation-duration)
|
|
32
|
+
var(--page-indicator-animation-timing-function),
|
|
33
|
+
opacity var(--page-indicator-animation-duration)
|
|
34
|
+
var(--page-indicator-animation-timing-function);
|
|
35
|
+
}
|
|
36
|
+
&.exiting {
|
|
37
|
+
opacity: 0;
|
|
38
|
+
}
|
|
39
|
+
&.exited {
|
|
40
|
+
opacity: 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './utils';
|