nitro-web 0.0.75 → 0.0.77

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={
@@ -54,6 +54,7 @@ export function Checkbox({
54
54
  ? <>
55
55
  <input
56
56
  {...props}
57
+ id={id}
57
58
  type={type}
58
59
  style={{ width: checkboxSize, height: checkboxSize }}
59
60
  checked={value}
@@ -106,6 +107,7 @@ export function Checkbox({
106
107
  : <>
107
108
  <input
108
109
  {...props}
110
+ id={id}
109
111
  type="checkbox"
110
112
  className="sr-only peer"
111
113
  checked={value}
@@ -200,22 +200,22 @@ export function Styleguide({ className, elements, children }: StyleguideProps) {
200
200
  <div><Button size="xs" IconCenter={<FileEditIcon size={14}/>}></Button></div>
201
201
  </div>
202
202
 
203
- <h2 class="h3">Checkboxes</h2>
203
+ <h2 class="h3">Varients</h2>
204
204
  <div class="grid grid-cols-3 gap-x-6 mb-4">
205
205
  <div>
206
- <label for="input2">Label</label>
206
+ <label for="input2">Toggles</label>
207
207
  <Checkbox name="input2" type="toggle" text="Toggle sm" subtext="some additional text here." class="!mb-0"
208
208
  state={state} onChange={(e) => onChange(setState, e)} />
209
209
  <Checkbox name="input3" type="toggle" text="Toggle 22px" subtext="some additional text here." size={22} />
210
210
  </div>
211
211
  <div>
212
- <label for="input1">Label</label>
212
+ <label for="input1">Radios</label>
213
213
  <Checkbox name="input1" type="radio" text="Radio" subtext="some additional text here 1." id="input1-1" class="!mb-0"
214
214
  defaultChecked />
215
215
  <Checkbox name="input1" type="radio" text="Radio 16px" subtext="some additional text here 2." id="input1-2" size={16} />
216
216
  </div>
217
217
  <div>
218
- <label for="input0">Label</label>
218
+ <label for="input0">Checkboxes</label>
219
219
  <Checkbox name="input0" type="checkbox" text="Checkbox" subtext="some additional text here." class="!mb-0" defaultChecked />
220
220
  <Checkbox name="input0.1" type="checkbox" text="Checkbox 16px" size={16}
221
221
  subtext="some additional text here which is a bit longer that will be line-wrap to the next line." />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-web",
3
- "version": "0.0.75",
3
+ "version": "0.0.77",
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