nitro-web 0.0.78 → 0.0.79
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.
|
@@ -35,8 +35,8 @@ export function Signup() {
|
|
|
35
35
|
<Field name="name" placeholder="E.g. Bruce Wayne" state={state} onChange={(e) => onChange(setState, e)} />
|
|
36
36
|
</div>
|
|
37
37
|
<div>
|
|
38
|
-
<label for="
|
|
39
|
-
<Field name="
|
|
38
|
+
<label for="business.name">Company Name</label>
|
|
39
|
+
<Field name="business.name" placeholder="E.g. Wayne Enterprises" state={state} onChange={(e) => onChange(setState, e)} />
|
|
40
40
|
</div>
|
|
41
41
|
</div>
|
|
42
42
|
<div>
|
|
@@ -4,12 +4,16 @@ import { X, CircleCheck } from 'lucide-react'
|
|
|
4
4
|
import { MessageObject } from 'nitro-web/types'
|
|
5
5
|
import { twMerge } from 'nitro-web'
|
|
6
6
|
|
|
7
|
+
type MessageProps = {
|
|
8
|
+
className?: string
|
|
9
|
+
classNameWrapper?: string
|
|
10
|
+
position?: 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'
|
|
11
|
+
}
|
|
7
12
|
/**
|
|
8
13
|
* Shows a message
|
|
9
|
-
* Triggered by navigating to a link with a valid query string, or
|
|
10
|
-
* by setting store.message to a string or more explicitly, to an object
|
|
14
|
+
* Triggered by navigating to a link with a valid query string, or by setting store.message to a string or more explicitly, to an object
|
|
11
15
|
**/
|
|
12
|
-
export function Message({ className }:
|
|
16
|
+
export function Message({ className, classNameWrapper, position='top-right' }: MessageProps) {
|
|
13
17
|
const devDontHide = false
|
|
14
18
|
const [store, setStore] = useTracked()
|
|
15
19
|
const [visible, setVisible] = useState(false)
|
|
@@ -30,7 +34,16 @@ export function Message({ className }: { className?: string }) {
|
|
|
30
34
|
'info': 'text-info',
|
|
31
35
|
'success': 'text-success',
|
|
32
36
|
}
|
|
37
|
+
const positionMap = {
|
|
38
|
+
'top-left': ['sm:items-start sm:justify-start', 'sm:translate-y-0 sm:translate-x-[-0.5rem]'],
|
|
39
|
+
'top-center': ['sm:items-start sm:justify-center', 'sm:translate-y-[-0.5rem]'],
|
|
40
|
+
'top-right': ['sm:items-start sm:justify-end', 'sm:translate-y-0 sm:translate-x-1'],
|
|
41
|
+
'bottom-left': ['sm:items-end sm:justify-start', 'sm:translate-y-0 sm:translate-x-[-0.5rem]'],
|
|
42
|
+
'bottom-center': ['sm:items-end sm:justify-center', 'sm:translate-y-1'],
|
|
43
|
+
'bottom-right': ['sm:items-end sm:justify-end', 'sm:translate-y-0 sm:translate-x-1'],
|
|
44
|
+
}
|
|
33
45
|
const color = colorMap[(store.message as MessageObject)?.type || 'success']
|
|
46
|
+
const positionArr = positionMap[(position as keyof typeof positionMap)]
|
|
34
47
|
|
|
35
48
|
useEffect(() => {
|
|
36
49
|
return () => {
|
|
@@ -82,29 +95,29 @@ export function Message({ className }: { className?: string }) {
|
|
|
82
95
|
setVisible(false)
|
|
83
96
|
setTimeout(() => setStore(s => ({ ...s, message: undefined })), 250)
|
|
84
97
|
}
|
|
85
|
-
|
|
98
|
+
|
|
86
99
|
return (
|
|
87
100
|
<>
|
|
88
101
|
{/* Global notification live region, render this permanently at the end of the document */}
|
|
89
102
|
<div
|
|
90
103
|
aria-live="assertive"
|
|
91
|
-
className={`${twMerge(`pointer-events-none fixed inset-0 flex
|
|
104
|
+
className={`${twMerge(`pointer-events-none items-end justify-center fixed inset-0 flex px-4 py-6 sm:p-6 z-[101] nitro-message ${positionArr[0]} ${classNameWrapper || ''}`)}`}
|
|
92
105
|
>
|
|
93
|
-
<div className="flex
|
|
106
|
+
<div className="flex flex-col items-center space-y-4">
|
|
94
107
|
{isObject(store.message) && (
|
|
95
|
-
<div className={
|
|
96
|
-
'overflow-hidden pointer-events-auto max-w-[350px] rounded-md bg-white shadow-lg ring-1 ring-black/5 transition '
|
|
97
|
-
|
|
98
|
-
|
|
108
|
+
<div className={twMerge(
|
|
109
|
+
'overflow-hidden translate-y-[0.5rem] opacity-0 pointer-events-auto max-w-[350px] rounded-md bg-white shadow-lg ring-1 ring-black/5 transition text-sm font-medium text-gray-900',
|
|
110
|
+
positionArr[1],
|
|
111
|
+
(visible ? 'translate-x-0 translate-y-0 sm:translate-x-0 sm:translate-y-0 opacity-100' : ''),
|
|
112
|
+
className
|
|
113
|
+
)}>
|
|
99
114
|
<div className="p-3">
|
|
100
|
-
<div className="flex items-start gap-3
|
|
115
|
+
<div className="flex items-start gap-3 leading-[1.4em]">
|
|
101
116
|
<div className="flex items-center shrink-0 min-h-[1.4em]">
|
|
102
117
|
<CircleCheck aria-hidden="true" size={19} className={`${color}`} />
|
|
103
118
|
</div>
|
|
104
119
|
<div className="flex flex-1 items-center min-h-[1.4em]">
|
|
105
|
-
<p
|
|
106
|
-
</p>
|
|
107
|
-
{/* <p className="mt-1 text-sm text-gray-500">{store.message.text}</p> */}
|
|
120
|
+
<p>{typeof store.message === 'object' && store.message?.text}</p>
|
|
108
121
|
</div>
|
|
109
122
|
<div className="flex items-center shrink-0 min-h-[1.4em]">
|
|
110
123
|
<button
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.79",
|
|
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 🚀",
|