@donkit-ai/design-system 0.3.4 → 0.4.2

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 (45) hide show
  1. package/dist/index.cjs.js +22 -0
  2. package/dist/index.es.js +1105 -0
  3. package/dist/tokens.css +1 -0
  4. package/package.json +15 -9
  5. package/src/components/Accordion.css +0 -70
  6. package/src/components/Accordion.jsx +0 -42
  7. package/src/components/Alert.css +0 -93
  8. package/src/components/Alert.jsx +0 -47
  9. package/src/components/Badge.css +0 -52
  10. package/src/components/Badge.jsx +0 -25
  11. package/src/components/Button.css +0 -103
  12. package/src/components/Button.jsx +0 -80
  13. package/src/components/Card.css +0 -46
  14. package/src/components/Card.jsx +0 -70
  15. package/src/components/Checkbox.css +0 -88
  16. package/src/components/Checkbox.jsx +0 -47
  17. package/src/components/Code.css +0 -30
  18. package/src/components/Code.jsx +0 -27
  19. package/src/components/CodeAccordion.css +0 -80
  20. package/src/components/CodeAccordion.jsx +0 -42
  21. package/src/components/Input.css +0 -163
  22. package/src/components/Input.jsx +0 -55
  23. package/src/components/Link.css +0 -18
  24. package/src/components/Link.jsx +0 -21
  25. package/src/components/Modal.css +0 -70
  26. package/src/components/Modal.jsx +0 -72
  27. package/src/components/Radio.css +0 -115
  28. package/src/components/Radio.jsx +0 -42
  29. package/src/components/Select.css +0 -167
  30. package/src/components/Select.jsx +0 -118
  31. package/src/components/Stepper.css +0 -183
  32. package/src/components/Stepper.jsx +0 -104
  33. package/src/components/Tabs.css +0 -87
  34. package/src/components/Tabs.jsx +0 -81
  35. package/src/components/Textarea.css +0 -116
  36. package/src/components/Textarea.jsx +0 -41
  37. package/src/components/Toggle.css +0 -133
  38. package/src/components/Toggle.jsx +0 -38
  39. package/src/components/Tooltip.css +0 -134
  40. package/src/components/Tooltip.jsx +0 -148
  41. package/src/components/Typography.css +0 -74
  42. package/src/components/Typography.jsx +0 -42
  43. package/src/index.js +0 -24
  44. package/src/styles/iconSizes.js +0 -15
  45. package/src/styles/tokens.css +0 -298
@@ -1,133 +0,0 @@
1
- .ds-toggle {
2
- display: inline-flex;
3
- align-items: center;
4
- gap: var(--space-s);
5
- cursor: pointer;
6
- }
7
-
8
- .ds-toggle--disabled {
9
- opacity: 0.5;
10
- cursor: not-allowed;
11
- }
12
-
13
- .ds-toggle__input {
14
- position: absolute;
15
- opacity: 0;
16
- pointer-events: none;
17
- }
18
-
19
- .ds-toggle__track {
20
- position: relative;
21
- display: flex;
22
- align-items: center;
23
- background-color: var(--color-item-bg);
24
- border: 1px solid var(--color-border);
25
- transition: background-color var(--transition-normal), border-color var(--transition-normal);
26
- flex-shrink: 0;
27
- }
28
-
29
- .ds-toggle__input:checked + .ds-toggle__track {
30
- background-color: var(--color-status-success);
31
- border-color: var(--color-status-success);
32
- }
33
-
34
- .ds-toggle__input:not(:checked) + .ds-toggle__track:hover {
35
- border-color: var(--color-border-hover);
36
- }
37
-
38
- .ds-toggle__thumb {
39
- background-color: var(--color-white);
40
- border-radius: 50%;
41
- transition: transform var(--transition-normal);
42
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
43
- }
44
-
45
- .ds-toggle__label {
46
- font-size: var(--font-size-p1);
47
- color: var(--color-txt-icon-1);
48
- user-select: none;
49
- }
50
-
51
- /* Extra Small */
52
- .ds-toggle--xs .ds-toggle__track {
53
- width: calc(var(--icon-xs) * 1.75);
54
- height: var(--icon-xs);
55
- border-radius: calc(var(--icon-xs) / 2);
56
- padding: 2px;
57
- }
58
-
59
- .ds-toggle--xs .ds-toggle__thumb {
60
- width: calc(var(--icon-xs) - 4px);
61
- height: calc(var(--icon-xs) - 4px);
62
- }
63
-
64
- .ds-toggle--xs .ds-toggle__input:checked + .ds-toggle__track .ds-toggle__thumb {
65
- transform: translateX(calc(var(--icon-xs) * 0.75));
66
- }
67
-
68
- .ds-toggle--xs .ds-toggle__label {
69
- font-size: var(--font-size-p3);
70
- }
71
-
72
- /* Small */
73
- .ds-toggle--s .ds-toggle__track {
74
- width: calc(var(--icon-s) * 1.75);
75
- height: var(--icon-s);
76
- border-radius: calc(var(--icon-s) / 2);
77
- padding: 2px;
78
- }
79
-
80
- .ds-toggle--s .ds-toggle__thumb {
81
- width: calc(var(--icon-s) - 4px);
82
- height: calc(var(--icon-s) - 4px);
83
- }
84
-
85
- .ds-toggle--s .ds-toggle__input:checked + .ds-toggle__track .ds-toggle__thumb {
86
- transform: translateX(calc(var(--icon-s) * 0.75));
87
- }
88
-
89
- .ds-toggle--s .ds-toggle__label {
90
- font-size: var(--font-size-p2);
91
- }
92
-
93
- /* Medium */
94
- .ds-toggle--m .ds-toggle__track {
95
- width: calc(var(--icon-m) * 1.75);
96
- height: var(--icon-m);
97
- border-radius: calc(var(--icon-m) / 2);
98
- padding: 2px;
99
- }
100
-
101
- .ds-toggle--m .ds-toggle__thumb {
102
- width: calc(var(--icon-m) - 4px);
103
- height: calc(var(--icon-m) - 4px);
104
- }
105
-
106
- .ds-toggle--m .ds-toggle__input:checked + .ds-toggle__track .ds-toggle__thumb {
107
- transform: translateX(calc(var(--icon-m) * 0.75));
108
- }
109
-
110
- .ds-toggle--m .ds-toggle__label {
111
- font-size: var(--font-size-p1);
112
- }
113
-
114
- /* Large */
115
- .ds-toggle--l .ds-toggle__track {
116
- width: calc(var(--icon-l) * 1.75);
117
- height: var(--icon-l);
118
- border-radius: calc(var(--icon-l) / 2);
119
- padding: 3px;
120
- }
121
-
122
- .ds-toggle--l .ds-toggle__thumb {
123
- width: calc(var(--icon-l) - 6px);
124
- height: calc(var(--icon-l) - 6px);
125
- }
126
-
127
- .ds-toggle--l .ds-toggle__input:checked + .ds-toggle__track .ds-toggle__thumb {
128
- transform: translateX(calc(var(--icon-l) * 0.75));
129
- }
130
-
131
- .ds-toggle--l .ds-toggle__label {
132
- font-size: var(--font-size-p1);
133
- }
@@ -1,38 +0,0 @@
1
- import React from 'react';
2
- import './Toggle.css';
3
-
4
- export function Toggle({
5
- checked = false,
6
- onChange,
7
- size = 'm',
8
- disabled = false,
9
- label,
10
- id,
11
- ...props
12
- }) {
13
- const toggleId = id || `toggle-${React.useId()}`;
14
-
15
- const className = [
16
- 'ds-toggle',
17
- `ds-toggle--${size}`,
18
- disabled && 'ds-toggle--disabled',
19
- ].filter(Boolean).join(' ');
20
-
21
- return (
22
- <label className={className} htmlFor={toggleId}>
23
- <input
24
- type="checkbox"
25
- id={toggleId}
26
- className="ds-toggle__input"
27
- checked={checked}
28
- onChange={(e) => onChange?.(e.target.checked)}
29
- disabled={disabled}
30
- {...props}
31
- />
32
- <span className="ds-toggle__track">
33
- <span className="ds-toggle__thumb" />
34
- </span>
35
- {label && <span className="ds-toggle__label">{label}</span>}
36
- </label>
37
- );
38
- }
@@ -1,134 +0,0 @@
1
- .ds-tooltip-wrapper {
2
- position: relative;
3
- display: inline-flex;
4
- }
5
-
6
- .ds-tooltip {
7
- position: absolute;
8
- background-color: var(--color-bg);
9
- color: var(--color-txt-icon-2);
10
- font-size: var(--font-size-p3);
11
- letter-spacing: var(--letter-spacing-p3);
12
- width: max-content;
13
- max-width: 200px;
14
- padding: var(--space-xs);
15
- border: 1px solid var(--color-border);
16
- border-radius: var(--radius-xs);
17
- z-index: 2000;
18
- white-space: normal;
19
- word-wrap: break-word;
20
- pointer-events: none;
21
- line-height: 1.4;
22
- }
23
-
24
- /* Position: Top */
25
- .ds-tooltip--top {
26
- bottom: calc(100% + 8px);
27
- left: 50%;
28
- transform: translateX(calc(-50% + var(--tooltip-offset-x, 0px)));
29
- }
30
-
31
- .ds-tooltip--top::after {
32
- content: '';
33
- position: absolute;
34
- top: 100%;
35
- left: calc(50% + var(--arrow-offset, 0px));
36
- transform: translateX(-50%);
37
- border: 4px solid transparent;
38
- border-top-color: var(--color-border);
39
- }
40
-
41
- .ds-tooltip--top::before {
42
- content: '';
43
- position: absolute;
44
- top: 100%;
45
- left: calc(50% + var(--arrow-offset, 0px));
46
- transform: translateX(-50%);
47
- border: 3px solid transparent;
48
- border-top-color: var(--color-bg);
49
- z-index: 1;
50
- }
51
-
52
- /* Position: Bottom */
53
- .ds-tooltip--bottom {
54
- top: calc(100% + 8px);
55
- left: 50%;
56
- transform: translateX(calc(-50% + var(--tooltip-offset-x, 0px)));
57
- }
58
-
59
- .ds-tooltip--bottom::after {
60
- content: '';
61
- position: absolute;
62
- bottom: 100%;
63
- left: calc(50% + var(--arrow-offset, 0px));
64
- transform: translateX(-50%);
65
- border: 4px solid transparent;
66
- border-bottom-color: var(--color-border);
67
- }
68
-
69
- .ds-tooltip--bottom::before {
70
- content: '';
71
- position: absolute;
72
- bottom: 100%;
73
- left: calc(50% + var(--arrow-offset, 0px));
74
- transform: translateX(-50%);
75
- border: 3px solid transparent;
76
- border-bottom-color: var(--color-bg);
77
- z-index: 1;
78
- }
79
-
80
- /* Position: Left */
81
- .ds-tooltip--left {
82
- right: calc(100% + 8px);
83
- top: 50%;
84
- transform: translateY(-50%);
85
- }
86
-
87
- .ds-tooltip--left::after {
88
- content: '';
89
- position: absolute;
90
- left: 100%;
91
- top: 50%;
92
- transform: translateY(-50%);
93
- border: 4px solid transparent;
94
- border-left-color: var(--color-border);
95
- }
96
-
97
- .ds-tooltip--left::before {
98
- content: '';
99
- position: absolute;
100
- left: 100%;
101
- top: 50%;
102
- transform: translateY(-50%);
103
- border: 3px solid transparent;
104
- border-left-color: var(--color-bg);
105
- z-index: 1;
106
- }
107
-
108
- /* Position: Right */
109
- .ds-tooltip--right {
110
- left: calc(100% + 8px);
111
- top: 50%;
112
- transform: translateY(-50%);
113
- }
114
-
115
- .ds-tooltip--right::after {
116
- content: '';
117
- position: absolute;
118
- right: 100%;
119
- top: 50%;
120
- transform: translateY(-50%);
121
- border: 4px solid transparent;
122
- border-right-color: var(--color-border);
123
- }
124
-
125
- .ds-tooltip--right::before {
126
- content: '';
127
- position: absolute;
128
- right: 100%;
129
- top: 50%;
130
- transform: translateY(-50%);
131
- border: 3px solid transparent;
132
- border-right-color: var(--color-bg);
133
- z-index: 1;
134
- }
@@ -1,148 +0,0 @@
1
- import React, { useState, useRef, useEffect } from 'react';
2
- import './Tooltip.css';
3
-
4
- export function Tooltip({
5
- children,
6
- content,
7
- position,
8
- ...props
9
- }) {
10
- const [isVisible, setIsVisible] = useState(false);
11
- const [computedPosition, setComputedPosition] = useState(position || 'top');
12
- const [offset, setOffset] = useState({ x: 0, arrowOffset: 0 });
13
- const wrapperRef = useRef(null);
14
- const tooltipRef = useRef(null);
15
- const isTouchDevice = useRef(false);
16
-
17
- useEffect(() => {
18
- if (isVisible && !position && wrapperRef.current && tooltipRef.current) {
19
- const wrapperRect = wrapperRef.current.getBoundingClientRect();
20
- const tooltipRect = tooltipRef.current.getBoundingClientRect();
21
- const viewportHeight = window.innerHeight;
22
- const viewportWidth = window.innerWidth;
23
-
24
- // Calculate available space in each direction
25
- const spaceTop = wrapperRect.top;
26
- const spaceBottom = viewportHeight - wrapperRect.bottom;
27
- const spaceLeft = wrapperRect.left;
28
- const spaceRight = viewportWidth - wrapperRect.right;
29
-
30
- const tooltipHeight = tooltipRect.height;
31
- const tooltipWidth = tooltipRect.width;
32
-
33
- // Prefer top/bottom first, then left/right
34
- if (spaceTop >= tooltipHeight + 8) {
35
- setComputedPosition('top');
36
- } else if (spaceBottom >= tooltipHeight + 8) {
37
- setComputedPosition('bottom');
38
- } else if (spaceRight >= tooltipWidth + 8) {
39
- setComputedPosition('right');
40
- } else if (spaceLeft >= tooltipWidth + 8) {
41
- setComputedPosition('left');
42
- } else {
43
- // Fallback to direction with most space
44
- const maxSpace = Math.max(spaceTop, spaceBottom, spaceLeft, spaceRight);
45
- if (maxSpace === spaceTop) setComputedPosition('top');
46
- else if (maxSpace === spaceBottom) setComputedPosition('bottom');
47
- else if (maxSpace === spaceRight) setComputedPosition('right');
48
- else setComputedPosition('left');
49
- }
50
- } else if (position) {
51
- setComputedPosition(position);
52
- }
53
- }, [isVisible, position]);
54
-
55
- // Check viewport boundaries and adjust position
56
- useEffect(() => {
57
- if (isVisible && tooltipRef.current && wrapperRef.current) {
58
- const tooltipRect = tooltipRef.current.getBoundingClientRect();
59
- const viewportWidth = window.innerWidth;
60
- const PADDING = 8; // minimum distance from viewport edge
61
-
62
- let xOffset = 0;
63
- let arrowShift = 0;
64
-
65
- // For top/bottom positions, check horizontal overflow
66
- if (computedPosition === 'top' || computedPosition === 'bottom') {
67
- // Check if tooltip overflows on the right
68
- if (tooltipRect.right > viewportWidth - PADDING) {
69
- xOffset = viewportWidth - PADDING - tooltipRect.right;
70
- arrowShift = -xOffset; // arrow moves opposite direction
71
- }
72
- // Check if tooltip overflows on the left
73
- else if (tooltipRect.left < PADDING) {
74
- xOffset = PADDING - tooltipRect.left;
75
- arrowShift = -xOffset; // arrow moves opposite direction
76
- }
77
- }
78
-
79
- setOffset({ x: xOffset, arrowOffset: arrowShift });
80
- } else {
81
- setOffset({ x: 0, arrowOffset: 0 });
82
- }
83
- }, [isVisible, computedPosition]);
84
-
85
- // Close tooltip when clicking outside (for touch interfaces)
86
- useEffect(() => {
87
- if (!isVisible) return;
88
-
89
- const handleClickOutside = (event) => {
90
- if (wrapperRef.current && !wrapperRef.current.contains(event.target)) {
91
- setIsVisible(false);
92
- }
93
- };
94
-
95
- document.addEventListener('touchstart', handleClickOutside);
96
-
97
- return () => {
98
- document.removeEventListener('touchstart', handleClickOutside);
99
- };
100
- }, [isVisible]);
101
-
102
- const handleTouchStart = () => {
103
- isTouchDevice.current = true;
104
- setIsVisible((prev) => !prev);
105
- };
106
-
107
- const handleMouseEnter = () => {
108
- // Ignore mouse events on touch devices
109
- if (!isTouchDevice.current) {
110
- setIsVisible(true);
111
- }
112
- };
113
-
114
- const handleMouseLeave = () => {
115
- // Ignore mouse events on touch devices
116
- if (!isTouchDevice.current) {
117
- setIsVisible(false);
118
- }
119
- };
120
-
121
- if (!content) return children;
122
-
123
- return (
124
- <div
125
- ref={wrapperRef}
126
- className="ds-tooltip-wrapper"
127
- onMouseEnter={handleMouseEnter}
128
- onMouseLeave={handleMouseLeave}
129
- onTouchStart={handleTouchStart}
130
- {...props}
131
- >
132
- {children}
133
- {isVisible && (
134
- <div
135
- ref={tooltipRef}
136
- className={`ds-tooltip ds-tooltip--${computedPosition}`}
137
- role="tooltip"
138
- style={{
139
- '--tooltip-offset-x': `${offset.x}px`,
140
- '--arrow-offset': `${offset.arrowOffset}px`,
141
- }}
142
- >
143
- {content}
144
- </div>
145
- )}
146
- </div>
147
- );
148
- }
@@ -1,74 +0,0 @@
1
- .ds-h1 {
2
- font-size: var(--font-size-h1);
3
- font-weight: 400;
4
- line-height: 1.2;
5
- color: var(--color-txt-icon-1);
6
- letter-spacing: var(--letter-spacing-h1);
7
- margin: 0;
8
- }
9
-
10
- .ds-h2 {
11
- font-size: var(--font-size-h2);
12
- font-weight: 400;
13
- line-height: 1.3;
14
- color: var(--color-txt-icon-1);
15
- letter-spacing: var(--letter-spacing-h2);
16
- margin: 0;
17
- }
18
-
19
- .ds-h3 {
20
- font-size: var(--font-size-h3);
21
- font-weight: 400;
22
- line-height: 1.3;
23
- color: var(--color-txt-icon-1);
24
- letter-spacing: var(--letter-spacing-h3);
25
- margin: 0;
26
- }
27
-
28
- .ds-h4 {
29
- font-size: var(--font-size-h4);
30
- font-weight: 400;
31
- line-height: 1.4;
32
- color: var(--color-txt-icon-1);
33
- letter-spacing: var(--letter-spacing-h4);
34
- margin: 0;
35
- }
36
-
37
- .ds-p1 {
38
- font-size: var(--font-size-p1);
39
- font-weight: 400;
40
- line-height: 1.5;
41
- color: var(--color-txt-icon-1);
42
- letter-spacing: var(--letter-spacing-p1);
43
- margin: 0;
44
- }
45
-
46
- .ds-p1--secondary {
47
- color: var(--color-txt-icon-2);
48
- }
49
-
50
- .ds-p2 {
51
- font-size: var(--font-size-p2);
52
- font-weight: 400;
53
- line-height: 1.5;
54
- color: var(--color-txt-icon-1);
55
- letter-spacing: var(--letter-spacing-p2);
56
- margin: 0;
57
- }
58
-
59
- .ds-p2--secondary {
60
- color: var(--color-txt-icon-2);
61
- }
62
-
63
- .ds-p3 {
64
- font-size: var(--font-size-p3);
65
- font-weight: 400;
66
- line-height: 1.5;
67
- color: var(--color-txt-icon-1);
68
- letter-spacing: var(--letter-spacing-p3);
69
- margin: 0;
70
- }
71
-
72
- .ds-p3--secondary {
73
- color: var(--color-txt-icon-2);
74
- }
@@ -1,42 +0,0 @@
1
- import React from 'react';
2
- import './Typography.css';
3
-
4
- export function H1({ children, ...props }) {
5
- return <h1 className="ds-h1" {...props}>{children}</h1>;
6
- }
7
-
8
- export function H2({ children, ...props }) {
9
- return <h2 className="ds-h2" {...props}>{children}</h2>;
10
- }
11
-
12
- export function H3({ children, ...props }) {
13
- return <h3 className="ds-h3" {...props}>{children}</h3>;
14
- }
15
-
16
- export function H4({ children, ...props }) {
17
- return <h4 className="ds-h4" {...props}>{children}</h4>;
18
- }
19
-
20
- export function P1({ children, secondary = false, ...props }) {
21
- return (
22
- <p className={`ds-p1 ${secondary ? 'ds-p1--secondary' : ''}`} {...props}>
23
- {children}
24
- </p>
25
- );
26
- }
27
-
28
- export function P2({ children, secondary = false, ...props }) {
29
- return (
30
- <p className={`ds-p2 ${secondary ? 'ds-p2--secondary' : ''}`} {...props}>
31
- {children}
32
- </p>
33
- );
34
- }
35
-
36
- export function P3({ children, secondary = false, ...props }) {
37
- return (
38
- <p className={`ds-p3 ${secondary ? 'ds-p3--secondary' : ''}`} {...props}>
39
- {children}
40
- </p>
41
- );
42
- }
package/src/index.js DELETED
@@ -1,24 +0,0 @@
1
- // Styles
2
- export * from './styles/tokens.css';
3
- export { iconSizes } from './styles/iconSizes';
4
-
5
- // Components
6
- export { Button } from './components/Button';
7
- export { Input } from './components/Input';
8
- export { Textarea } from './components/Textarea';
9
- export { Select } from './components/Select';
10
- export { Stepper } from './components/Stepper';
11
- export { Card } from './components/Card';
12
- export { H1, H2, H3, H4, P1, P2, P3 } from './components/Typography';
13
- export { Badge } from './components/Badge';
14
- export { Alert } from './components/Alert';
15
- export { Modal, ModalFooter } from './components/Modal';
16
- export { Code } from './components/Code';
17
- export { Link } from './components/Link';
18
- export { Tabs, Tab } from './components/Tabs';
19
- export { Accordion } from './components/Accordion';
20
- export { CodeAccordion } from './components/CodeAccordion';
21
- export { Tooltip } from './components/Tooltip';
22
- export { Toggle } from './components/Toggle';
23
- export { Checkbox } from './components/Checkbox';
24
- export { Radio } from './components/Radio';
@@ -1,15 +0,0 @@
1
- /**
2
- * Icon sizes matching CSS variables
3
- * --icon-xs: 16px
4
- * --icon-s: 20px
5
- * --icon-m: 24px
6
- * --icon-l: 28px
7
- * --icon-xl: 48px
8
- */
9
- export const iconSizes = {
10
- xs: 16,
11
- s: 20,
12
- m: 24,
13
- l: 28,
14
- xl: 48,
15
- };