nitro-web 0.0.75 → 0.0.76

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.
@@ -6,7 +6,7 @@ import { Strategy as JwtStrategy, ExtractJwt } from 'passport-jwt'
6
6
  import db from 'monastery'
7
7
  import jsonwebtoken from 'jsonwebtoken'
8
8
  import { sendEmail } from 'nitro-web/server'
9
- import { isArray, pick, isString, ucFirst, fullNameSplit } from 'nitro-web/util'
9
+ import { isArray, pick, ucFirst, fullNameSplit } from 'nitro-web/util'
10
10
 
11
11
  let authConfig = null
12
12
  const JWT_SECRET = process.env.JWT_SECRET || 'replace_this_with_secure_env_secret'
@@ -81,51 +81,45 @@ export const Dropdown = forwardRef(function Dropdown({
81
81
 
82
82
  useEffect(() => {
83
83
  setReady(false)
84
- console.log(1111, isActive, dropdownRef.current)
85
84
  if (!isActive || !dropdownRef.current) return
86
85
 
87
- // const ul = dropdownRef.current.querySelector('&>ul') as HTMLElement
88
- // if (!ul) return
89
- // console.log(1111)
86
+ const ul = dropdownRef.current.querySelector('ul') as HTMLElement
87
+ if (!ul) return
90
88
 
91
89
  // Temporarily show the ul for measurement
92
- // const originalMaxHeight = ul.style.maxHeight
93
- // const originalVisibility = ul.style.visibility
94
- // const originalOpacity = ul.style.opacity
95
- // const originalPointerEvents = ul.style.pointerEvents
90
+ const originalMaxHeight = ul.style.maxHeight
91
+ const originalVisibility = ul.style.visibility
92
+ const originalOpacity = ul.style.opacity
93
+ const originalPointerEvents = ul.style.pointerEvents
96
94
 
97
- // ul.style.maxHeight = 'none'
98
- // ul.style.visibility = 'hidden'
99
- // ul.style.opacity = '0'
100
- // ul.style.pointerEvents = 'none'
95
+ ul.style.maxHeight = 'none'
96
+ ul.style.visibility = 'hidden'
97
+ ul.style.opacity = '0'
98
+ ul.style.pointerEvents = 'none'
101
99
 
102
- // const dropdownHeight = ul.getBoundingClientRect().height
100
+ const dropdownHeight = ul.getBoundingClientRect().height
103
101
 
104
102
  // Revert styles
105
- // ul.style.maxHeight = originalMaxHeight
106
- // ul.style.visibility = originalVisibility
107
- // ul.style.opacity = originalOpacity
108
- // ul.style.pointerEvents = originalPointerEvents
103
+ ul.style.maxHeight = originalMaxHeight
104
+ ul.style.visibility = originalVisibility
105
+ ul.style.opacity = originalOpacity
106
+ ul.style.pointerEvents = originalPointerEvents
109
107
 
108
+ const rect = dropdownRef.current.getBoundingClientRect()
109
+ const spaceBelow = window.innerHeight - rect.bottom
110
+ const spaceAbove = rect.top
110
111
 
111
- // const rect = dropdownRef.current.getBoundingClientRect()
112
- // const spaceBelow = window.innerHeight - rect.bottom
113
- // const spaceAbove = rect.top
112
+ const side = dir.endsWith('right') ? 'right' : 'left'
114
113
 
115
- // const side = dir.endsWith('right') ? 'right' : 'left'
114
+ const newDirection = dir.startsWith('bottom')
115
+ ? `${spaceBelow < dropdownHeight && spaceAbove > dropdownHeight ? 'top' : 'bottom'}-${side}`
116
+ : `${spaceAbove < dropdownHeight && spaceBelow > dropdownHeight ? 'bottom' : 'top'}-${side}`
116
117
 
117
- // const newDirection = dir.startsWith('bottom')
118
- // ? `${1 < 1 && 1 > 1 ? 'top' : 'bottom'}-${side}`
119
- // : `${1 < 1 && 1 > 1 ? 'bottom' : 'top'}-${side}`
118
+ setDirection(newDirection as 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right')
120
119
 
121
- // setDirection(dir as 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right')
122
-
123
- // requestAnimationFrame(() => {
124
- // // console.log('ul', originalOpacity)
125
- // setReady(true)
126
- // })
127
- setDirection(dir)
128
- setReady(true)
120
+ requestAnimationFrame(() => {
121
+ setReady(true)
122
+ })
129
123
  }, [isActive, dir])
130
124
 
131
125
  function onMouseDown(e: { key: string, preventDefault: Function }) {
@@ -138,12 +132,13 @@ export const Dropdown = forwardRef(function Dropdown({
138
132
  if (option.onClick) option.onClick(e)
139
133
  if (!menuIsOpen) setIsActive(!isActive)
140
134
  }
135
+ var ready2
141
136
 
142
137
  return (
143
138
  <div
144
139
  class={
145
140
  `relative is-${direction || dir}` + // until hovered, show the original direction to prevent scrollbars
146
- (ready ? ' is-ready' : '') +
141
+ (ready2 ? ' is-ready' : '') +
147
142
  (isHoverable ? ' is-hoverable' : '') +
148
143
  (isActive ? ' is-active' : '') +
149
144
  (!animate ? ' no-animation' : '') +
@@ -165,7 +160,7 @@ export const Dropdown = forwardRef(function Dropdown({
165
160
  <ul
166
161
  style={{ minWidth }}
167
162
  class={
168
- twMerge(`${menuStyle} absolute invisible opacity-0 select-none min-w-full z-[1] ${menuClassName||''}`)}
163
+ twMerge(`${menuStyle} ${ready ? 'is-ready' : ''} absolute invisible opacity-0 select-none min-w-full z-[1] ${menuClassName||''}`)}
169
164
  >
170
165
  {menuContent}
171
166
  {
@@ -198,7 +193,7 @@ const style = css`
198
193
  }
199
194
  &.is-bottom-right,
200
195
  &.is-top-right {
201
- &>ul {
196
+ ul {
202
197
  left: auto;
203
198
  right: 0;
204
199
  }
@@ -218,14 +213,13 @@ const style = css`
218
213
  }
219
214
  }
220
215
  // active submenu
221
- &./////////////
222
216
  &.is-hoverable:hover,
223
217
  &:focus,
224
218
  &.is-active,
225
219
  &>ul>li:hover,
226
220
  &>ul>li:focus,
227
221
  &>ul>li.is-active {
228
- &>ul {
222
+ &>ul.is-ready {
229
223
  opacity: 1;
230
224
  visibility: visible;
231
225
  transition: transform 0.15s ease, opacity 0.15s ease;
@@ -119,10 +119,9 @@ export const Filters = forwardRef<FiltersHandleType, FiltersProps>(({
119
119
 
120
120
  return (
121
121
  <Elements.Dropdown
122
- // menuIsOpen={true}
123
- className='ddddddddd'
124
122
  dir="bottom-right"
125
123
  allowOverflow={true}
124
+ // menuIsOpen={true}
126
125
  {...dropdownProps}
127
126
  menuClassName={twMerge(`min-w-[330px] ${dropdownProps?.menuClassName || ''}`)}
128
127
  menuContent={
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-web",
3
- "version": "0.0.75",
3
+ "version": "0.0.76",
4
4
  "repository": "github:boycce/nitro-web",
5
5
  "homepage": "https://boycce.github.io/nitro-web/",
6
6
  "description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",
@@ -1,6 +1,6 @@
1
1
  <!--
2
- - You can view templates at http://localhost:3001/email/reset-password
3
- - To modify the css, add your own /server/email/partials/email.css file
2
+ - You can view templates at http://localhost:3000/email/reset-password
3
+ - To modify the css, add your own ./server/email/partials/email.css file
4
4
  - You can copy any nitro email .swig/html template to your project, and modify it
5
5
  -->
6
6
 
@@ -1,6 +1,6 @@
1
1
  <!--
2
- - You can view templates at http://localhost:3001/email/welcome
3
- - To modify the css, add your own /server/email/partials/email.css file
2
+ - You can view templates at http://localhost:3000/email/welcome
3
+ - To modify the css, add your own ./server/email/partials/email.css file
4
4
  - You can copy any nitro email .swig/html template to your project, and modify it
5
5
  -->
6
6
 
package/server/router.js CHANGED
@@ -98,7 +98,8 @@ export async function setupRouter (config) {
98
98
  let indexExists = !!fs.existsSync(distDir + 'index.html')
99
99
 
100
100
  // Register email routes for development
101
- // E.g. http://localhost:3001/email/welcome
101
+ // E.g. http://localhost:3001/email/welcome Or
102
+ // E.g. http://localhost:3000/email/welcome (with webpack-dev-server proxy)
102
103
  if (env == 'development') {
103
104
  expressApp.get('/email/partials/email.css', (req, res) => {
104
105
  // first check if there is a custom email.css in the emailTemplateDir