@cyber-harbour/ui 1.0.35 → 1.0.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cyber-harbour/ui",
3
- "version": "1.0.35",
3
+ "version": "1.0.36",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -20,7 +20,7 @@ const StyledContainer = styled.header(
20
20
  padding-right: 20px;
21
21
  height: 56px;
22
22
  background-color: ${theme.colors.background};
23
- border-bottom: 1px solid ${theme.colors.stroke.main};
23
+ border-bottom: 1px solid ${theme.colors.stroke.light};
24
24
 
25
25
  &:before {
26
26
  content: '';
@@ -40,8 +40,8 @@ const StyledContainer = styled.aside<StyledProps>(
40
40
  width: ${theme.sidebar.width};
41
41
  padding: 12px;
42
42
  height: 100%;
43
- border-right: 1px solid ${theme.colors.stroke.light};
44
- background: ${theme.colors.background};
43
+ border-right: 1px solid ${theme.sidebar.border};
44
+ background: ${theme.sidebar.background};
45
45
  ${
46
46
  $collapsed
47
47
  ? `
@@ -60,7 +60,7 @@ const StyledContainer = styled.aside<StyledProps>(
60
60
  height: 25dvh;
61
61
  transform: translateY(-100%);
62
62
  background: ${theme.colors.background};
63
- border-right: 1px solid ${theme.colors.stroke.light};
63
+ border-right: 1px solid ${theme.sidebar.border};
64
64
 
65
65
  width: ${theme.sidebar.width};
66
66
  ${
@@ -16,7 +16,7 @@ const StyledDelimeter = styled.div<StyledProps>(
16
16
  min-width: 32px;
17
17
  width: 0;
18
18
 
19
- border-bottom: 1px dashed ${theme.colors.stroke.main};
19
+ border-bottom: 1px dashed ${theme.sidebar.delimeter.color};
20
20
  margin-block: 8px;
21
21
  margin-left: 4px;
22
22
 
@@ -2,7 +2,7 @@ import ForceGraph2D, { ForceGraphMethods, LinkObject, NodeObject } from 'react-f
2
2
  import { Graph2DProps } from './types';
3
3
  import { useEffect, useRef, useState, useCallback, useLayoutEffect } from 'react';
4
4
  import { forceCollide } from 'd3-force';
5
- import { styled } from 'styled-components';
5
+ import { styled, useTheme } from 'styled-components';
6
6
  import eyeLightIcon from './eye_light.png';
7
7
  import eyeLightHoverIcon from './eye_light_hover.png';
8
8
  import groupLightIcon from './group_light.png';
@@ -44,6 +44,8 @@ export const Graph2D = ({
44
44
  onLinkClick,
45
45
  onBackgroundClick,
46
46
  }: Graph2DProps) => {
47
+ const theme = useTheme();
48
+
47
49
  // Стан для підсвічування вузлів і зв'язків
48
50
  const [highlightNodes, setHighlightNodes] = useState(new Set());
49
51
  const [highlightLinks, setHighlightLinks] = useState(new Set());
@@ -227,7 +229,7 @@ export const Graph2D = ({
227
229
  // Малюємо кільце навколо вузла
228
230
  ctx.beginPath();
229
231
  ctx.arc(node.x, node.y, radius, 0, 2 * Math.PI, false);
230
- ctx.fillStyle = 'rgba(255, 165, 0, 0.3)';
232
+ ctx.fillStyle = theme.graph2D.ring.highlightFill;
231
233
  ctx.fill();
232
234
  },
233
235
  [config]
@@ -246,9 +248,9 @@ export const Graph2D = ({
246
248
  ctx.beginPath();
247
249
  ctx.arc(x, y, buttonRadius, Math.PI, Math.PI * 2, false);
248
250
  ctx.lineWidth = 1;
249
- ctx.strokeStyle = '#e5e5e5';
251
+ ctx.strokeStyle = theme.graph2D.button.stroke;
250
252
  ctx.stroke();
251
- ctx.fillStyle = hoverTopButton ? 'rgba(230, 230, 230, 0.9)' : 'rgba(255, 255, 255, 0.8)';
253
+ ctx.fillStyle = hoverTopButton ? theme.graph2D.button.hoverFill : theme.graph2D.button.normalFill;
252
254
  ctx.fill();
253
255
 
254
256
  // Лінія розділення між кнопками
@@ -256,16 +258,16 @@ export const Graph2D = ({
256
258
  ctx.moveTo(x - buttonRadius, y);
257
259
  ctx.lineTo(x + buttonRadius, y);
258
260
  ctx.lineWidth = 1;
259
- ctx.strokeStyle = '#e5e5e5';
261
+ ctx.strokeStyle = theme.graph2D.button.stroke;
260
262
  ctx.stroke();
261
263
 
262
264
  // Кнопка "згорнути" (нижня частина кільця)
263
265
  ctx.beginPath();
264
266
  ctx.arc(x, y, buttonRadius, Math.PI * 2, Math.PI, false);
265
267
  ctx.lineWidth = 1;
266
- ctx.strokeStyle = '#e5e5e5';
268
+ ctx.strokeStyle = theme.graph2D.button.stroke;
267
269
  ctx.stroke();
268
- ctx.fillStyle = hoverBottomButton ? 'rgba(230, 230, 230, 0.9)' : 'rgba(255, 255, 255, 0.8)';
270
+ ctx.fillStyle = hoverBottomButton ? theme.graph2D.button.hoverFill : theme.graph2D.button.normalFill;
269
271
  ctx.fill();
270
272
 
271
273
  // Додаємо іконку хрестика для кнопки "сховати вузол"
@@ -571,7 +573,7 @@ export const Graph2D = ({
571
573
  const gridSpacing = config.gridSpacing;
572
574
  const dotSize = config.dotSize;
573
575
 
574
- ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';
576
+ ctx.fillStyle = theme.graph2D.grid.dotColor;
575
577
 
576
578
  for (let x = 0; x < width; x += gridSpacing) {
577
579
  for (let y = 0; y < height; y += gridSpacing) {
@@ -690,7 +692,7 @@ export const Graph2D = ({
690
692
  };
691
693
 
692
694
  // Малюємо лінію зв'язку з урахуванням місця для тексту, якщо він є
693
- const lineColor = highlightLinks.has(link) ? '#ff9900' : '#999';
695
+ const lineColor = highlightLinks.has(link) ? theme.graph2D.link.highlighted : theme.graph2D.link.normal;
694
696
  const lineWidth = highlightLinks.has(link) ? 1.5 : 0.5;
695
697
 
696
698
  if (label) {
@@ -763,7 +765,7 @@ export const Graph2D = ({
763
765
  ctx.lineTo(-arrowHeadLength, -arrowHeadWidth);
764
766
  ctx.closePath();
765
767
 
766
- ctx.fillStyle = highlightLinks.has(link) ? '#ff9900' : '#999';
768
+ ctx.fillStyle = highlightLinks.has(link) ? theme.graph2D.link.highlighted : theme.graph2D.link.normal;
767
769
  ctx.fill();
768
770
  ctx.restore();
769
771
 
@@ -777,7 +779,7 @@ export const Graph2D = ({
777
779
  // Використовуємо реверсивне масштабування для тексту
778
780
  const scaledFontSize = calculateFontSize(globalScale);
779
781
  ctx.font = `${scaledFontSize}px Sans-Serif`;
780
- ctx.fillStyle = '#666'; // Колір тексту
782
+ ctx.fillStyle = theme.graph2D.link.textColor; // Колір тексту
781
783
  ctx.textAlign = 'center';
782
784
  ctx.textBaseline = 'middle';
783
785
 
@@ -797,7 +799,9 @@ export const Graph2D = ({
797
799
  // Рисуємо фон для тексту для кращої читаємості
798
800
  const textWidth = ctx.measureText(label).width;
799
801
  const padding = 2;
800
- ctx.fillStyle = highlightLinks.has(link) ? 'rgba(255, 230, 204, 0.9)' : 'rgba(255, 255, 255, 0.8)';
802
+ ctx.fillStyle = highlightLinks.has(link)
803
+ ? theme.graph2D.link.highlightedTextBgColor
804
+ : theme.graph2D.link.textBgColor;
801
805
  ctx.fillRect(
802
806
  -textWidth / 2 - padding,
803
807
  -scaledFontSize / 2 - padding,
@@ -806,7 +810,7 @@ export const Graph2D = ({
806
810
  );
807
811
 
808
812
  // Малюємо текст
809
- ctx.fillStyle = highlightLinks.has(link) ? '#663300' : '#666';
813
+ ctx.fillStyle = highlightLinks.has(link) ? theme.graph2D.link.highlightedTextColor : theme.graph2D.link.textColor;
810
814
  ctx.fillText(label, 0, 0);
811
815
 
812
816
  // Відновлення стану контексту
@@ -945,7 +949,9 @@ export const Graph2D = ({
945
949
  d3AlphaDecay={0.038}
946
950
  // Виділення зв'язків при наведенні
947
951
  linkWidth={(link: any) => (highlightLinks.has(link) ? 3 : 1)}
948
- linkColor={(link: any) => (highlightLinks.has(link) ? '#ff9900' : '#999')}
952
+ linkColor={(link: any) =>
953
+ highlightLinks.has(link) ? theme.graph2D.link.highlighted : theme.graph2D.link.normal
954
+ }
949
955
  onRenderFramePre={renderGrid}
950
956
  nodePointerAreaPaint={renderNodePointerAreaPaint}
951
957
  nodeCanvasObject={renderNodeCanvasObject}
@@ -54,6 +54,9 @@ export const StyledContainer = styled.div<StyledContainerProps>(
54
54
  `
55
55
  );
56
56
 
57
- const StyledMain = styled.main`
58
- min-width: 0;
59
- `;
57
+ const StyledMain = styled.main(
58
+ ({ theme }) => `
59
+ min-width: 0;
60
+ background: ${theme.colors.backgroundBase};
61
+ `
62
+ );
@@ -1,11 +1,17 @@
1
1
  import { StyleSheetManager, ThemeProvider as ThemeProviderStyled, WebTarget } from 'styled-components';
2
- import { lightTheme } from './theme';
2
+ import { lightTheme, darkTheme } from './themes';
3
3
  import { GlobalStyle } from './GlobalStyle';
4
4
 
5
- export const ThemeProvider = ({ children }: { children: any }) => {
5
+ interface ThemeProviderProps {
6
+ children: any;
7
+ mode?: 'light' | 'LIGHT' | 'dark' | 'DARK';
8
+ }
9
+
10
+ export type ThemeMode = 'light' | 'LIGHT' | 'dark' | 'DARK';
11
+ export const ThemeProvider = ({ children, mode }: ThemeProviderProps) => {
6
12
  return (
7
13
  <StyleSheetManager shouldForwardProp={shouldForwardProp}>
8
- <ThemeProviderStyled theme={lightTheme}>
14
+ <ThemeProviderStyled theme={mode == 'light' || mode === 'LIGHT' ? lightTheme : darkTheme}>
9
15
  <GlobalStyle />
10
16
  {children}
11
17
  </ThemeProviderStyled>
@@ -2,5 +2,5 @@ export * from './GlobalStyle';
2
2
  export * from './ThemeProvider';
3
3
  export * from './utils';
4
4
  export * from './types';
5
- export * from './theme';
5
+ export * from './themes';
6
6
  export * from './componentFabric';
@@ -0,0 +1,41 @@
1
+ // Індексні шари (z-index) для різних компонентів
2
+ export const zIndex = {
3
+ dropdown: 1000,
4
+ sticky: 1020,
5
+ fixed: 1030,
6
+ backdrop: 1040,
7
+ modal: 1050,
8
+ popover: 1060,
9
+ tooltip: 1070,
10
+ };
11
+
12
+ // Розміри брейкпоінтів
13
+ export const breakpoints = {
14
+ xs: 320,
15
+ s: 576,
16
+ m: 768,
17
+ l: 992,
18
+ xl: 1200,
19
+ };
20
+
21
+ // Типографія
22
+ export const typography = {
23
+ fontFamily:
24
+ 'Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;',
25
+ lineHeight: 1.49,
26
+ // Розміри текстових елементів
27
+ variants: {
28
+ h1: {
29
+ fontSize: 22,
30
+ },
31
+ h2: {
32
+ fontSize: 16,
33
+ },
34
+ h3: {
35
+ fontSize: 14,
36
+ },
37
+ body: {
38
+ fontSize: 12,
39
+ },
40
+ },
41
+ };