@julseb-lib/react 0.0.86 → 0.0.88
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/README.md +1 -1
- package/dist/index.cjs.js +52 -53
- package/dist/index.es.js +748 -734
- package/dist/index.umd.js +210 -211
- package/dist/lib/components/Alert/Alert.tsx +74 -72
- package/dist/lib/components/Aside/Aside.tsx +18 -18
- package/dist/lib/components/Button/Button.tsx +86 -84
- package/dist/lib/components/ButtonIcon/ButtonIcon.tsx +2 -0
- package/dist/lib/components/Grid/Grid.tsx +9 -9
- package/dist/lib/components/Header/Header.tsx +166 -164
- package/dist/lib/components/Header/HeaderBurger.tsx +40 -39
- package/dist/lib/components/Header/HeaderLogo.tsx +57 -53
- package/dist/lib/components/Header/HeaderNav.tsx +68 -59
- package/dist/lib/components/Header/subtypes.ts +52 -51
- package/dist/lib/components/Main/Main.tsx +19 -19
- package/dist/lib/components/TextIcon/TextIcon.tsx +58 -58
- package/dist/lib/components/Tooltip/types.ts +15 -14
- package/dist/lib/components/Wrapper/styles.tsx +0 -1
- package/package.json +2 -2
|
@@ -9,9 +9,9 @@ import { HeaderLogo } from "./HeaderLogo"
|
|
|
9
9
|
import { StyledHeader, Overlay } from "./styles"
|
|
10
10
|
import type { ILibHeader } from "./types"
|
|
11
11
|
import type {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
ILibHeaderNav,
|
|
13
|
+
ILibHeaderBurger,
|
|
14
|
+
ILibHeaderSearch,
|
|
15
15
|
} from "./subtypes"
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -56,166 +56,168 @@ import type {
|
|
|
56
56
|
* />
|
|
57
57
|
*/
|
|
58
58
|
export const Header: FC<ILibHeader> = ({
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
59
|
+
"data-testid": testid,
|
|
60
|
+
as,
|
|
61
|
+
ref,
|
|
62
|
+
children,
|
|
63
|
+
role = "navigation",
|
|
64
|
+
className,
|
|
65
|
+
logo,
|
|
66
|
+
variant = "primary",
|
|
67
|
+
burgerPosition = "right",
|
|
68
|
+
navDesktopVariant = "right",
|
|
69
|
+
navMobileVariant = "drawer",
|
|
70
|
+
search,
|
|
71
|
+
position = "relative",
|
|
72
|
+
hideOnScroll,
|
|
73
|
+
links,
|
|
74
|
+
nav,
|
|
75
|
+
enableScrollingOpen,
|
|
76
|
+
backgroundColor = "primary",
|
|
77
|
+
textColor = "background",
|
|
78
|
+
linkColor = "white",
|
|
79
|
+
...rest
|
|
79
80
|
}) => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
81
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
82
|
+
|
|
83
|
+
const handleOpen = () => {
|
|
84
|
+
if (!enableScrollingOpen) disableScroll()
|
|
85
|
+
setIsOpen(true)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const handleClose = () => {
|
|
89
|
+
if (!enableScrollingOpen) enableScroll()
|
|
90
|
+
setTimeout(() => setIsOpen(false), 10)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const isMobile = useMaxWidth(600)
|
|
94
|
+
|
|
95
|
+
const logoObj = typeof logo === "object" ? logo : undefined
|
|
96
|
+
|
|
97
|
+
const logoHeight = logoObj?.height || 30
|
|
98
|
+
const burgerHeight = 32
|
|
99
|
+
const logoTextHeight = 35
|
|
100
|
+
const heightsArr = [logoHeight, burgerHeight, logoTextHeight].sort()
|
|
101
|
+
const valueForHeight = heightsArr[heightsArr.length - 1]
|
|
102
|
+
|
|
103
|
+
const headerHeight = valueForHeight + 16 * 2
|
|
104
|
+
|
|
105
|
+
const [isHidden, setIsHidden] = useState(false)
|
|
106
|
+
const hidePosition = typeof hideOnScroll === "boolean" ? 400 : hideOnScroll
|
|
107
|
+
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (hidePosition) {
|
|
110
|
+
if (window.pageYOffset >= hidePosition) {
|
|
111
|
+
setIsHidden(true)
|
|
112
|
+
} else {
|
|
113
|
+
setIsHidden(false)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
window.addEventListener("scroll", () => {
|
|
117
|
+
if (window.pageYOffset >= hidePosition) {
|
|
118
|
+
setIsHidden(true)
|
|
119
|
+
} else {
|
|
120
|
+
setIsHidden(false)
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
}, [hidePosition])
|
|
125
|
+
|
|
126
|
+
const burgerRef = useRef<HTMLButtonElement>(null as any)
|
|
127
|
+
|
|
128
|
+
useKeyPress("Escape", () => {
|
|
129
|
+
if (isOpen) handleClose()
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
const burgerProps: ILibHeaderBurger & {
|
|
133
|
+
ref: Ref<HTMLButtonElement>
|
|
134
|
+
} = {
|
|
135
|
+
"data-testid": testid,
|
|
136
|
+
className,
|
|
137
|
+
isOpen,
|
|
138
|
+
navMobileVariant,
|
|
139
|
+
variant,
|
|
140
|
+
ref: burgerRef,
|
|
141
|
+
handleOpen,
|
|
142
|
+
handleClose,
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const navProps: ILibHeaderNav = {
|
|
146
|
+
"data-testid": testid,
|
|
147
|
+
className,
|
|
148
|
+
search,
|
|
149
|
+
isOpen,
|
|
150
|
+
handleClose,
|
|
151
|
+
links,
|
|
152
|
+
children,
|
|
153
|
+
headerHeight,
|
|
154
|
+
variant,
|
|
155
|
+
navMobileVariant,
|
|
156
|
+
burgerPosition,
|
|
157
|
+
burgerRef,
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const searchProps: ILibHeaderSearch = {
|
|
161
|
+
"data-testid": testid,
|
|
162
|
+
className,
|
|
163
|
+
search,
|
|
164
|
+
handleClose,
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<StyledHeader
|
|
169
|
+
data-testid={testid}
|
|
170
|
+
ref={ref}
|
|
171
|
+
as={as}
|
|
172
|
+
className={classNames(
|
|
173
|
+
className,
|
|
174
|
+
{ Hidden: isHidden },
|
|
175
|
+
{ Open: isOpen }
|
|
176
|
+
)}
|
|
177
|
+
role={role}
|
|
178
|
+
$burgerPosition={burgerPosition}
|
|
179
|
+
$headerHeight={headerHeight}
|
|
180
|
+
$position={position}
|
|
181
|
+
$variant={variant}
|
|
182
|
+
$backgroundColor={backgroundColor}
|
|
183
|
+
$linkColor={linkColor}
|
|
184
|
+
$textColor={textColor}
|
|
185
|
+
{...rest}
|
|
186
|
+
>
|
|
187
|
+
{burgerPosition === "left" && <HeaderBurger {...burgerProps} />}
|
|
188
|
+
|
|
189
|
+
<HeaderLogo
|
|
190
|
+
data-testid={testid}
|
|
191
|
+
className={className}
|
|
192
|
+
logo={logo}
|
|
193
|
+
isOpen={isOpen}
|
|
194
|
+
>
|
|
195
|
+
{typeof logo === "object" ? logo.text : logo}
|
|
196
|
+
</HeaderLogo>
|
|
197
|
+
|
|
198
|
+
{navDesktopVariant === "left" && <HeaderNav {...navProps} />}
|
|
199
|
+
|
|
200
|
+
{!isMobile && navDesktopVariant === "right" && (
|
|
201
|
+
<HeaderSearch {...searchProps} />
|
|
202
|
+
)}
|
|
203
|
+
|
|
204
|
+
{burgerPosition === "right" && <HeaderBurger {...burgerProps} />}
|
|
205
|
+
|
|
206
|
+
{navDesktopVariant === "right" && <HeaderNav {...navProps} />}
|
|
207
|
+
|
|
208
|
+
{isMobile && navMobileVariant === "drawer" && (
|
|
209
|
+
<Overlay
|
|
210
|
+
onClick={() => setIsOpen(false)}
|
|
211
|
+
className={classNames(
|
|
212
|
+
{ HeaderOverlay: className },
|
|
213
|
+
{ Visible: isOpen }
|
|
214
|
+
)}
|
|
215
|
+
/>
|
|
216
|
+
)}
|
|
217
|
+
|
|
218
|
+
{!isMobile && navDesktopVariant === "left" && (
|
|
219
|
+
<HeaderSearch {...searchProps} />
|
|
220
|
+
)}
|
|
221
|
+
</StyledHeader>
|
|
222
|
+
)
|
|
221
223
|
}
|
|
@@ -4,48 +4,49 @@ import { StyledHeaderBurger } from "./styles"
|
|
|
4
4
|
import type { ILibHeaderBurger } from "./subtypes"
|
|
5
5
|
|
|
6
6
|
export const HeaderBurger: FC<ILibHeaderBurger> = ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
"data-testid": testid,
|
|
8
|
+
ref,
|
|
9
|
+
className,
|
|
10
|
+
isOpen,
|
|
11
|
+
navMobileVariant,
|
|
12
|
+
variant,
|
|
13
|
+
burgerColor,
|
|
14
|
+
handleOpen,
|
|
15
|
+
handleClose,
|
|
16
16
|
}) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const getBurgerColor = (): LibColorsHover => {
|
|
18
|
+
if (burgerColor) {
|
|
19
|
+
if (typeof burgerColor === "string") return burgerColor
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
return isOpen ? burgerColor.open : burgerColor.closed
|
|
22
|
+
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
if (
|
|
25
|
+
(navMobileVariant === "drawer" && isOpen) ||
|
|
26
|
+
variant === "primary" ||
|
|
27
|
+
navMobileVariant === "full" ||
|
|
28
|
+
(navMobileVariant === "top" && isOpen && variant === "transparent")
|
|
29
|
+
) {
|
|
30
|
+
return "white"
|
|
31
|
+
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
return "primary"
|
|
34
|
+
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
36
|
+
return (
|
|
37
|
+
<StyledHeaderBurger
|
|
38
|
+
data-testid={testid && `${testid}.HeaderBurger`}
|
|
39
|
+
ref={ref}
|
|
40
|
+
role="button"
|
|
41
|
+
className={className && "HeaderBurger"}
|
|
42
|
+
isOpen={isOpen}
|
|
43
|
+
onClick={() => {
|
|
44
|
+
if (isOpen) handleClose()
|
|
45
|
+
else handleOpen()
|
|
46
|
+
}}
|
|
47
|
+
width={32}
|
|
48
|
+
height={24}
|
|
49
|
+
color={getBurgerColor()}
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
51
52
|
}
|
|
@@ -4,61 +4,65 @@ import { Logo, LogoImg } from "./styles"
|
|
|
4
4
|
import type { ILibHeaderLogo } from "./subtypes"
|
|
5
5
|
|
|
6
6
|
export const HeaderLogo: FC<ILibHeaderLogo> = ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
"data-testid": testid,
|
|
8
|
+
className,
|
|
9
|
+
logo,
|
|
10
|
+
children,
|
|
11
|
+
isOpen,
|
|
12
12
|
}) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
const {
|
|
14
|
+
to = "/",
|
|
15
|
+
href,
|
|
16
|
+
img,
|
|
17
|
+
imgOpen,
|
|
18
|
+
alt = "Logo",
|
|
19
|
+
width = 100,
|
|
20
|
+
height = 30,
|
|
21
|
+
} = logo as any
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
if (img) {
|
|
24
|
+
const imgProps = {
|
|
25
|
+
"data-testid": testid && `${testid}.HeaderLogo.Img`,
|
|
26
|
+
className: className && "HeaderLogoImg",
|
|
27
|
+
src: imgOpen && isOpen ? imgOpen : img,
|
|
28
|
+
alt,
|
|
29
|
+
width,
|
|
30
|
+
height,
|
|
31
|
+
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
return href ? (
|
|
34
|
+
<a
|
|
35
|
+
href={href}
|
|
36
|
+
data-testid={testid && `${testid}.HeaderLogo`}
|
|
37
|
+
className={className && "HeaderLogo"}
|
|
38
|
+
role="link"
|
|
39
|
+
>
|
|
40
|
+
<LogoImg {...imgProps} />
|
|
41
|
+
</a>
|
|
42
|
+
) : (
|
|
43
|
+
<Link
|
|
44
|
+
data-testid={testid && `${testid}.HeaderLogo`}
|
|
45
|
+
className={className && "HeaderLogo"}
|
|
46
|
+
to={to}
|
|
47
|
+
role="link"
|
|
48
|
+
>
|
|
49
|
+
<LogoImg {...imgProps} />
|
|
50
|
+
</Link>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
return (
|
|
55
|
+
<Logo
|
|
56
|
+
data-testid={testid && `${testid}.HeaderLogo`}
|
|
57
|
+
as={href ? "a" : Link}
|
|
58
|
+
className={className && "HeaderLogo"}
|
|
59
|
+
to={to}
|
|
60
|
+
href={href}
|
|
61
|
+
translate="no"
|
|
62
|
+
role="link"
|
|
63
|
+
aria-label="Header Logo"
|
|
64
|
+
>
|
|
65
|
+
{children}
|
|
66
|
+
</Logo>
|
|
67
|
+
)
|
|
64
68
|
}
|