@cyber-harbour/ui 1.0.63 → 1.0.65
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 +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +86 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +125 -123
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Core/Pagination/Pagination.tsx +18 -13
- package/src/Core/Sidebar/Sidebar.tsx +11 -6
- package/src/Core/Sidebar/SidebarContext.tsx +2 -0
- package/src/Core/Sidebar/SidebarDelimeter.tsx +5 -3
- package/src/Core/Sidebar/SidebarItem.tsx +10 -7
- package/src/Theme/themes/dark.ts +9 -0
- package/src/Theme/themes/light.ts +9 -0
- package/src/Theme/types.ts +9 -0
package/package.json
CHANGED
|
@@ -94,12 +94,15 @@ type StyledButtonProps = {
|
|
|
94
94
|
$current?: boolean;
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
const StyledList = styled.div
|
|
97
|
+
const StyledList = styled.div(
|
|
98
|
+
({ theme }) => `
|
|
98
99
|
list-style: none;
|
|
99
100
|
padding: 0;
|
|
100
101
|
display: flex;
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
flex-wrap: wrap;
|
|
103
|
+
gap: ${theme.pagination.gap};
|
|
104
|
+
`
|
|
105
|
+
);
|
|
103
106
|
const Button = styled.button<StyledButtonProps>(
|
|
104
107
|
({ theme, $current }) => `
|
|
105
108
|
font-family: ${theme.typography.fontFamily};
|
|
@@ -107,18 +110,18 @@ const Button = styled.button<StyledButtonProps>(
|
|
|
107
110
|
color: ${$current ? theme.colors.background : theme.colors.text.main};
|
|
108
111
|
border: none;
|
|
109
112
|
cursor: pointer;
|
|
110
|
-
padding-block:
|
|
111
|
-
padding-inline:
|
|
112
|
-
border-radius:
|
|
113
|
-
font-size:
|
|
113
|
+
padding-block: ${theme.pagination.paddingBlock};
|
|
114
|
+
padding-inline: ${theme.pagination.paddingInline};
|
|
115
|
+
border-radius: ${theme.pagination.borderRadius};
|
|
116
|
+
font-size: ${theme.pagination.fontSize};
|
|
114
117
|
font-weight: 400;
|
|
115
118
|
display: flex;
|
|
116
119
|
align-items: center;
|
|
117
120
|
justify-content: center;
|
|
118
|
-
height:
|
|
121
|
+
height: ${theme.pagination.height};
|
|
119
122
|
svg {
|
|
120
|
-
width:
|
|
121
|
-
height:
|
|
123
|
+
width: ${theme.pagination.iconSize};
|
|
124
|
+
height: ${theme.pagination.iconSize};
|
|
122
125
|
}
|
|
123
126
|
&:hover {
|
|
124
127
|
background-color: ${theme.colors.primary.light};
|
|
@@ -126,9 +129,11 @@ const Button = styled.button<StyledButtonProps>(
|
|
|
126
129
|
transition: background-color 0.3s ease-in-out;
|
|
127
130
|
`
|
|
128
131
|
);
|
|
129
|
-
const FlexGroup = styled.div
|
|
132
|
+
const FlexGroup = styled.div(
|
|
133
|
+
({ theme }) => `
|
|
130
134
|
display: flex;
|
|
131
135
|
align-items: center;
|
|
132
136
|
justify-content: flex-end;
|
|
133
|
-
gap:
|
|
134
|
-
|
|
137
|
+
gap: ${theme.pagination.gap};
|
|
138
|
+
`
|
|
139
|
+
);
|
|
@@ -1,35 +1,39 @@
|
|
|
1
1
|
import { styled } from 'styled-components';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { SidebarContext } from './SidebarContext';
|
|
4
|
+
import { createComponent } from '../../Theme';
|
|
4
5
|
|
|
5
6
|
export interface SidebarProps {
|
|
6
7
|
defaultCollapsed?: boolean;
|
|
7
8
|
children: any;
|
|
9
|
+
canGrow: boolean;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
interface StyledProps {
|
|
11
13
|
$collapsed: boolean;
|
|
14
|
+
$canGrow: boolean;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
export const Sidebar = ({ defaultCollapsed, children }
|
|
17
|
+
export const Sidebar = createComponent<SidebarProps>(({ defaultCollapsed, canGrow, children }) => {
|
|
15
18
|
const [collapsed, setCollapsed] = React.useState(!!defaultCollapsed);
|
|
16
19
|
|
|
17
20
|
return (
|
|
18
|
-
<StyledContainer $collapsed={collapsed}>
|
|
21
|
+
<StyledContainer $collapsed={collapsed} $canGrow={canGrow}>
|
|
19
22
|
<SidebarContext.Provider
|
|
20
23
|
value={{
|
|
21
24
|
collapsed,
|
|
22
25
|
setCollapsed,
|
|
26
|
+
canGrow,
|
|
23
27
|
}}
|
|
24
28
|
>
|
|
25
29
|
{children}
|
|
26
30
|
</SidebarContext.Provider>
|
|
27
31
|
</StyledContainer>
|
|
28
32
|
);
|
|
29
|
-
};
|
|
33
|
+
});
|
|
30
34
|
|
|
31
35
|
const StyledContainer = styled.aside<StyledProps>(
|
|
32
|
-
({ theme, $collapsed }) => `
|
|
36
|
+
({ theme, $collapsed, $canGrow }) => `
|
|
33
37
|
display: flex;
|
|
34
38
|
flex-direction: column;
|
|
35
39
|
justify-content: space-between;
|
|
@@ -40,10 +44,11 @@ const StyledContainer = styled.aside<StyledProps>(
|
|
|
40
44
|
width: ${theme.sidebar.width};
|
|
41
45
|
padding: 12px;
|
|
42
46
|
height: 100%;
|
|
47
|
+
overflow: hidden auto;
|
|
43
48
|
border-right: 1px solid ${theme.sidebar.border};
|
|
44
49
|
background: ${theme.sidebar.background};
|
|
45
50
|
${
|
|
46
|
-
$collapsed
|
|
51
|
+
$collapsed || !$canGrow
|
|
47
52
|
? `
|
|
48
53
|
width: 65px;
|
|
49
54
|
`
|
|
@@ -64,7 +69,7 @@ const StyledContainer = styled.aside<StyledProps>(
|
|
|
64
69
|
|
|
65
70
|
width: ${theme.sidebar.width};
|
|
66
71
|
${
|
|
67
|
-
$collapsed
|
|
72
|
+
$collapsed || !$canGrow
|
|
68
73
|
? `
|
|
69
74
|
width: 65px;
|
|
70
75
|
`
|
|
@@ -3,9 +3,11 @@ import { createContext } from 'react';
|
|
|
3
3
|
interface SidebarContext {
|
|
4
4
|
collapsed: boolean;
|
|
5
5
|
setCollapsed: React.Dispatch<React.SetStateAction<boolean>>;
|
|
6
|
+
canGrow: boolean;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
export const SidebarContext = createContext<SidebarContext>({
|
|
9
10
|
collapsed: false,
|
|
10
11
|
setCollapsed: () => {},
|
|
12
|
+
canGrow: false,
|
|
11
13
|
});
|
|
@@ -4,15 +4,16 @@ import { styled } from 'styled-components';
|
|
|
4
4
|
|
|
5
5
|
type StyledProps = {
|
|
6
6
|
$collapsed: boolean;
|
|
7
|
+
$canGrow: boolean;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
export const SidebarDelimeter = () => {
|
|
10
|
-
const { collapsed } = useContext(SidebarContext);
|
|
11
|
-
return <StyledDelimeter $collapsed={collapsed} />;
|
|
11
|
+
const { collapsed, canGrow } = useContext(SidebarContext);
|
|
12
|
+
return <StyledDelimeter $collapsed={collapsed} $canGrow={canGrow} />;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
const StyledDelimeter = styled.div<StyledProps>(
|
|
15
|
-
({ $collapsed, theme }) => `
|
|
16
|
+
({ $collapsed, $canGrow, theme }) => `
|
|
16
17
|
min-width: 32px;
|
|
17
18
|
width: 0;
|
|
18
19
|
|
|
@@ -22,6 +23,7 @@ const StyledDelimeter = styled.div<StyledProps>(
|
|
|
22
23
|
|
|
23
24
|
${
|
|
24
25
|
!$collapsed &&
|
|
26
|
+
$canGrow &&
|
|
25
27
|
`
|
|
26
28
|
& {
|
|
27
29
|
width: 100%;
|
|
@@ -17,6 +17,7 @@ interface SidebarItemAnchor {
|
|
|
17
17
|
type StyledProps = {
|
|
18
18
|
$active: SidebarItemBase['active'];
|
|
19
19
|
$collapsed: boolean;
|
|
20
|
+
$canGrow: boolean;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
interface SidebarItemButton {
|
|
@@ -27,7 +28,7 @@ interface SidebarItemButton {
|
|
|
27
28
|
export type SidebarItemProps = SidebarItemBase & (SidebarItemAnchor | SidebarItemButton);
|
|
28
29
|
|
|
29
30
|
export const SidebarItem = ({ active, icon: Icon, label, ...props }: SidebarItemProps) => {
|
|
30
|
-
const { collapsed } = useContext(SidebarContext);
|
|
31
|
+
const { collapsed, canGrow } = useContext(SidebarContext);
|
|
31
32
|
|
|
32
33
|
const isAnchor = 'href' in props;
|
|
33
34
|
|
|
@@ -37,10 +38,11 @@ export const SidebarItem = ({ active, icon: Icon, label, ...props }: SidebarItem
|
|
|
37
38
|
as={isAnchor ? 'a' : 'button'}
|
|
38
39
|
$collapsed={collapsed}
|
|
39
40
|
$active={active}
|
|
41
|
+
$canGrow={canGrow}
|
|
40
42
|
{...props}
|
|
41
43
|
>
|
|
42
44
|
{Icon && <Icon aria-label={label} width={16} height={16} />}
|
|
43
|
-
<StyledText $collapsed={collapsed} $active={active}>
|
|
45
|
+
<StyledText $collapsed={collapsed} $active={active} $canGrow={canGrow}>
|
|
44
46
|
{label}
|
|
45
47
|
</StyledText>
|
|
46
48
|
</StyledItem>
|
|
@@ -48,7 +50,7 @@ export const SidebarItem = ({ active, icon: Icon, label, ...props }: SidebarItem
|
|
|
48
50
|
};
|
|
49
51
|
|
|
50
52
|
const StyledText = styled.span<StyledProps>(
|
|
51
|
-
({ $collapsed }) => `
|
|
53
|
+
({ $collapsed, $canGrow }) => `
|
|
52
54
|
margin-top: 2px;
|
|
53
55
|
overflow: hidden;
|
|
54
56
|
white-space: nowrap;
|
|
@@ -62,18 +64,19 @@ const StyledText = styled.span<StyledProps>(
|
|
|
62
64
|
font-family: Inter;
|
|
63
65
|
|
|
64
66
|
${
|
|
65
|
-
$collapsed
|
|
66
|
-
|
|
67
|
+
$collapsed || !$canGrow
|
|
68
|
+
? `
|
|
67
69
|
& {
|
|
68
70
|
width: 0;
|
|
69
71
|
}
|
|
70
72
|
`
|
|
73
|
+
: ''
|
|
71
74
|
}
|
|
72
75
|
`
|
|
73
76
|
);
|
|
74
77
|
|
|
75
78
|
const StyledItem = styled.a<StyledProps>(
|
|
76
|
-
({ $active, $collapsed, theme }) => `
|
|
79
|
+
({ $active, $collapsed, $canGrow, theme }) => `
|
|
77
80
|
display: flex;
|
|
78
81
|
align-items: center;
|
|
79
82
|
gap: 12px;
|
|
@@ -96,7 +99,7 @@ const StyledItem = styled.a<StyledProps>(
|
|
|
96
99
|
`
|
|
97
100
|
: ''
|
|
98
101
|
}
|
|
99
|
-
${$collapsed ? `gap: 0;` : ''}
|
|
102
|
+
${$collapsed || !$canGrow ? `gap: 0;` : ''}
|
|
100
103
|
|
|
101
104
|
|
|
102
105
|
|
package/src/Theme/themes/dark.ts
CHANGED
|
@@ -976,6 +976,15 @@ export const darkThemePx: Theme = {
|
|
|
976
976
|
color: '#99989C',
|
|
977
977
|
background: '#1E2226',
|
|
978
978
|
},
|
|
979
|
+
pagination: {
|
|
980
|
+
fontSize: 14,
|
|
981
|
+
paddingBlock: 4,
|
|
982
|
+
paddingInline: 8,
|
|
983
|
+
borderRadius: 3,
|
|
984
|
+
gap: 6,
|
|
985
|
+
height: 26,
|
|
986
|
+
iconSize: 8,
|
|
987
|
+
},
|
|
979
988
|
};
|
|
980
989
|
|
|
981
990
|
export const darkTheme = convertPaletteToRem(darkThemePx, darkThemePx.baseSize) as DefaultTheme;
|
|
@@ -975,6 +975,15 @@ export const lightThemePx: Theme = {
|
|
|
975
975
|
color: '#535353',
|
|
976
976
|
background: '#EBEBEB',
|
|
977
977
|
},
|
|
978
|
+
pagination: {
|
|
979
|
+
fontSize: 14,
|
|
980
|
+
paddingBlock: 4,
|
|
981
|
+
paddingInline: 8,
|
|
982
|
+
borderRadius: 3,
|
|
983
|
+
gap: 6,
|
|
984
|
+
height: 26,
|
|
985
|
+
iconSize: 8,
|
|
986
|
+
},
|
|
978
987
|
};
|
|
979
988
|
|
|
980
989
|
export const lightTheme = convertPaletteToRem(lightThemePx, lightThemePx.baseSize) as DefaultTheme;
|
package/src/Theme/types.ts
CHANGED
|
@@ -319,6 +319,15 @@ export type Theme = {
|
|
|
319
319
|
color: string;
|
|
320
320
|
background: string;
|
|
321
321
|
};
|
|
322
|
+
pagination: {
|
|
323
|
+
fontSize: string | number;
|
|
324
|
+
paddingBlock: string | number;
|
|
325
|
+
paddingInline: string | number;
|
|
326
|
+
borderRadius: string | number;
|
|
327
|
+
gap: string | number;
|
|
328
|
+
height: string | number;
|
|
329
|
+
iconSize: string | number;
|
|
330
|
+
};
|
|
322
331
|
};
|
|
323
332
|
|
|
324
333
|
//TODO check and refactoring
|