@jetbrains/kotlin-web-site-ui 4.4.0-alpha.4 → 4.4.0-alpha.5

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.
@@ -137,7 +137,8 @@
137
137
  }
138
138
 
139
139
  .ktl-vertical-menu-module_dropdown-header_77lTy {
140
- margin-top: 0;
140
+ /* workaround */
141
+ margin-top: calc(var(--ktl-header-height-mobile) * -1);
141
142
  display: flex;
142
143
  color: #ffffff;
143
144
  align-items: center;
@@ -150,8 +151,7 @@
150
151
  }
151
152
 
152
153
  .ktl-vertical-menu-module_sticky-header_BlLzL {
153
- /* workaround */
154
- margin-top: calc(var(--ktl-header-height-mobile) * -1);
154
+ margin-top: 0;
155
155
  }
156
156
 
157
157
  .ktl-vertical-menu-module_dropdown-list_N3KWV {
@@ -31,11 +31,8 @@ const VerticalMenu = ({
31
31
  const activeItem = _items[_activeIndex];
32
32
  const [isExpanded, setIsExpanded] = useState(false);
33
33
  const [portalRoot, setPortalRoot] = useState(null);
34
- const [isTopMenuSticky, setIsTopMenuSticky] = useState(false);
35
34
  const handleOpen = useCallback(() => {
36
35
  setIsExpanded(true);
37
- const topMenuTopOffset = topMenuRef?.current?.getBoundingClientRect().top;
38
- setIsTopMenuSticky(topMenuTopOffset === 0);
39
36
  }, []);
40
37
  const handleClose = useCallback(() => {
41
38
  setIsExpanded(false);
@@ -65,8 +62,7 @@ const VerticalMenu = ({
65
62
  items: _items,
66
63
  onClose: handleClose,
67
64
  linkHandler: linkHandler,
68
- topMenuRef: topMenuRef,
69
- isSticky: isTopMenuSticky
65
+ topMenuRef: topMenuRef
70
66
  }), portalRoot)));
71
67
  };
72
68
 
@@ -76,14 +72,20 @@ const VerticalMenuDropDown = ({
76
72
  items,
77
73
  linkHandler,
78
74
  activeIndex,
79
- topMenuRef,
80
- isSticky
75
+ topMenuRef
81
76
  }) => {
82
77
  const textCn = useTextStyles();
83
78
  const theme = useTheme();
84
79
  const navRef = useRef(null);
85
80
  const [navStyle, setNavStyle] = useState({});
81
+ const [topMenuSticky, setTopMenuSticky] = useState(false);
86
82
  useEffect(() => {
83
+ const topMenuTopOffset = topMenuRef?.current?.getBoundingClientRect().top;
84
+
85
+ if (topMenuTopOffset !== undefined) {
86
+ setTopMenuSticky(topMenuTopOffset === 0);
87
+ }
88
+
87
89
  if (navRef.current) {
88
90
  disableBodyScroll(navRef.current);
89
91
  }
@@ -105,7 +107,7 @@ const VerticalMenuDropDown = ({
105
107
  })
106
108
  }, React__default.createElement("div", {
107
109
  className: classNames(styles.dropdownHeader, {
108
- [styles.stickyHeader]: !isSticky
110
+ [styles.stickyHeader]: topMenuSticky
109
111
  })
110
112
  }, React__default.createElement("div", {
111
113
  className: textCn('rs-text-2')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jetbrains/kotlin-web-site-ui",
3
3
  "description": "UI components for Kotlin web sites development",
4
- "version": "4.4.0-alpha.4",
4
+ "version": "4.4.0-alpha.5",
5
5
  "license": "Apache-2.0",
6
6
  "author": "JetBrains",
7
7
  "files": [