@cyber-harbour/ui 1.0.59 → 1.0.61
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/dist/index.d.mts +513 -43
- package/dist/index.d.ts +513 -43
- package/dist/index.js +343 -310
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +276 -243
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Core/Alert/Alert.tsx +11 -5
- package/src/Core/Box/Box.tsx +19 -17
- package/src/Core/Button/Button.tsx +59 -55
- package/src/Core/Checkbox/Checkbox.tsx +6 -7
- package/src/Core/ContentLoader/ContentLoader.tsx +13 -0
- package/src/Core/ContentLoader/index.ts +1 -0
- package/src/Core/Drawer/Drawer.tsx +29 -14
- package/src/Core/Flex/FlexContainer.tsx +47 -45
- package/src/Core/Flex/FlexItem.tsx +19 -26
- package/src/Core/IconComponents/PencilIcon.tsx +16 -0
- package/src/Core/IconComponents/PointIcon.tsx +16 -0
- package/src/Core/IconComponents/index.ts +2 -0
- package/src/Core/Label/Label.tsx +31 -30
- package/src/Core/Line/Line.tsx +5 -5
- package/src/Core/LinerProgress/LinerProgress.tsx +14 -20
- package/src/Core/Switch/Switch.tsx +4 -4
- package/src/Core/Tag/Tag.tsx +29 -36
- package/src/Core/Tooltip/Tooltip.tsx +93 -0
- package/src/Core/Tooltip/index.ts +1 -0
- package/src/Core/Typography/Typography.tsx +31 -33
- package/src/Core/index.ts +2 -0
- package/src/Layouts/Container/Container.tsx +13 -7
- package/src/Theme/Breakpoint.tsx +50 -0
- package/src/Theme/ThemeProvider.tsx +5 -2
- package/src/Theme/{componentFabric.ts → componentFabric.tsx} +90 -36
- package/src/Theme/index.ts +1 -0
- package/src/Theme/themes/dark.ts +11 -0
- package/src/Theme/themes/light.ts +11 -0
- package/src/Theme/types.ts +11 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import styled, { css,
|
|
1
|
+
import styled, { css, DefaultTheme } from 'styled-components';
|
|
2
2
|
import { pxToRem } from './utils';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { useBreakpoint } from './Breakpoint';
|
|
5
|
+
import { Breakpoint } from './types';
|
|
6
|
+
import { breakpoints } from './themes/config';
|
|
3
7
|
|
|
4
8
|
type SpaceProps = {
|
|
5
9
|
m?: string | number; // margin
|
|
@@ -18,9 +22,39 @@ type SpaceProps = {
|
|
|
18
22
|
py?: string | number; // padding-top + padding-bottom
|
|
19
23
|
};
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
type GeneratedFabricMarginProperties =
|
|
26
|
+
| 'margin'
|
|
27
|
+
| 'margin-top'
|
|
28
|
+
| 'margin-right'
|
|
29
|
+
| 'margin-bottom'
|
|
30
|
+
| 'margin-left'
|
|
31
|
+
| 'margin-inline'
|
|
32
|
+
| 'margin-block'
|
|
33
|
+
| 'padding'
|
|
34
|
+
| 'padding-top'
|
|
35
|
+
| 'padding-right'
|
|
36
|
+
| 'padding-bottom'
|
|
37
|
+
| 'padding-left'
|
|
38
|
+
| 'padding-inline'
|
|
39
|
+
| 'padding-block';
|
|
40
|
+
|
|
41
|
+
type MediaProps<T = object> = {
|
|
42
|
+
media?: {
|
|
43
|
+
[key in Breakpoint]?: Partial<T>;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
22
46
|
|
|
23
|
-
|
|
47
|
+
type FabricStyledComponentOptions = {
|
|
48
|
+
ignoreStyles?: GeneratedFabricMarginProperties[] | undefined; // Ignore margin styles
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type CreatedFabricComponent<T extends FabricComponent> =
|
|
52
|
+
| React.ComponentType<Omit<T, 'media'>>
|
|
53
|
+
| React.ForwardRefExoticComponent<Omit<T, 'media'>>;
|
|
54
|
+
export type FabricComponent<T = object> = T & SpaceProps & MediaProps<T>;
|
|
55
|
+
export type StyledFabricComponent<T = object> = T & SpaceProps;
|
|
56
|
+
|
|
57
|
+
const marginStyles = ({ ignoreStyles }: FabricStyledComponentOptions = {}) =>
|
|
24
58
|
css<FabricComponent>(({ theme, ...props }) => {
|
|
25
59
|
return `
|
|
26
60
|
${generatePropertySpaceStyle(theme, 'margin', props.m, ignoreStyles)}
|
|
@@ -33,7 +67,7 @@ const marginStyles = ({ ignoreStyles }: FabricComponentOptions = {}) =>
|
|
|
33
67
|
`;
|
|
34
68
|
});
|
|
35
69
|
|
|
36
|
-
const paddingStyles = ({ ignoreStyles }:
|
|
70
|
+
const paddingStyles = ({ ignoreStyles }: FabricStyledComponentOptions = {}) =>
|
|
37
71
|
css<FabricComponent>(({ theme, ...props }) => {
|
|
38
72
|
return `
|
|
39
73
|
${generatePropertySpaceStyle(theme, 'padding', props.p, ignoreStyles)}
|
|
@@ -46,21 +80,17 @@ const paddingStyles = ({ ignoreStyles }: FabricComponentOptions = {}) =>
|
|
|
46
80
|
`;
|
|
47
81
|
});
|
|
48
82
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
| 'padding-bottom'
|
|
61
|
-
| 'padding-left'
|
|
62
|
-
| 'padding-inline'
|
|
63
|
-
| 'padding-block';
|
|
83
|
+
export const destructSpaceProps = <T extends FabricComponent>(props: T): SpaceProps => {
|
|
84
|
+
const rest: SpaceProps = {};
|
|
85
|
+
['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'p', 'pt', 'pr', 'pb', 'pl', 'px', 'py'].forEach((key) => {
|
|
86
|
+
if (key in props) {
|
|
87
|
+
rest[key as keyof SpaceProps] = props[key as keyof SpaceProps];
|
|
88
|
+
delete props[key as keyof SpaceProps];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return rest;
|
|
93
|
+
};
|
|
64
94
|
|
|
65
95
|
export const generatePropertySpaceStyle = (
|
|
66
96
|
theme: DefaultTheme,
|
|
@@ -78,28 +108,52 @@ export const generatePropertySpaceStyle = (
|
|
|
78
108
|
return '';
|
|
79
109
|
};
|
|
80
110
|
|
|
81
|
-
|
|
82
|
-
|
|
111
|
+
export function getResponsiveProps<T = object>(
|
|
112
|
+
{ media, ...props }: T & MediaProps<T>,
|
|
113
|
+
currentBreakpoint: Breakpoint,
|
|
114
|
+
breakpointOrder: Breakpoint[]
|
|
115
|
+
) {
|
|
116
|
+
if (!media) {
|
|
117
|
+
return props;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Отримуємо індекс поточного breakpoint
|
|
121
|
+
const currentIndex = breakpointOrder.indexOf(currentBreakpoint);
|
|
122
|
+
|
|
123
|
+
// Створюємо результуючий об'єкт, починаючи з базових props
|
|
124
|
+
let result = { ...props };
|
|
125
|
+
|
|
126
|
+
// Застосовуємо стилі від найменшого breakpoint до поточного (mobile-first)
|
|
127
|
+
for (let i = 0; i <= currentIndex; i++) {
|
|
128
|
+
const breakpoint = breakpointOrder[i];
|
|
129
|
+
if (media[breakpoint]) {
|
|
130
|
+
result = {
|
|
131
|
+
...result,
|
|
132
|
+
...media[breakpoint],
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export const createComponent = <T extends FabricComponent, R = unknown>(Component: CreatedFabricComponent<T>) => {
|
|
141
|
+
return React.forwardRef<R, FabricComponent<T>>((props, ref) => {
|
|
142
|
+
const { currentBreakpoint, breakpointsOrder } = useBreakpoint();
|
|
143
|
+
const responsiveProps = useMemo(
|
|
144
|
+
() => getResponsiveProps<T>(props as T & MediaProps<T>, currentBreakpoint, breakpointsOrder),
|
|
145
|
+
[props, currentBreakpoint]
|
|
146
|
+
);
|
|
147
|
+
return <Component {...responsiveProps} ref={ref} />;
|
|
148
|
+
});
|
|
83
149
|
};
|
|
84
150
|
|
|
85
|
-
export const
|
|
151
|
+
export const createStyledComponent = <T extends object = StyledFabricComponent>(
|
|
86
152
|
component: React.ComponentType<T>,
|
|
87
|
-
options?:
|
|
153
|
+
options?: FabricStyledComponentOptions
|
|
88
154
|
) => {
|
|
89
|
-
return styled(component)<T
|
|
155
|
+
return styled(component)<StyledFabricComponent<T>>`
|
|
90
156
|
${marginStyles(options)}
|
|
91
157
|
${paddingStyles(options)}
|
|
92
158
|
`;
|
|
93
159
|
};
|
|
94
|
-
|
|
95
|
-
export const destructSpaceProps = <T extends FabricComponent>(props: T): SpaceProps => {
|
|
96
|
-
const rest: SpaceProps = {};
|
|
97
|
-
['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'p', 'pt', 'pr', 'pb', 'pl', 'px', 'py'].forEach((key) => {
|
|
98
|
-
if (key in props) {
|
|
99
|
-
rest[key as keyof SpaceProps] = props[key as keyof SpaceProps];
|
|
100
|
-
delete props[key as keyof SpaceProps];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
return rest;
|
|
105
|
-
};
|
package/src/Theme/index.ts
CHANGED
package/src/Theme/themes/dark.ts
CHANGED
|
@@ -28,6 +28,8 @@ export const darkThemePx: Theme = {
|
|
|
28
28
|
light: '#99989C',
|
|
29
29
|
lighter: '#535353',
|
|
30
30
|
invert: '#101010',
|
|
31
|
+
success: '#31B083',
|
|
32
|
+
error: '#C93939',
|
|
31
33
|
},
|
|
32
34
|
stroke: {
|
|
33
35
|
main: '#34404C',
|
|
@@ -965,6 +967,15 @@ export const darkThemePx: Theme = {
|
|
|
965
967
|
width: 573,
|
|
966
968
|
shadow: '0px 4px 10px 0px rgba(0, 0, 0, 0.25)',
|
|
967
969
|
},
|
|
970
|
+
tooltip: {
|
|
971
|
+
fontSize: 14,
|
|
972
|
+
padding: 10,
|
|
973
|
+
borderRadius: 6,
|
|
974
|
+
maxWidth: 240,
|
|
975
|
+
shadow: '0px 4px 10px 0px rgba(0, 0, 0, 0.25)',
|
|
976
|
+
color: '#99989C',
|
|
977
|
+
background: '#1E2226',
|
|
978
|
+
},
|
|
968
979
|
};
|
|
969
980
|
|
|
970
981
|
export const darkTheme = convertPaletteToRem(darkThemePx, darkThemePx.baseSize) as DefaultTheme;
|
|
@@ -27,6 +27,8 @@ export const lightThemePx: Theme = {
|
|
|
27
27
|
light: '#535353',
|
|
28
28
|
lighter: '#99989C',
|
|
29
29
|
invert: '#ffffff',
|
|
30
|
+
success: '#31B083',
|
|
31
|
+
error: '#C93939',
|
|
30
32
|
},
|
|
31
33
|
stroke: {
|
|
32
34
|
main: '#C7C5C5',
|
|
@@ -964,6 +966,15 @@ export const lightThemePx: Theme = {
|
|
|
964
966
|
width: 573,
|
|
965
967
|
shadow: '0px 4px 10px 0px rgba(0, 0, 0, 0.25)',
|
|
966
968
|
},
|
|
969
|
+
tooltip: {
|
|
970
|
+
fontSize: 14,
|
|
971
|
+
padding: 10,
|
|
972
|
+
borderRadius: 6,
|
|
973
|
+
maxWidth: 240,
|
|
974
|
+
shadow: '0px 4px 10px 0px rgba(0, 0, 0, 0.25)',
|
|
975
|
+
color: '#535353',
|
|
976
|
+
background: '#EBEBEB',
|
|
977
|
+
},
|
|
967
978
|
};
|
|
968
979
|
|
|
969
980
|
export const lightTheme = convertPaletteToRem(lightThemePx, lightThemePx.baseSize) as DefaultTheme;
|
package/src/Theme/types.ts
CHANGED
|
@@ -105,6 +105,8 @@ export type Theme = {
|
|
|
105
105
|
light: string;
|
|
106
106
|
lighter: string;
|
|
107
107
|
invert: string;
|
|
108
|
+
success: string;
|
|
109
|
+
error: string;
|
|
108
110
|
};
|
|
109
111
|
stroke: {
|
|
110
112
|
main: string;
|
|
@@ -308,6 +310,15 @@ export type Theme = {
|
|
|
308
310
|
width: number;
|
|
309
311
|
shadow: string;
|
|
310
312
|
};
|
|
313
|
+
tooltip: {
|
|
314
|
+
fontSize: string | number;
|
|
315
|
+
padding: string | number;
|
|
316
|
+
maxWidth: string | number;
|
|
317
|
+
borderRadius: string | number;
|
|
318
|
+
shadow: string;
|
|
319
|
+
color: string;
|
|
320
|
+
background: string;
|
|
321
|
+
};
|
|
311
322
|
};
|
|
312
323
|
|
|
313
324
|
//TODO check and refactoring
|