@ainias42/react-bootstrap-mobile 0.1.16 → 0.1.18

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 (34) hide show
  1. package/bin/updateCopies.js +1 -0
  2. package/bootstrapReactMobile.ts +2 -0
  3. package/dist/bootstrapReactMobile.d.ts +2 -0
  4. package/dist/bootstrapReactMobile.js +184 -55
  5. package/dist/bootstrapReactMobile.js.map +1 -1
  6. package/dist/src/Components/Clickable/Clickable.d.ts +5 -3
  7. package/dist/src/Components/DragAndDrop/DragItem.d.ts +1 -1
  8. package/dist/src/Components/Flavor.d.ts +4 -0
  9. package/dist/src/Components/FormElements/Button/Button.d.ts +3 -1
  10. package/dist/src/Components/Icon/DoubleIcon.d.ts +7 -0
  11. package/dist/src/Components/Menu/HoverMenu.d.ts +3 -1
  12. package/dist/src/Components/Menu/Menu.d.ts +1 -0
  13. package/dist/src/Components/Menu/Submenu.d.ts +3 -1
  14. package/dist/src/Components/Text/Text.d.ts +1 -0
  15. package/package.json +1 -1
  16. package/src/Components/Clickable/Clickable.tsx +49 -15
  17. package/src/Components/DragAndDrop/DragItem.tsx +7 -7
  18. package/src/Components/Flavor.ts +4 -0
  19. package/src/Components/FormElements/Button/Button.tsx +19 -9
  20. package/src/Components/FormElements/Input/input.scss +1 -1
  21. package/src/Components/FormElements/SearchSelectInput/seachSelectInput.scss +3 -1
  22. package/src/Components/Icon/DoubleIcon.tsx +34 -0
  23. package/src/Components/Icon/Icon.tsx +13 -10
  24. package/src/Components/Icon/icon.scss +16 -0
  25. package/src/Components/Layout/Grid/grid.scss +28 -22
  26. package/src/Components/Menu/HoverMenu.tsx +17 -6
  27. package/src/Components/Menu/Menu.tsx +47 -24
  28. package/src/Components/Menu/Submenu.tsx +9 -3
  29. package/src/Components/Menu/menu.scss +5 -1
  30. package/src/Components/Text/Text.tsx +1 -0
  31. package/src/Components/Text/text.scss +13 -5
  32. package/src/Components/Toast/toast.scss +1 -0
  33. package/src/scss/_colors.scss +1 -1
  34. package/src/scss/_flavorMixin.scss +8 -1
@@ -10,6 +10,7 @@ import {withRenderBrowserOnly} from '../../helper/withRenderBrowserOnly';
10
10
  import {useWindow} from '../../WindowContext/WindowContext';
11
11
  import {MenuItem} from "./MenuItem";
12
12
  import {MenuCloseContextProvider} from "./MenuCloseContext";
13
+ import {createPortal} from "react-dom";
13
14
 
14
15
  export type MenuItemType = {
15
16
  label: string;
@@ -33,6 +34,8 @@ export type MenuProps = RbmComponentProps<
33
34
  }
34
35
  >;
35
36
 
37
+ export const MENU_CONTAINER_CLASS = "rbm-menu-container";
38
+
36
39
  export const Menu = withMemo(
37
40
  withRenderBrowserOnly(function Menu({
38
41
  className,
@@ -53,6 +56,10 @@ export const Menu = withMemo(
53
56
  const window = useWindow();
54
57
 
55
58
  // States
59
+ const [portalContainer] = useState<HTMLDivElement>(() => {
60
+ return document.createElement('div');
61
+ });
62
+
56
63
  const [innerX, setInnerX] = useState(x);
57
64
  const [innerY, setInnerY] = useState(y);
58
65
 
@@ -74,6 +81,18 @@ export const Menu = withMemo(
74
81
  return undefined;
75
82
  }, [isOpen, onClose, window]);
76
83
 
84
+ useLayoutEffect(() => {
85
+ if (!isOpen) {
86
+ return;
87
+ }
88
+ let elem = window?.document.body.querySelector("." + MENU_CONTAINER_CLASS);
89
+ if (!elem) {
90
+ elem = window?.document.body;
91
+ }
92
+ elem?.appendChild(portalContainer)
93
+ }, [isOpen, portalContainer, window?.document.body]);
94
+
95
+
77
96
  useLayoutEffect(() => {
78
97
  if (!menuRef.current) {
79
98
  return;
@@ -81,7 +100,7 @@ export const Menu = withMemo(
81
100
  const width = parseFloat(getComputedStyle(menuRef.current).width);
82
101
  let newX = x;
83
102
  if (newX > (window?.innerWidth ?? 0) - width) {
84
- newX -= width+offsetX;
103
+ newX -= width + offsetX;
85
104
  }
86
105
 
87
106
  if (newX < 0) {
@@ -98,7 +117,7 @@ export const Menu = withMemo(
98
117
  const height = parseFloat(getComputedStyle(menuRef.current).height);
99
118
  let newY = y;
100
119
  if (newY > (window?.innerHeight ?? 0) - height) {
101
- newY -= height+offsetY;
120
+ newY -= height + offsetY;
102
121
  }
103
122
 
104
123
  if (newY < 0) {
@@ -116,28 +135,32 @@ export const Menu = withMemo(
116
135
  }
117
136
 
118
137
  return (
119
- <MenuCloseContextProvider value={onClose}>
120
- <Block
121
- className={classNames(className, styles.menu)}
122
- style={{...style, top: innerY, left: innerX}}
123
- ref={menuRef}
124
- __allowChildren="all"
125
- >
126
- {items?.map((item) => {
127
- const icon = (!!item.icon && typeof item.icon === "object" && "color" in item.icon) ? item.icon.icon : item.icon;
128
- const iconColor = (!!item.icon && typeof item.icon === "object" && "color" in item.icon) ? item.icon.color : undefined;
129
-
130
- return <MenuItem key={item.key}
131
- onClick={item.callback}
132
- className={classNames(styles.item, item.className)}
133
- onMouseEnter={item.onMouseEnter}
134
- icon={icon}
135
- iconColor={iconColor}
136
- onMouseLeave={item.onMouseLeave}>{item.label}</MenuItem>;
137
- })}
138
- {children}
139
- </Block>
140
- </MenuCloseContextProvider>
138
+ <>
139
+ {createPortal(
140
+ <MenuCloseContextProvider value={onClose}>
141
+ <Block
142
+ className={classNames(className, styles.menu)}
143
+ style={{...style, top: innerY, left: innerX}}
144
+ ref={menuRef}
145
+ __allowChildren="all"
146
+ >
147
+ {items?.map((item) => {
148
+ const icon = (!!item.icon && typeof item.icon === "object" && "color" in item.icon) ? item.icon.icon : item.icon;
149
+ const iconColor = (!!item.icon && typeof item.icon === "object" && "color" in item.icon) ? item.icon.color : undefined;
150
+
151
+ return <MenuItem key={item.key}
152
+ onClick={item.callback}
153
+ className={classNames(styles.item, item.className)}
154
+ onMouseEnter={item.onMouseEnter}
155
+ icon={icon}
156
+ iconColor={iconColor}
157
+ onMouseLeave={item.onMouseLeave}>{item.label}</MenuItem>;
158
+ })}
159
+ {children}
160
+ </Block>
161
+ </MenuCloseContextProvider>
162
+ , portalContainer)}
163
+ </>
141
164
  );
142
165
  }),
143
166
  styles
@@ -17,6 +17,8 @@ export type SubmenuProps = RbmComponentProps<{
17
17
  label: string, icon?: IconSource;
18
18
  iconColor?: string;
19
19
  disabled?: boolean;
20
+ onMouseEnter?: () => void;
21
+ onMouseLeave?: () => void;
20
22
  }, WithNoStringAndChildrenProps>;
21
23
 
22
24
  export const Submenu = withMemo(function Submenu({
@@ -26,7 +28,9 @@ export const Submenu = withMemo(function Submenu({
26
28
  iconColor,
27
29
  className,
28
30
  style,
29
- disabled = false
31
+ disabled = false,
32
+ onMouseEnter,
33
+ onMouseLeave,
30
34
  }: SubmenuProps) {
31
35
  // Refs
32
36
 
@@ -52,11 +56,13 @@ export const Submenu = withMemo(function Submenu({
52
56
  setOpenLeft(right + parseFloat(width) >= (window?.innerWidth ?? 0));
53
57
  setOpenTop(top + parseFloat(height) >= (window?.innerHeight ?? 0));
54
58
  setIsOpen(true);
55
- }, [window?.innerHeight, window?.innerWidth]);
59
+ onMouseEnter?.();
60
+ }, [onMouseEnter, window?.innerHeight, window?.innerWidth]);
56
61
 
57
62
  const closeSubmenu = useCallback(() => {
58
63
  setIsOpen(false);
59
- }, []);
64
+ onMouseLeave?.();
65
+ }, [onMouseLeave]);
60
66
 
61
67
  const closeParent = useMenuClose();
62
68
  const closeAllMenus = useCallback(() => {
@@ -4,6 +4,10 @@
4
4
  border: 1px solid var(--border-light);
5
5
  border-radius: 2px;
6
6
  z-index: 1000;
7
+
8
+ &.hidden {
9
+ visibility: hidden;
10
+ }
7
11
  }
8
12
 
9
13
  .divider {
@@ -33,7 +37,7 @@
33
37
  white-space: nowrap;
34
38
 
35
39
  .icon {
36
- padding-right: 4px;
40
+ margin-right: 4px;
37
41
  }
38
42
  }
39
43
 
@@ -11,6 +11,7 @@ import { ViewProps } from '../Layout/View';
11
11
  export const TEXT_PRIO = {
12
12
  primary: styles.primary,
13
13
  secondary: styles.secondary,
14
+ tertiary: styles.tertiary,
14
15
  heading: styles.heading,
15
16
  };
16
17
 
@@ -1,8 +1,12 @@
1
- $primaryColor: #000000;
2
- $secondaryColor: #717171;
1
+ $primaryColor: #18181B; // Gray-900
2
+ $secondaryColor: #71717a; // Gray-500
3
+ $tertiaryColor: #A1A1AA; // Gray-400
3
4
 
4
5
  :root {
5
- --text-primary-default-color: $primaryColor;
6
+ --text-primary-default-color: #{$primaryColor};
7
+ --text-prmary: #{$primaryColor};
8
+ --text-secondary: #{$secondaryColor};
9
+ --text-tertiary: #{$tertiaryColor};
6
10
  }
7
11
 
8
12
  .text {
@@ -21,11 +25,15 @@ $secondaryColor: #717171;
21
25
  }
22
26
 
23
27
  &.primary {
24
- color: $primaryColor
28
+ color: var(--text-primary)
25
29
  }
26
30
 
27
31
  &.secondary {
28
- color: $secondaryColor;
32
+ color: var(--text-secondary);
33
+ }
34
+
35
+ &.tertiary {
36
+ color: var(--text-tertiary);
29
37
  }
30
38
 
31
39
  &.xsmall {
@@ -18,6 +18,7 @@
18
18
  background-color: rgba(0, 0, 0, 0.8);
19
19
  min-height: 48px;
20
20
  line-height: 1.5;
21
+ --text-primary-default-color: white;
21
22
  color: white;
22
23
  font-size: 0.77rem;
23
24
  letter-spacing: normal;
@@ -1,11 +1,11 @@
1
1
  @include design($material) {
2
2
  --flavor-accent: #37474f;
3
- --flavor-focus: var(--flavor-accent);
4
3
  }
5
4
 
6
5
  :root {
7
6
  --border-light: #cecece;
8
7
  --border-strong: #717171;
8
+ --flavor-basic: #000000
9
9
  }
10
10
 
11
11
  @include design($flat) {
@@ -1,3 +1,10 @@
1
+ @use 'sass:selector';
2
+
1
3
  @mixin flavorSelection($varName) {
2
- #{$varName}: var(--flavor-accent);
4
+ &:global(.flavor-accent) {
5
+ #{$varName}: var(--flavor-accent);
6
+ }
7
+ &:global(.flavor-basic) {
8
+ #{$varName}: var(--flavor-basic);
9
+ }
3
10
  }