idea-react 3.0.0-alpha.0 → 3.0.0-beta.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.
Files changed (76) hide show
  1. package/AGENTS.md +31 -10
  2. package/ReadMe.md +75 -41
  3. package/dist/index.d.mts +451 -100
  4. package/dist/index.d.ts +451 -100
  5. package/dist/index.js +16 -16
  6. package/dist/index.mjs +15 -15
  7. package/dist/style.css +5 -5
  8. package/package.json +7 -8
  9. package/source/Avatar.tsx +65 -12
  10. package/source/Button.tsx +13 -4
  11. package/source/ButtonGroup.tsx +28 -0
  12. package/source/Card.tsx +34 -0
  13. package/source/ClickBoundary.tsx +6 -5
  14. package/source/CloseButton.tsx +23 -0
  15. package/source/CodeBlock.tsx +5 -3
  16. package/source/Countdown.tsx +2 -0
  17. package/source/Drawer.tsx +62 -0
  18. package/source/Editor.tsx +5 -8
  19. package/source/Form/Adorn.tsx +38 -0
  20. package/source/Form/Checkbox.tsx +73 -0
  21. package/source/Form/Chips.tsx +51 -0
  22. package/source/Form/Combobox.tsx +109 -0
  23. package/source/Form/Control.tsx +59 -0
  24. package/source/Form/DatePicker.tsx +89 -0
  25. package/source/Form/Feedback.tsx +29 -0
  26. package/source/Form/FloatingLabel.tsx +15 -0
  27. package/source/Form/InputGroup.tsx +23 -0
  28. package/source/Form/OTP.tsx +48 -0
  29. package/source/Form/PasswordStrength.tsx +157 -0
  30. package/source/Form/Primitives.tsx +46 -0
  31. package/source/Form/Radio.tsx +51 -0
  32. package/source/Form/Range.tsx +65 -0
  33. package/source/Form/Switch.tsx +35 -0
  34. package/source/Form/index.ts +15 -0
  35. package/source/Grid.tsx +92 -0
  36. package/source/HorizontalMarquee/index.tsx +4 -10
  37. package/source/Image.tsx +15 -0
  38. package/source/ListGroup.tsx +103 -0
  39. package/source/LiveTSX.tsx +1 -1
  40. package/source/Loading.tsx +4 -3
  41. package/source/Menu.tsx +99 -1
  42. package/source/MonthCalendar.tsx +60 -22
  43. package/source/NativeDialog/index.tsx +37 -1
  44. package/source/Nav.tsx +52 -0
  45. package/source/Navbar.tsx +58 -1
  46. package/source/Overlay.ts +22 -0
  47. package/source/OverlayBox.tsx +200 -32
  48. package/source/PageNav.tsx +56 -32
  49. package/source/Popover.tsx +36 -0
  50. package/source/ScrollNav/Scroller.tsx +107 -0
  51. package/source/ScrollNav/index.tsx +12 -99
  52. package/source/Select.tsx +66 -55
  53. package/source/ShareBox.tsx +5 -11
  54. package/source/Spinner.tsx +30 -0
  55. package/source/SpinnerButton.tsx +8 -10
  56. package/source/Table.tsx +59 -0
  57. package/source/TableSpinner.tsx +7 -5
  58. package/source/{TextTruncate.tsx → TextTruncate/Content.tsx} +24 -20
  59. package/source/TextTruncate/index.tsx +25 -0
  60. package/source/Time.tsx +7 -33
  61. package/source/TimeDistance.tsx +1 -1
  62. package/source/Timeline/index.tsx +7 -7
  63. package/source/Toast.tsx +120 -29
  64. package/source/ToggleButton.tsx +47 -0
  65. package/source/Tooltip.tsx +32 -0
  66. package/source/TypeEcho/Content.tsx +58 -0
  67. package/source/TypeEcho/index.tsx +14 -0
  68. package/source/UserRank/index.module.less +9 -20
  69. package/source/UserRank/index.tsx +35 -32
  70. package/source/VerticalMarquee/index.module.less +0 -1
  71. package/source/VerticalMarquee/index.tsx +3 -5
  72. package/source/ZodiacBar.tsx +1 -1
  73. package/source/animate.ts +4 -2
  74. package/source/color.ts +3 -5
  75. package/source/index.ts +14 -0
  76. package/source/TypeEcho.tsx +0 -49
package/source/Toast.tsx CHANGED
@@ -1,79 +1,170 @@
1
- import { observable } from 'mobx';
1
+ 'use client';
2
+
3
+ import classNames from 'classnames';
4
+ import { action, observable } from 'mobx';
2
5
  import { observer } from 'mobx-react';
3
- import { FC, ReactNode } from 'react';
4
- import { Toast as BSToast, ToastContainer, ToastContainerProps } from 'react-bootstrap';
5
- import { Variant } from 'react-bootstrap/esm/types';
6
+ import { ComponentPropsWithRef, FC, MouseEvent, ReactNode } from 'react';
6
7
  import { Timestamp, uniqueID } from 'web-utility';
7
8
 
8
- const LIGHT_TEXT_VARIANTS = new Set<Variant>(['warning', 'info', 'light']);
9
+ import type { ComponentTheme } from './Button';
10
+
11
+ export type ToastPosition =
12
+ | 'top-start'
13
+ | 'top-center'
14
+ | 'top-end'
15
+ | 'middle-start'
16
+ | 'middle-center'
17
+ | 'middle-end'
18
+ | 'bottom-start'
19
+ | 'bottom-center'
20
+ | 'bottom-end';
21
+
22
+ const TOAST_POSITION_CLASSES: Record<ToastPosition, string> = {
23
+ 'top-start': 'top-0 start-0',
24
+ 'top-center': 'top-0 start-50 translate-middle-x',
25
+ 'top-end': 'top-0 end-0',
26
+ 'middle-start': 'top-50 start-0 translate-middle-y',
27
+ 'middle-center': 'top-50 start-50 translate-middle',
28
+ 'middle-end': 'top-50 end-0 translate-middle-y',
29
+ 'bottom-start': 'bottom-0 start-0',
30
+ 'bottom-center': 'bottom-0 start-50 translate-middle-x',
31
+ 'bottom-end': 'bottom-0 end-0'
32
+ };
9
33
 
10
34
  export interface ToastMessage {
11
35
  id?: string;
12
36
  title?: ReactNode;
13
37
  body: ReactNode;
14
- variant?: Variant;
38
+ theme?: ComponentTheme;
15
39
  delay?: number;
16
40
  }
17
41
 
18
- interface ToastItem extends ToastMessage {
42
+ interface ToastEntry extends ToastMessage {
19
43
  openedAt: number;
20
44
  closedAt?: number;
21
- resolve?: (value: ToastItem) => void;
45
+ timer?: ReturnType<typeof setTimeout>;
46
+ resolve?: (value: ToastEntry) => void;
47
+ }
48
+
49
+ export interface ToastContainerProps extends ComponentPropsWithRef<'div'> {
50
+ position?: ToastPosition | 'static';
51
+ }
52
+
53
+ export const ToastContainer: FC<ToastContainerProps> = ({
54
+ position = 'top-end',
55
+ className,
56
+ 'aria-live': ariaLive = 'polite',
57
+ 'aria-atomic': ariaAtomic = true,
58
+ ...props
59
+ }) => {
60
+ const isStatic = position === 'static';
61
+
62
+ return (
63
+ <div
64
+ {...props}
65
+ className={classNames(
66
+ 'toast-container',
67
+ !isStatic && 'position-fixed',
68
+ !isStatic && 'p-3',
69
+ isStatic ? 'position-static' : TOAST_POSITION_CLASSES[position],
70
+ className
71
+ )}
72
+ aria-live={ariaLive}
73
+ aria-atomic={ariaAtomic}
74
+ />
75
+ );
76
+ };
77
+
78
+ export interface ToastItemProps extends ComponentPropsWithRef<'div'> {
79
+ theme?: ComponentTheme;
22
80
  }
23
81
 
82
+ export const ToastItem: FC<ToastItemProps> = ({ theme, role = 'status', className, ...props }) => (
83
+ <div
84
+ {...props}
85
+ className={classNames('toast show', theme && `theme-${theme}`, className)}
86
+ role={role}
87
+ />
88
+ );
89
+
90
+ export const ToastHeader: FC<ComponentPropsWithRef<'div'>> = ({ className, ...props }) => (
91
+ <div {...props} className={classNames('toast-header', className)} />
92
+ );
93
+
94
+ export const ToastBody: FC<ComponentPropsWithRef<'div'>> = ({ className, ...props }) => (
95
+ <div {...props} className={classNames('toast-body', className)} />
96
+ );
97
+
24
98
  export class Toast {
25
99
  @observable
26
- accessor messages: ToastItem[] = [];
100
+ accessor messages: ToastEntry[] = [];
27
101
 
28
- Component: FC<Pick<ToastContainerProps, 'position'>> = observer(({ position = 'top-end' }) => (
29
- <ToastContainer position={position} className="position-fixed p-3">
102
+ Component: FC<{ position?: ToastPosition }> = observer(({ position }) => (
103
+ <ToastContainer position={position} onClick={this.handleDismiss}>
30
104
  {this.messages.map(this.renderMessage)}
31
105
  </ToastContainer>
32
106
  ));
33
107
 
34
- renderMessage = ({ id, openedAt, title, body, variant, delay = 3000 }: ToastItem) => {
35
- const bodyClassName =
36
- variant && !LIGHT_TEXT_VARIANTS.has(variant) ? 'text-white' : undefined;
108
+ renderMessage = ({ id, openedAt, title, body, theme, delay = 3000 }: ToastEntry) => {
37
109
  const showHeader = !!title || delay === 0;
38
110
  const elapsed = this.TimeScalar.distanceOf<Timestamp>(Date.now(), openedAt).toShortString();
39
111
 
40
112
  return (
41
- <BSToast
42
- key={id}
43
- bg={variant}
44
- delay={delay}
45
- autohide={delay !== 0}
46
- onClose={() => this.close(id!)}
47
- >
113
+ <ToastItem key={id} theme={theme}>
48
114
  {showHeader && (
49
- <BSToast.Header>
115
+ <ToastHeader>
50
116
  <strong className="me-auto">{title}</strong>
51
117
  <small>{elapsed}</small>
52
- </BSToast.Header>
118
+ <button
119
+ type="button"
120
+ className="btn-close"
121
+ aria-label="Close"
122
+ data-toast-dismiss={id}
123
+ />
124
+ </ToastHeader>
53
125
  )}
54
- <BSToast.Body className={bodyClassName}>{body}</BSToast.Body>
55
- </BSToast>
126
+ <ToastBody>{body}</ToastBody>
127
+ </ToastItem>
56
128
  );
57
129
  };
58
130
 
131
+ handleDismiss = ({ target }: MouseEvent<HTMLDivElement>) => {
132
+ if (!(target instanceof Element)) return;
133
+
134
+ const id = target.closest<HTMLElement>('[data-toast-dismiss]')?.dataset.toastDismiss;
135
+ if (id) this.close(id);
136
+ };
137
+
59
138
  constructor(public TimeScalar = Timestamp) {
60
139
  this.Component.displayName = 'ToastComponent';
61
140
  }
62
141
 
142
+ @action
63
143
  open(message: ToastMessage) {
64
144
  const id = uniqueID();
65
145
  const openedAt = Date.now();
66
- const { promise, resolve } = Promise.withResolvers<ToastItem>();
146
+ const { promise, resolve } = Promise.withResolvers<ToastEntry>();
147
+ const timer =
148
+ message.delay === 0
149
+ ? undefined
150
+ : setTimeout(() => this.close(id), message.delay ?? 3000);
67
151
 
68
- this.messages = [...this.messages, { id, ...message, openedAt, resolve }];
152
+ const item: ToastEntry = { id, ...message, openedAt, resolve, timer };
153
+
154
+ this.messages = [...this.messages, item];
69
155
 
70
156
  return promise;
71
157
  }
72
158
 
159
+ @action
73
160
  close(id: string) {
74
- const { resolve, ...item } = this.messages.find(message => message.id === id) || {};
161
+ const message = this.messages.find(message => message.id === id);
162
+ if (!message) return;
163
+
164
+ const { resolve, timer, ...item } = message;
75
165
 
76
- resolve?.({ ...item, closedAt: Date.now() } as ToastItem);
166
+ clearTimeout(timer);
167
+ resolve?.({ ...item, closedAt: Date.now() } as ToastEntry);
77
168
 
78
169
  this.messages = this.messages.filter(message => message.id !== id);
79
170
  }
@@ -0,0 +1,47 @@
1
+ import classNames from 'classnames';
2
+ import { ComponentPropsWithRef, FC } from 'react';
3
+
4
+ import type { ComponentTheme } from './Button';
5
+
6
+ export interface ToggleButtonProps extends Omit<ComponentPropsWithRef<'label'>, 'onChange'> {
7
+ type?: 'checkbox' | 'radio';
8
+ variant?: 'solid' | 'outline' | 'subtle' | 'text';
9
+ theme?: ComponentTheme;
10
+ name?: string;
11
+ value?: string;
12
+ checked?: boolean;
13
+ defaultChecked?: boolean;
14
+ disabled?: boolean;
15
+ }
16
+
17
+ export const ToggleButton: FC<ToggleButtonProps> = ({
18
+ type = 'checkbox',
19
+ variant = 'solid',
20
+ theme,
21
+ name,
22
+ value,
23
+ checked,
24
+ defaultChecked,
25
+ disabled,
26
+ className,
27
+ children,
28
+ ...props
29
+ }) => (
30
+ <label
31
+ {...props}
32
+ className={classNames('btn-check', `btn-${variant}`, theme && `theme-${theme}`, className)}
33
+ >
34
+ <input
35
+ type={type}
36
+ name={name}
37
+ value={value}
38
+ checked={checked}
39
+ defaultChecked={defaultChecked}
40
+ disabled={disabled}
41
+ autoComplete="off"
42
+ />
43
+ {children}
44
+ </label>
45
+ );
46
+
47
+ ToggleButton.displayName = 'ToggleButton';
@@ -0,0 +1,32 @@
1
+ import classNames from 'classnames';
2
+ import { FC } from 'react';
3
+
4
+ import { OVERLAY_ARROW_POSITIONS, OVERLAY_DIRECTIONS, OverlayTriggerProps } from './Overlay';
5
+
6
+ export type TooltipProps = OverlayTriggerProps;
7
+
8
+ export const Tooltip: FC<TooltipProps> = ({
9
+ placement = 'top',
10
+ show = true,
11
+ role = 'tooltip',
12
+ className,
13
+ children,
14
+ ...props
15
+ }) => (
16
+ <div
17
+ {...props}
18
+ className={classNames(
19
+ 'tooltip',
20
+ { show },
21
+ `bs-tooltip-${OVERLAY_DIRECTIONS[placement]}`,
22
+ className
23
+ )}
24
+ role={role}
25
+ data-bs-placement={placement}
26
+ >
27
+ <div className={classNames('tooltip-arrow', OVERLAY_ARROW_POSITIONS[placement])} />
28
+ <div className="tooltip-inner">{children}</div>
29
+ </div>
30
+ );
31
+
32
+ Tooltip.displayName = 'Tooltip';
@@ -0,0 +1,58 @@
1
+ 'use client';
2
+
3
+ import classNames from 'classnames';
4
+ import { action, observable } from 'mobx';
5
+ import { observer } from 'mobx-react';
6
+ import { Component, HTMLAttributes, RefCallback } from 'react';
7
+ import { sleep } from 'web-utility';
8
+
9
+ export interface TypeEchoContentProps extends Omit<HTMLAttributes<HTMLPreElement>, 'children'> {
10
+ text: string;
11
+ intervals?: number;
12
+ }
13
+
14
+ @observer
15
+ export class TypeEchoContent extends Component<TypeEchoContentProps> {
16
+ @observable
17
+ accessor echoed = '';
18
+
19
+ @observable
20
+ accessor started = false;
21
+
22
+ componentDidMount() {
23
+ this.start();
24
+ }
25
+
26
+ start = action(() => (this.started = true));
27
+
28
+ echo = action((char: string) => (this.echoed += char));
29
+
30
+ init: RefCallback<HTMLPreElement> = node => {
31
+ if (!node) return;
32
+
33
+ new IntersectionObserver(async ([{ isIntersecting }], observer) => {
34
+ if (!isIntersecting) return;
35
+
36
+ observer.disconnect();
37
+
38
+ const { text, intervals = 150 } = this.props;
39
+
40
+ for (const char of text) {
41
+ await sleep(intervals / 1000);
42
+
43
+ this.echo(char);
44
+ }
45
+ }).observe(node);
46
+ };
47
+
48
+ render() {
49
+ const { className, text, intervals: _intervals, ...props } = this.props;
50
+ const { started, echoed } = this;
51
+
52
+ return (
53
+ <pre {...props} ref={this.init} className={classNames('text-wrap', className)}>
54
+ {started ? echoed + (echoed === text ? '' : '_') : text}
55
+ </pre>
56
+ );
57
+ }
58
+ }
@@ -0,0 +1,14 @@
1
+ import { FC, HTMLAttributes } from 'react';
2
+
3
+ import { TypeEchoContent } from './Content';
4
+
5
+ export interface TypeEchoProps extends HTMLAttributes<HTMLPreElement> {
6
+ text: string;
7
+ intervals?: number;
8
+ }
9
+
10
+ export const TypeEcho: FC<TypeEchoProps> = ({ text, intervals, ...props }) => (
11
+ <TypeEchoContent {...props} text={text} intervals={intervals} />
12
+ );
13
+
14
+ TypeEcho.displayName = 'TypeEcho';
@@ -54,8 +54,7 @@
54
54
  i {
55
55
  box-shadow: 0 0 0.5rem 0 #ffd83a;
56
56
  border: 0.1rem solid #ffd83a;
57
- background-image: var(--logo-image),
58
- linear-gradient(#ffd83a, #fdeba0);
57
+ background-image: var(--logo-image), linear-gradient(#ffd83a, #fdeba0);
59
58
  background-position: center;
60
59
  background-size: 1.5rem 1.5rem;
61
60
  background-repeat: no-repeat;
@@ -65,14 +64,12 @@
65
64
  &:first-child {
66
65
  box-shadow: 0 0 0.5rem 0 #d8d8d8;
67
66
  border-color: #d8d8d8;
68
- background-image: var(--logo-image),
69
- linear-gradient(#d8d8d8, #eeeeee);
67
+ background-image: var(--logo-image), linear-gradient(#d8d8d8, #eeeeee);
70
68
  }
71
69
  &:last-child {
72
70
  box-shadow: 0 0 0.5rem 0 #fab36e;
73
71
  border-color: #fab36e;
74
- background-image: var(--logo-image),
75
- linear-gradient(#fab36e, #fbe7d3);
72
+ background-image: var(--logo-image), linear-gradient(#fab36e, #fbe7d3);
76
73
  }
77
74
  }
78
75
  }
@@ -98,12 +95,7 @@
98
95
  left: 0;
99
96
  z-index: 1;
100
97
  margin: 0 auto;
101
- background-image: linear-gradient(
102
- to right,
103
- #d8d8d8 10%,
104
- #ffd83a 60%,
105
- #fab36e 75%
106
- );
98
+ background-image: linear-gradient(to right, #d8d8d8 10%, #ffd83a 60%, #fab36e 75%);
107
99
  background-clip: text;
108
100
  width: 10rem;
109
101
  content: attr(data-text);
@@ -136,8 +128,7 @@
136
128
  0px 1px 0px #969653,
137
129
  0px 2px 5px rgba(240, 219, 100, 0.4);
138
130
  i {
139
- background-image: var(--logo-image),
140
- linear-gradient(#ffd83a, #fdeba0);
131
+ background-image: var(--logo-image), linear-gradient(#ffd83a, #fdeba0);
141
132
  background-position: center;
142
133
  background-size: 2.5rem auto;
143
134
  background-repeat: no-repeat;
@@ -157,11 +148,9 @@
157
148
  .topUser {
158
149
  border-bottom: 1.2rem solid #d8d8d8;
159
150
  color: #d8d8d8;
160
- text-shadow: 0px 1px 0px #d9cdcd 0px 2px 5px
161
- rgba(133, 132, 130, 0.4);
151
+ text-shadow: 0px 1px 0px #d9cdcd 0px 2px 5px rgba(133, 132, 130, 0.4);
162
152
  i {
163
- background-image: var(--logo-image),
164
- linear-gradient(#d8d8d8, #eeeeee);
153
+ background-image: var(--logo-image), linear-gradient(#d8d8d8, #eeeeee);
165
154
  }
166
155
  }
167
156
  .image {
@@ -179,8 +168,7 @@
179
168
  0px 1px 0px #aa8865,
180
169
  0px 2px 5px rgba(167, 129, 67, 0.4);
181
170
  i {
182
- background-image: var(--logo-image),
183
- linear-gradient(#fab36e, #fbe7d3);
171
+ background-image: var(--logo-image), linear-gradient(#fab36e, #fbe7d3);
184
172
  }
185
173
  }
186
174
  .image {
@@ -215,6 +203,7 @@
215
203
  cursor: default;
216
204
  background-color: transparent;
217
205
  .name {
206
+ max-width: 50%;
218
207
  font-size: 0;
219
208
  &:hover {
220
209
  .image > img {
@@ -1,6 +1,9 @@
1
- import { PureComponent } from 'react';
2
- import { Badge, Col, Image, Row, RowProps, Table } from 'react-bootstrap';
1
+ import { FC, HTMLAttributes } from 'react';
3
2
 
3
+ import { Badge } from '../Badge';
4
+ import { Col, Container, Row } from '../Grid';
5
+ import { Image } from '../Image';
6
+ import { Table } from '../Table';
4
7
  import { UserAddress, UserAddressProps } from './Address';
5
8
  import * as style from './index.module.less';
6
9
 
@@ -11,44 +14,45 @@ export interface UserRank extends UserAddressProps {
11
14
  score: number;
12
15
  }
13
16
 
14
- export interface UserRankViewProps extends RowProps {
17
+ export interface UserRankViewProps extends HTMLAttributes<HTMLDivElement> {
15
18
  title: string;
16
19
  rank: UserRank[];
17
20
  linkOf?: (user: UserRank) => string;
18
21
  }
19
22
 
20
- export class UserRankView extends PureComponent<UserRankViewProps> {
21
- static displayName = 'UserRankView';
22
-
23
- renderMedal = (user: UserRank) => (
24
- <Col key={user.id} as="li">
23
+ export const UserRankView: FC<UserRankViewProps> = ({
24
+ className = '',
25
+ title,
26
+ rank = [],
27
+ linkOf,
28
+ ...props
29
+ }) => {
30
+ const renderMedal = (user: UserRank) => (
31
+ <li key={user.id} className="col">
25
32
  <div className={`shadow-lg overflow-hidden rounded-circle m-auto ${style.image}`}>
26
33
  <Image src={user.avatar} alt={user.name} loading="lazy" fluid />
27
34
  </div>
28
35
  <div className={`position-relative overflow-hidden ${style.topUser}`}>
29
36
  <div className="position-relative">
30
37
  <i className="d-block overflow-hidden m-auto mb-1 rounded-circle" />
31
- <a
32
- className="d-block mb-0 stretched-link"
33
- href={this.props.linkOf?.(user) || '#'}
34
- >
38
+ <a className="d-block mb-0 stretched-link" href={linkOf?.(user) || '#'}>
35
39
  {user.name}
36
40
  </a>
37
41
  <strong>{user.score}</strong>
38
42
  </div>
39
43
  <UserAddress {...user} />
40
44
  </div>
41
- </Col>
45
+ </li>
42
46
  );
43
47
 
44
- renderRow = (user: UserRank, index: number, { length }: UserRank[]) => (
48
+ const renderRow = (user: UserRank, index: number, { length }: UserRank[]) => (
45
49
  <tr key={user.id} className="position-relative">
46
50
  <td className="align-middle">
47
51
  <Badge className="fw-bold fst-italic">
48
52
  {(index + 4 + '').padStart((length + '').length, '0')}
49
53
  </Badge>
50
54
  </td>
51
- <td className={`position-relative mw-50 text-truncate ${style.name}`}>
55
+ <td className={`position-relative text-truncate ${style.name}`}>
52
56
  <div
53
57
  className={`d-inline-block overflow-hidden align-middle rounded-circle ${style.image}`}
54
58
  >
@@ -59,7 +63,7 @@ export class UserRankView extends PureComponent<UserRankViewProps> {
59
63
  style={{
60
64
  color: `rgb(248, ${(index + 2) * 15}, ${(index + 2) * 35})`
61
65
  }}
62
- href={this.props.linkOf?.(user) || '#'}
66
+ href={linkOf?.(user) || '#'}
63
67
  >
64
68
  {user.name}
65
69
  </a>
@@ -71,12 +75,10 @@ export class UserRankView extends PureComponent<UserRankViewProps> {
71
75
  </tr>
72
76
  );
73
77
 
74
- render() {
75
- const { className = '', title, rank = [], linkOf, ...props } = this.props;
76
-
77
- return (
78
- <Row className={`${style.rankBox} ${className}`} {...props}>
79
- <Col sm={12} xs={12} lg={7}>
78
+ return (
79
+ <Container className={className} {...props}>
80
+ <Row className={style.rankBox}>
81
+ <Col span={12} lg={7}>
80
82
  <div className={`shadow rounded-3 ${style.title}`}>
81
83
  <div className={style.medal}>
82
84
  <i className="d-inline-block ms-1 overflow-hidden rounded-circle" />
@@ -90,19 +92,20 @@ export class UserRankView extends PureComponent<UserRankViewProps> {
90
92
  {title}
91
93
  </h3>
92
94
  </div>
93
- <Row
94
- as="ul"
95
- className={`mt-2 g-0 align-items-end text-center ps-0 pt-2 list-unstyled ${style.topUsers}`}
95
+ <ul
96
+ className={`row mt-2 g-0 align-items-end text-center ps-0 pt-2 list-unstyled ${style.topUsers}`}
96
97
  >
97
- {rank.slice(0, 3).map(this.renderMedal)}
98
- </Row>
98
+ {rank.slice(0, 3).map(renderMedal)}
99
+ </ul>
99
100
  </Col>
100
- <Col xs={12} sm={12} lg={5}>
101
+ <Col span={12} lg={5}>
101
102
  <Table className={`my-3 pt-2 ${style.restUsers}`} responsive>
102
- <tbody>{rank.slice(3, 10).map(this.renderRow)}</tbody>
103
+ <tbody>{rank.slice(3, 10).map(renderRow)}</tbody>
103
104
  </Table>
104
105
  </Col>
105
106
  </Row>
106
- );
107
- }
108
- }
107
+ </Container>
108
+ );
109
+ };
110
+
111
+ UserRankView.displayName = 'UserRankView';
@@ -26,7 +26,6 @@
26
26
  animation-timing-function: linear;
27
27
  animation-iteration-count: infinite;
28
28
  animation-direction: alternate;
29
- font-size: 0;
30
29
  &:hover {
31
30
  animation-play-state: paused;
32
31
  .scrollItem {
@@ -12,15 +12,13 @@ export const VerticalMarquee: FC<VerticalMarqueeProps> = ({
12
12
  duration,
13
13
  ...props
14
14
  }) => (
15
- <div className={`overflow-hidden ${className}`} {...props}>
15
+ <div className={`overflow-hidden h-100 ${className}`} {...props}>
16
16
  <div
17
- className={`d-inline-block mw-100 mh-100 ${style.scrollWrap}`}
17
+ className={`d-inline-block max-w-100 max-h-100 ${style.scrollWrap}`}
18
18
  // @ts-expect-error remove after React 19 released
19
19
  style={{ '--duration': duration }}
20
20
  >
21
- <div className={`d-inline-block ${style.scrollItem}`}>
22
- {children}
23
- </div>
21
+ <div className={`d-inline-block ${style.scrollItem}`}>{children}</div>
24
22
  </div>
25
23
  </div>
26
24
  );
@@ -39,7 +39,7 @@ export const ZodiacBar: FC<ZodiacBarProps> = ({
39
39
  return (
40
40
  <li key={year} className={itemClassName}>
41
41
  <a className="d-inline-block p-3 text-decoration-none text-center" href={link}>
42
- <div className="fs-1">{zodiac}</div>
42
+ <div className="fs-3xl">{zodiac}</div>
43
43
 
44
44
  {title}
45
45
  </a>
package/source/animate.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { RefCallback } from 'react';
2
2
 
3
3
  export function animate(name: string): RefCallback<Element> {
4
- return element =>
5
- element &&
4
+ return element => {
5
+ if (!element) return;
6
+
6
7
  new IntersectionObserver(([{ isIntersecting, target }], observer) => {
7
8
  if (!isIntersecting) return;
8
9
 
@@ -17,4 +18,5 @@ export function animate(name: string): RefCallback<Element> {
17
18
  );
18
19
  observer.disconnect();
19
20
  }).observe(element);
21
+ };
20
22
  }
package/source/color.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Color } from 'react-bootstrap/esm/types';
1
+ import type { ComponentTheme } from './Button';
2
2
 
3
- export type VariantColor = Exclude<Color, 'white' | 'muted'>;
3
+ export type VariantColor = ComponentTheme;
4
4
 
5
5
  export const VariantColors: VariantColor[] = [
6
6
  'primary',
@@ -15,9 +15,7 @@ export const VariantColors: VariantColor[] = [
15
15
 
16
16
  export function text2color(raw: string, excludeColors: VariantColor[] = []) {
17
17
  const colors = excludeColors[0]
18
- ? VariantColors.filter(
19
- color => !excludeColors.find(c => c === color)
20
- )
18
+ ? VariantColors.filter(color => !excludeColors.find(c => c === color))
21
19
  : VariantColors,
22
20
  sum = [...raw].reduce((sum, char) => sum + char.charCodeAt(0), 0);
23
21