oddsgate-ds 1.0.191 → 1.0.193
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/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/atoms/LegalLinksDropdown/LegalLinksDropdown.theme.d.ts +3 -1
- package/dist/esm/index.js +5 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/atoms/LegalLinksDropdown/LegalLinksDropdown.theme.d.ts +3 -1
- package/package.json +1 -1
- package/src/components/atoms/LegalLinksDropdown/LegalLinksDropdown.component.tsx +21 -6
- package/src/components/atoms/LegalLinksDropdown/LegalLinksDropdown.theme.ts +76 -8
|
@@ -5,4 +5,6 @@ export declare const StyledLegalLinksDropdownTrigger: import("styled-components/
|
|
|
5
5
|
export declare const StyledLegalLinksDropdownTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
6
6
|
export declare const StyledLegalLinksDropdownContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, ILegalLinksDropdownContainer>> & string;
|
|
7
7
|
export declare const StyledLegalLinksDropdownItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, ILegalLinksDropdownItem>> & string;
|
|
8
|
-
export declare const StyledLegalLinksDropdownIcon: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").
|
|
8
|
+
export declare const StyledLegalLinksDropdownIcon: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
|
|
9
|
+
isOpen?: boolean | undefined;
|
|
10
|
+
}>> & string;
|
package/package.json
CHANGED
|
@@ -22,6 +22,7 @@ const LegalLinksDropdown = ({
|
|
|
22
22
|
}: ILegalLinksDropdown) => {
|
|
23
23
|
const [isOpen, setIsOpen] = useState(false)
|
|
24
24
|
const [openUpward, setOpenUpward] = useState(false)
|
|
25
|
+
const [isMobile, setIsMobile] = useState(false)
|
|
25
26
|
const dropdownRef = useRef<HTMLDivElement>(null)
|
|
26
27
|
const containerRef = useRef<HTMLUListElement>(null)
|
|
27
28
|
|
|
@@ -29,10 +30,24 @@ const LegalLinksDropdown = ({
|
|
|
29
30
|
setIsOpen(!isOpen)
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const checkIsMobile = () => {
|
|
35
|
+
// You can adjust this breakpoint to match your responsiveMedia value
|
|
36
|
+
setIsMobile(window.innerWidth < 768)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
checkIsMobile()
|
|
40
|
+
window.addEventListener('resize', checkIsMobile)
|
|
41
|
+
|
|
42
|
+
return () => {
|
|
43
|
+
window.removeEventListener('resize', checkIsMobile)
|
|
44
|
+
}
|
|
45
|
+
}, [])
|
|
32
46
|
|
|
33
47
|
useEffect(() => {
|
|
34
48
|
const handleClickOutside = (event: MouseEvent) => {
|
|
35
49
|
if (
|
|
50
|
+
!isMobile &&
|
|
36
51
|
dropdownRef.current &&
|
|
37
52
|
!dropdownRef.current.contains(event.target as Node)
|
|
38
53
|
) {
|
|
@@ -40,24 +55,24 @@ const LegalLinksDropdown = ({
|
|
|
40
55
|
}
|
|
41
56
|
}
|
|
42
57
|
|
|
43
|
-
if (isOpen) {
|
|
58
|
+
if (isOpen && !isMobile) {
|
|
44
59
|
document.addEventListener('mousedown', handleClickOutside)
|
|
45
60
|
}
|
|
46
61
|
|
|
47
62
|
return () => {
|
|
48
63
|
document.removeEventListener('mousedown', handleClickOutside)
|
|
49
64
|
}
|
|
50
|
-
}, [isOpen])
|
|
65
|
+
}, [isOpen, isMobile])
|
|
51
66
|
|
|
52
67
|
useEffect(() => {
|
|
53
|
-
if (isOpen && dropdownRef.current && containerRef.current) {
|
|
68
|
+
if (isOpen && !isMobile && dropdownRef.current && containerRef.current) {
|
|
54
69
|
const triggerRect = dropdownRef.current.getBoundingClientRect()
|
|
55
70
|
const containerHeight = containerRef.current.offsetHeight
|
|
56
71
|
const spaceBelow = window.innerHeight - triggerRect.bottom
|
|
57
72
|
|
|
58
73
|
setOpenUpward(spaceBelow < containerHeight)
|
|
59
74
|
}
|
|
60
|
-
}, [isOpen])
|
|
75
|
+
}, [isOpen, isMobile])
|
|
61
76
|
|
|
62
77
|
return (
|
|
63
78
|
<StyledLegalLinksDropdown
|
|
@@ -67,14 +82,14 @@ const LegalLinksDropdown = ({
|
|
|
67
82
|
>
|
|
68
83
|
<StyledLegalLinksDropdownTrigger onClick={handleToggle}>
|
|
69
84
|
<StyledLegalLinksDropdownTitle>{title}</StyledLegalLinksDropdownTitle>
|
|
70
|
-
<StyledLegalLinksDropdownIcon>
|
|
85
|
+
<StyledLegalLinksDropdownIcon isOpen={isOpen}>
|
|
71
86
|
<Icon icon="icon-chevron-down" />
|
|
72
87
|
</StyledLegalLinksDropdownIcon>
|
|
73
88
|
</StyledLegalLinksDropdownTrigger>
|
|
74
89
|
<StyledLegalLinksDropdownContainer
|
|
75
90
|
ref={containerRef}
|
|
76
91
|
isVisible={isOpen}
|
|
77
|
-
openUpward={openUpward}
|
|
92
|
+
openUpward={openUpward && !isMobile}
|
|
78
93
|
>
|
|
79
94
|
{children}
|
|
80
95
|
</StyledLegalLinksDropdownContainer>
|
|
@@ -9,6 +9,11 @@ import styled from 'styled-components'
|
|
|
9
9
|
export const StyledLegalLinksDropdown = styled.div<ILegalLinksDropdown>`
|
|
10
10
|
position: relative;
|
|
11
11
|
display: inline-flex;
|
|
12
|
+
|
|
13
|
+
@media only screen and (max-width: ${responsiveMedia}) {
|
|
14
|
+
display: block;
|
|
15
|
+
width: 100%;
|
|
16
|
+
}
|
|
12
17
|
`
|
|
13
18
|
|
|
14
19
|
export const StyledLegalLinksDropdownTrigger = styled.div`
|
|
@@ -28,17 +33,26 @@ export const StyledLegalLinksDropdownTrigger = styled.div`
|
|
|
28
33
|
@media only screen and (min-width: ${responsiveMedia}) {
|
|
29
34
|
font-size: 15px;
|
|
30
35
|
}
|
|
36
|
+
|
|
37
|
+
@media only screen and (max-width: ${responsiveMedia}) {
|
|
38
|
+
width: 100%;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
text-decoration: none;
|
|
41
|
+
}
|
|
31
42
|
`
|
|
32
43
|
|
|
33
44
|
export const StyledLegalLinksDropdownTitle = styled.span`
|
|
34
45
|
text-decoration: underline;
|
|
46
|
+
|
|
47
|
+
@media only screen and (max-width: ${responsiveMedia}) {
|
|
48
|
+
text-decoration: underline;
|
|
49
|
+
}
|
|
35
50
|
`
|
|
36
51
|
|
|
37
52
|
export const StyledLegalLinksDropdownContainer = styled.ul<ILegalLinksDropdownContainer>`
|
|
38
53
|
position: absolute;
|
|
39
54
|
${props => (props.openUpward ? 'bottom: 100%;' : 'top: 100%;')}
|
|
40
|
-
left:
|
|
41
|
-
transform: translateX(-50%);
|
|
55
|
+
left: 0%;
|
|
42
56
|
|
|
43
57
|
${props => (props.openUpward ? 'margin-bottom: 2px;' : 'margin-top: 2px;')}
|
|
44
58
|
background: ${colors.primary50};
|
|
@@ -53,17 +67,34 @@ export const StyledLegalLinksDropdownContainer = styled.ul<ILegalLinksDropdownCo
|
|
|
53
67
|
visibility: ${props => (props.isVisible ? 'visible' : 'hidden')};
|
|
54
68
|
|
|
55
69
|
transform: ${props => {
|
|
56
|
-
const baseTransform = 'translateX(-50%)'
|
|
57
70
|
if (!props.isVisible) {
|
|
58
|
-
return props.openUpward
|
|
59
|
-
? `${baseTransform} translateY(10px)`
|
|
60
|
-
: `${baseTransform} translateY(-10px)`
|
|
71
|
+
return props.openUpward ? `translateY(10px)` : `translateY(-10px)`
|
|
61
72
|
}
|
|
62
|
-
return
|
|
73
|
+
return `translateY(0)`
|
|
63
74
|
}};
|
|
64
75
|
|
|
65
76
|
z-index: 100;
|
|
66
77
|
transition: all 0.2s ease-in-out;
|
|
78
|
+
|
|
79
|
+
@media only screen and (max-width: ${responsiveMedia}) {
|
|
80
|
+
position: static;
|
|
81
|
+
transform: none;
|
|
82
|
+
background: transparent;
|
|
83
|
+
box-shadow: none;
|
|
84
|
+
border-radius: 0;
|
|
85
|
+
white-space: normal;
|
|
86
|
+
margin: 0;
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
align-items: center;
|
|
90
|
+
text-align: center;
|
|
91
|
+
max-height: ${props => (props.isVisible ? '500px' : '0')};
|
|
92
|
+
overflow: hidden;
|
|
93
|
+
opacity: 1;
|
|
94
|
+
pointer-events: auto;
|
|
95
|
+
visibility: visible;
|
|
96
|
+
transition: max-height 0.3s ease-in-out;
|
|
97
|
+
}
|
|
67
98
|
`
|
|
68
99
|
|
|
69
100
|
export const StyledLegalLinksDropdownItem = styled.li<ILegalLinksDropdownItem>`
|
|
@@ -106,16 +137,53 @@ export const StyledLegalLinksDropdownItem = styled.li<ILegalLinksDropdownItem>`
|
|
|
106
137
|
color: ${colors.gray50} !important;
|
|
107
138
|
}
|
|
108
139
|
}
|
|
140
|
+
|
|
141
|
+
@media only screen and (max-width: ${responsiveMedia}) {
|
|
142
|
+
background-color: transparent;
|
|
143
|
+
padding: 8px 0;
|
|
144
|
+
border-radius: 0;
|
|
145
|
+
|
|
146
|
+
&:first-child {
|
|
147
|
+
border-radius: 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&:last-child {
|
|
151
|
+
border-radius: 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
&:first-child:last-child {
|
|
155
|
+
border-radius: 0;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&:hover {
|
|
159
|
+
background-color: transparent;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
a {
|
|
163
|
+
text-decoration: underline;
|
|
164
|
+
|
|
165
|
+
&:hover {
|
|
166
|
+
opacity: 0.6;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
109
170
|
`
|
|
110
171
|
|
|
111
|
-
export const StyledLegalLinksDropdownIcon = styled.span
|
|
172
|
+
export const StyledLegalLinksDropdownIcon = styled.span<{ isOpen?: boolean }>`
|
|
112
173
|
font-size: 10px;
|
|
113
174
|
display: flex;
|
|
114
175
|
align-items: center;
|
|
176
|
+
transition: transform 0.2s ease-in-out;
|
|
177
|
+
text-decoration: none !important;
|
|
115
178
|
|
|
116
179
|
& > * {
|
|
117
180
|
font-size: 10px !important;
|
|
118
181
|
width: 14px;
|
|
119
182
|
height: 8px;
|
|
183
|
+
text-decoration: none !important;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@media only screen and (max-width: ${responsiveMedia}) {
|
|
187
|
+
transform: ${props => (props.isOpen ? 'rotate(180deg)' : 'rotate(0deg)')};
|
|
120
188
|
}
|
|
121
189
|
`
|