@sikka/hawa 0.0.240 → 0.0.241
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/dist/styles.css +25 -1
- package/docs/documentation/{901.ae81c179.iframe.bundle.js → 566.80f3d604.iframe.bundle.js} +2 -2
- package/docs/documentation/{807.1424ceed.iframe.bundle.js → 807.b81f7e21.iframe.bundle.js} +2 -2
- package/docs/documentation/iframe.html +1 -1
- package/docs/documentation/main.3c9bbcb1.iframe.bundle.js +1 -0
- package/docs/documentation/project.json +1 -1
- package/docs/documentation/{runtime~main.d6831407.iframe.bundle.js → runtime~main.d1d3f3a0.iframe.bundle.js} +1 -1
- package/es/elements/BackToTop.d.ts +10 -0
- package/es/elements/index.d.ts +1 -0
- package/es/index.es.js +2 -2
- package/lib/elements/BackToTop.d.ts +10 -0
- package/lib/elements/index.d.ts +1 -0
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/src/elements/BackToTop.tsx +85 -0
- package/src/elements/index.ts +1 -0
- package/src/styles.css +25 -1
- package/docs/documentation/main.1d8c7d46.iframe.bundle.js +0 -1
- /package/docs/documentation/{901.ae81c179.iframe.bundle.js.LICENSE.txt → 566.80f3d604.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/docs/documentation/{807.1424ceed.iframe.bundle.js.LICENSE.txt → 807.b81f7e21.iframe.bundle.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { FunctionComponent, ReactNode, useState, useEffect } from "react"
|
|
2
|
+
import { clsx } from "clsx"
|
|
3
|
+
|
|
4
|
+
type ComponentTypes = {
|
|
5
|
+
paddingX?: number // Horizontal padding relative to the attached corner
|
|
6
|
+
paddingY?: number // Vertical padding relative to the attached corner
|
|
7
|
+
paddingThreshold?: number // Increase to the threshold of the scroll value that has to be passed for the button to appear
|
|
8
|
+
corner?: "top-left" | "top-right" | "bottom-left" | "bottom-right"
|
|
9
|
+
anchor: React.RefObject<HTMLInputElement>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const BackToTop: FunctionComponent<ComponentTypes> = ({ ...props }) => {
|
|
13
|
+
const [visible, setVisible] = useState<boolean>(false)
|
|
14
|
+
|
|
15
|
+
const getCoords = () => {
|
|
16
|
+
let anchor = props.anchor.current
|
|
17
|
+
return [anchor.scrollTop, anchor.scrollLeft]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const onScroll = () => {
|
|
21
|
+
let [scrollTop, scrollLeft] = getCoords()
|
|
22
|
+
|
|
23
|
+
let rect = props.anchor.current.getBoundingClientRect()
|
|
24
|
+
|
|
25
|
+
setVisible(scrollTop >= rect.height + (props.paddingThreshold || 100))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const backToTop = () => {
|
|
29
|
+
props.anchor.current.scrollTo(0, 0)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
props.anchor.current.addEventListener("scroll", onScroll)
|
|
34
|
+
|
|
35
|
+
return () => {
|
|
36
|
+
props.anchor.current.removeEventListener("scroll", onScroll)
|
|
37
|
+
}
|
|
38
|
+
}, [])
|
|
39
|
+
|
|
40
|
+
// // Reference to tailwind classes of corners
|
|
41
|
+
// const corners = {
|
|
42
|
+
// "top-left": ["top-0 left-0", "ml", "mt"],
|
|
43
|
+
// "top-right": ["top-0 right-0", "mr", "mt"],
|
|
44
|
+
// "bottom-left": ["bottom-0 left-0", "ml", "mb"],
|
|
45
|
+
// "bottom-right": ["bottom-0 right-0", "mr", "mb"],
|
|
46
|
+
// }
|
|
47
|
+
|
|
48
|
+
// const getClasses = () => {
|
|
49
|
+
// let [corner, horizontal, vertical] = corners[props.corner || "bottom-right"]
|
|
50
|
+
|
|
51
|
+
// return clsx(
|
|
52
|
+
// `${horizontal}-[${props.paddingX || 100}px]`,
|
|
53
|
+
// `${vertical}-[${props.paddingY || 0}px]`,
|
|
54
|
+
// `${corner}`,
|
|
55
|
+
// `${visible ? "block" : "hidden"}`
|
|
56
|
+
// )
|
|
57
|
+
// }
|
|
58
|
+
|
|
59
|
+
// Had to use react styles because tailwind didn't update top & left
|
|
60
|
+
const getStyles = () => {
|
|
61
|
+
let corner = props.corner || "bottom-right"
|
|
62
|
+
let [vertical, horizontal] = corner.split("-")
|
|
63
|
+
|
|
64
|
+
let style = {}
|
|
65
|
+
|
|
66
|
+
style[vertical] = props.paddingY || 15
|
|
67
|
+
style[horizontal] = props.paddingX || 30
|
|
68
|
+
|
|
69
|
+
return style
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
className={clsx(
|
|
75
|
+
"fixed rounded bg-blue-300 p-2 text-black transition-all hover:bg-blue-500",
|
|
76
|
+
`${visible ? "block" : "hidden"}`
|
|
77
|
+
// getClasses()
|
|
78
|
+
)}
|
|
79
|
+
style={getStyles()}
|
|
80
|
+
onClick={backToTop}
|
|
81
|
+
>
|
|
82
|
+
Back to top
|
|
83
|
+
</div>
|
|
84
|
+
)
|
|
85
|
+
}
|
package/src/elements/index.ts
CHANGED
package/src/styles.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
! tailwindcss v3.3.
|
|
2
|
+
! tailwindcss v3.3.3 | MIT License | https://tailwindcss.com
|
|
3
3
|
*//*
|
|
4
4
|
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
|
|
5
5
|
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
|
|
@@ -167,6 +167,8 @@ optgroup,
|
|
|
167
167
|
select,
|
|
168
168
|
textarea {
|
|
169
169
|
font-family: inherit; /* 1 */
|
|
170
|
+
font-feature-settings: inherit; /* 1 */
|
|
171
|
+
font-variation-settings: inherit; /* 1 */
|
|
170
172
|
font-size: 100%; /* 1 */
|
|
171
173
|
font-weight: inherit; /* 1 */
|
|
172
174
|
line-height: inherit; /* 1 */
|
|
@@ -304,6 +306,13 @@ menu {
|
|
|
304
306
|
padding: 0;
|
|
305
307
|
}
|
|
306
308
|
|
|
309
|
+
/*
|
|
310
|
+
Reset default styling for dialogs.
|
|
311
|
+
*/
|
|
312
|
+
dialog {
|
|
313
|
+
padding: 0;
|
|
314
|
+
}
|
|
315
|
+
|
|
307
316
|
/*
|
|
308
317
|
Prevent resizing textareas horizontally by default.
|
|
309
318
|
*/
|
|
@@ -1035,6 +1044,9 @@ video {
|
|
|
1035
1044
|
width: -moz-min-content;
|
|
1036
1045
|
width: min-content;
|
|
1037
1046
|
}
|
|
1047
|
+
.w-screen {
|
|
1048
|
+
width: 100vw;
|
|
1049
|
+
}
|
|
1038
1050
|
.min-w-\[24px\] {
|
|
1039
1051
|
min-width: 24px;
|
|
1040
1052
|
}
|
|
@@ -1286,6 +1298,9 @@ video {
|
|
|
1286
1298
|
.overflow-y-clip {
|
|
1287
1299
|
overflow-y: clip;
|
|
1288
1300
|
}
|
|
1301
|
+
.overflow-y-scroll {
|
|
1302
|
+
overflow-y: scroll;
|
|
1303
|
+
}
|
|
1289
1304
|
.truncate {
|
|
1290
1305
|
overflow: hidden;
|
|
1291
1306
|
text-overflow: ellipsis;
|
|
@@ -1606,6 +1621,10 @@ video {
|
|
|
1606
1621
|
--tw-bg-opacity: 1;
|
|
1607
1622
|
background-color: rgb(185 28 28 / var(--tw-bg-opacity));
|
|
1608
1623
|
}
|
|
1624
|
+
.bg-red-900 {
|
|
1625
|
+
--tw-bg-opacity: 1;
|
|
1626
|
+
background-color: rgb(127 29 29 / var(--tw-bg-opacity));
|
|
1627
|
+
}
|
|
1609
1628
|
.bg-slate-600 {
|
|
1610
1629
|
--tw-bg-opacity: 1;
|
|
1611
1630
|
background-color: rgb(71 85 105 / var(--tw-bg-opacity));
|
|
@@ -2201,6 +2220,11 @@ body {
|
|
|
2201
2220
|
background-color: rgb(191 219 254 / var(--tw-bg-opacity));
|
|
2202
2221
|
}
|
|
2203
2222
|
|
|
2223
|
+
.hover\:bg-blue-500:hover {
|
|
2224
|
+
--tw-bg-opacity: 1;
|
|
2225
|
+
background-color: rgb(59 130 246 / var(--tw-bg-opacity));
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2204
2228
|
.hover\:bg-buttonPrimary-500:hover {
|
|
2205
2229
|
background-color: var(--button-primary-500);
|
|
2206
2230
|
}
|