@colisweb/rescript-toolkit 2.2.0 → 2.3.0

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": "@colisweb/rescript-toolkit",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "scripts": {
5
5
  "clean": "rescript clean",
6
6
  "build": "rescript build",
@@ -228,6 +228,7 @@ module Make = (Config: RouterConfig) => {
228
228
  ~links: array<link>,
229
229
  ~isNavOpen: bool,
230
230
  ~onLinkClick=() => (),
231
+ ~openMenu,
231
232
  ) => {
232
233
  let (isOpen, setIsOpen) = React.useState(() => false)
233
234
 
@@ -241,7 +242,12 @@ module Make = (Config: RouterConfig) => {
241
242
  }, [isNavOpen])
242
243
 
243
244
  <>
244
- <button onClick=toggle className={cx([commonClassName, "flex items-center w-full"])}>
245
+ <button
246
+ onClick={_ => {
247
+ openMenu()
248
+ toggle()
249
+ }}
250
+ className={cx([commonClassName, "flex items-center w-full"])}>
245
251
  <span className={cx(["mr-2 text-neutral-800", isNavOpen ? "pl-2" : "px-2"])}>
246
252
  groupInfo.icon
247
253
  </span>
@@ -261,6 +267,12 @@ module Make = (Config: RouterConfig) => {
261
267
  ])}
262
268
  />
263
269
  </span>
270
+ {isNavOpen
271
+ ? React.null
272
+ : <div
273
+ className="sidenav-link-tooltip absolute left-0 p-2 bg-neutral-700 text-white rounded transform top-1/2 -translate-y-1/2 transition-all duration-200 ease-in-out opacity-0 invisible ml-16 whitespace-nowrap">
274
+ groupInfo.label
275
+ </div>}
264
276
  </button>
265
277
  <div
266
278
  className={cx([
@@ -84,10 +84,17 @@ module App = {
84
84
  type sideNavRender = {
85
85
  onLinkClick: unit => unit,
86
86
  isNavOpen: bool,
87
+ openMenu: unit => unit,
87
88
  }
88
89
 
89
90
  @react.component
90
- let make = (~isNavOpen, ~bottom=?, ~hideMenu, ~children: sideNavRender => React.element) => {
91
+ let make = (
92
+ ~isNavOpen,
93
+ ~bottom=?,
94
+ ~hideMenu,
95
+ ~children: sideNavRender => React.element,
96
+ ~openMenu,
97
+ ) => {
91
98
  let {isLg} = Toolkit__Hooks.useMediaQuery()
92
99
 
93
100
  let onLinkClick = () => isLg ? () : hideMenu()
@@ -99,17 +106,13 @@ module App = {
99
106
  "lg:flex border-r px-2 py-3 fixed flex-col bg-white justify-between transition-all duration-300 ease-in-out z-40",
100
107
  isNavOpen ? "w-64 overflow-y-auto" : "w-16 hidden sidenav--closed",
101
108
  ])}>
102
- {children({onLinkClick: onLinkClick, isNavOpen: isNavOpen})}
109
+ {children({onLinkClick: onLinkClick, isNavOpen: isNavOpen, openMenu: openMenu})}
103
110
  {bottom->Option.mapWithDefault(React.null, content =>
104
111
  <div className={!isNavOpen ? "overflow-hidden" : ""}>
105
112
  <div
106
113
  className={cx([
107
- "flex flex-col justify-end transition-all duration-300 ease-in-out",
114
+ "flex flex-col justify-end transition-all duration-300 ease-in-out w-[14.75rem]",
108
115
  isNavOpen ? "opacity-100" : "opacity-0",
109
- {
110
- open Css
111
- style(list{width(14.75->rem)})
112
- },
113
116
  ])}>
114
117
  content
115
118
  </div>
@@ -161,12 +164,15 @@ module App = {
161
164
  )
162
165
 
163
166
  let hideMenu = React.useCallback(_ => setOpen(_ => false))
167
+ let openMenu = React.useCallback(_ => setOpen(_ => true))
164
168
 
165
169
  <NavOpenContext.Provider value={isNavOpen}>
166
170
  <div>
167
171
  <TopNavigationBar username logout logoutLabel toggleMenu onLogoClick />
168
172
  <div className="flex">
169
- <LeftNavigationBar isNavOpen ?bottom hideMenu> sideNavRender </LeftNavigationBar>
173
+ <LeftNavigationBar isNavOpen ?bottom hideMenu openMenu>
174
+ {sideNavRender}
175
+ </LeftNavigationBar>
170
176
  <main
171
177
  className={cx([
172
178
  className,