oddsgate-ds 1.0.191 → 1.0.192
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 +3 -3
- 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 +77 -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,35 @@ 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
|
+
padding-left: 16px;
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
align-items: center;
|
|
91
|
+
text-align: center;
|
|
92
|
+
max-height: ${props => (props.isVisible ? '500px' : '0')};
|
|
93
|
+
overflow: hidden;
|
|
94
|
+
opacity: 1;
|
|
95
|
+
pointer-events: auto;
|
|
96
|
+
visibility: visible;
|
|
97
|
+
transition: max-height 0.3s ease-in-out;
|
|
98
|
+
}
|
|
67
99
|
`
|
|
68
100
|
|
|
69
101
|
export const StyledLegalLinksDropdownItem = styled.li<ILegalLinksDropdownItem>`
|
|
@@ -106,16 +138,53 @@ export const StyledLegalLinksDropdownItem = styled.li<ILegalLinksDropdownItem>`
|
|
|
106
138
|
color: ${colors.gray50} !important;
|
|
107
139
|
}
|
|
108
140
|
}
|
|
141
|
+
|
|
142
|
+
@media only screen and (max-width: ${responsiveMedia}) {
|
|
143
|
+
background-color: transparent;
|
|
144
|
+
padding: 8px 0;
|
|
145
|
+
border-radius: 0;
|
|
146
|
+
|
|
147
|
+
&:first-child {
|
|
148
|
+
border-radius: 0;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&:last-child {
|
|
152
|
+
border-radius: 0;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
&:first-child:last-child {
|
|
156
|
+
border-radius: 0;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
&:hover {
|
|
160
|
+
background-color: transparent;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
a {
|
|
164
|
+
text-decoration: underline;
|
|
165
|
+
|
|
166
|
+
&:hover {
|
|
167
|
+
opacity: 0.6;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
109
171
|
`
|
|
110
172
|
|
|
111
|
-
export const StyledLegalLinksDropdownIcon = styled.span
|
|
173
|
+
export const StyledLegalLinksDropdownIcon = styled.span<{ isOpen?: boolean }>`
|
|
112
174
|
font-size: 10px;
|
|
113
175
|
display: flex;
|
|
114
176
|
align-items: center;
|
|
177
|
+
transition: transform 0.2s ease-in-out;
|
|
178
|
+
text-decoration: none !important;
|
|
115
179
|
|
|
116
180
|
& > * {
|
|
117
181
|
font-size: 10px !important;
|
|
118
182
|
width: 14px;
|
|
119
183
|
height: 8px;
|
|
184
|
+
text-decoration: none !important;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
@media only screen and (max-width: ${responsiveMedia}) {
|
|
188
|
+
transform: ${props => (props.isOpen ? 'rotate(180deg)' : 'rotate(0deg)')};
|
|
120
189
|
}
|
|
121
190
|
`
|