11// @ts -nocheck
2- import React , { useState , useEffect , useRef , useMemo } from "react" ;
2+ import React , { useMemo } from "react" ;
33import styled , { ThemeProvider } from "styled-components" ;
44import { spaces , responsiveSizes } from "../common/variables.js" ;
55import useTheme from "../useTheme" ;
@@ -16,10 +16,6 @@ const DxcFooter = ({
1616 margin,
1717 tabIndex = 0 ,
1818} : FooterPropsType ) : JSX . Element => {
19- const ref = useRef ( null ) ;
20- const [ refSize , setRefSize ] = useState ( ) ;
21- const [ isResponsiveTablet , setIsResponsiveTablet ] = useState ( false ) ;
22- const [ isResponsivePhone , setIsResponsivePhone ] = useState ( false ) ;
2319 const colorsTheme = useTheme ( ) ;
2420
2521 const footerLogo = useMemo ( ( ) => {
@@ -32,35 +28,6 @@ const DxcFooter = ({
3228 return colorsTheme . footer . logo ;
3329 } , [ colorsTheme . footer . logo ] ) ;
3430
35- const handleResize = ( refWidth ) => {
36- if ( ref . current ) {
37- setRefSize ( refWidth ) ;
38- if ( refWidth <= responsiveSizes . tablet && refWidth > responsiveSizes . mobileLarge ) {
39- setIsResponsiveTablet ( true ) ;
40- setIsResponsivePhone ( false ) ;
41- } else if ( refWidth <= responsiveSizes . tablet && refWidth <= responsiveSizes . mobileLarge ) {
42- setIsResponsivePhone ( true ) ;
43- setIsResponsiveTablet ( false ) ;
44- } else {
45- setIsResponsiveTablet ( false ) ;
46- setIsResponsivePhone ( false ) ;
47- }
48- }
49- } ;
50-
51- const handleEventListener = ( ) => {
52- handleResize ( ref . current . offsetWidth ) ;
53- } ;
54-
55- useEffect ( ( ) => {
56- window . addEventListener ( "resize" , handleEventListener ) ;
57- handleResize ( ref . current . offsetWidth ) ;
58-
59- return ( ) => {
60- window . removeEventListener ( "resize" , handleEventListener ) ;
61- } ;
62- } , [ ] ) ;
63-
6431 const socialLink = socialLinks ?. map ( ( link , index ) => (
6532 < SocialAnchor
6633 tabIndex = { tabIndex }
@@ -85,18 +52,18 @@ const DxcFooter = ({
8552
8653 return (
8754 < ThemeProvider theme = { colorsTheme . footer } >
88- < FooterContainer margin = { margin } refSize = { refSize } ref = { ref } >
89- < FooterHeader refSize = { refSize } >
55+ < FooterContainer margin = { margin } >
56+ < FooterHeader >
9057 < LogoContainer > { footerLogo } </ LogoContainer >
91- < SocialLinkContainer refSize = { refSize } > { socialLink } </ SocialLinkContainer >
58+ < SocialLinkContainer > { socialLink } </ SocialLinkContainer >
9259 </ FooterHeader >
9360 < div >
9461 < ChildComponents padding = { padding } >
9562 < BackgroundColorProvider color = { colorsTheme . footer . backgroundColor } > { children } </ BackgroundColorProvider >
9663 </ ChildComponents >
97- < FooterFooter className = "footerFooter" refSize = { refSize } >
98- < BottomLinks refSize = { refSize } > { bottomLink } </ BottomLinks >
99- < Copyright refSize = { refSize } > { copyright } </ Copyright >
64+ < FooterFooter className = "footerFooter" >
65+ < BottomLinks > { bottomLink } </ BottomLinks >
66+ < Copyright > { copyright } </ Copyright >
10067 </ FooterFooter >
10168 </ div >
10269 </ FooterContainer >
@@ -105,7 +72,15 @@ const DxcFooter = ({
10572} ;
10673
10774const FooterContainer = styled . footer `
108- padding: ${ ( props ) => ( props . refSize <= responsiveSizes . mobileLarge ? "20px 20px 20px 20px" : "24px 36px 24px 36px" ) } ;
75+ @media (min-width: ${ responsiveSizes . small } rem) {
76+ padding: 24px 36px 24px 36px;
77+ }
78+
79+ @media (max-width: ${ responsiveSizes . small } rem) {
80+ //mobile phones
81+ padding: 20px;
82+ }
83+
10984 background-color: ${ ( props ) => props . theme . backgroundColor } ;
11085 margin-top: ${ ( props ) => ( props . margin && typeof props . margin !== "object" ? spaces [ props . margin ] : "0px" ) } ;
11186 width: 100%;
@@ -127,8 +102,17 @@ const FooterFooter = styled.div`
127102 display: flex;
128103 justify-content: space-between;
129104 align-items: flex-end;
130- flex-direction: ${ ( props ) => ( props . refSize <= responsiveSizes . mobileLarge ? "column" : "row" ) } ;
131- align-items: ${ ( props ) => ( props . refSize <= responsiveSizes . mobileLarge ? "center" : "" ) } ;
105+
106+ @media (min-width: ${ responsiveSizes . small } rem) {
107+ flex-direction: row;
108+ }
109+
110+ @media (max-width: ${ responsiveSizes . small } rem) {
111+ //mobile phones
112+ flex-direction: column;
113+ align-items: center;
114+ }
115+
132116 border-top: ${ ( props ) =>
133117 `${ props . theme . bottomLinksDividerThickness } ${ props . theme . bottomLinksDividerStyle } ${ props . theme . bottomLinksDividerColor } ` } ;
134118 margin-top: 16px;
@@ -138,8 +122,17 @@ const BottomLinks = styled.div`
138122 padding-top: ${ ( props ) => props . theme . bottomLinksDividerSpacing } ;
139123 display: inline-flex;
140124 flex-wrap: wrap;
141- max-width: ${ ( props ) => ( props . refSize <= responsiveSizes . mobileLarge ? "100%" : "60%" ) } ;
142- width: ${ ( props ) => ( props . refSize <= responsiveSizes . mobileLarge ? "100%" : "" ) } ;
125+
126+ @media (min-width: ${ responsiveSizes . small } rem) {
127+ max-width: 60%;
128+ }
129+
130+ @media (max-width: ${ responsiveSizes . small } rem) {
131+ //mobile phones
132+ max-width: 100%;
133+ width: 100%;
134+ }
135+
143136 & > span:last-child span {
144137 display: none;
145138 }
@@ -166,9 +159,19 @@ const Copyright = styled.div`
166159 font-style: ${ ( props ) => props . theme . copyrightFontStyle } ;
167160 font-weight: ${ ( props ) => props . theme . copyrightFontWeight } ;
168161 color: ${ ( props ) => props . theme . copyrightFontColor } ;
169- max-width: ${ ( props ) => ( props . refSize <= responsiveSizes . mobileLarge ? "100%" : "40%" ) } ;
170- width: ${ ( props ) => ( props . refSize <= responsiveSizes . mobileLarge ? "100%" : "" ) } ;
171- text-align: ${ ( props ) => ( props . refSize <= responsiveSizes . mobileLarge ? "left" : "right" ) } ;
162+
163+ @media (min-width: ${ responsiveSizes . small } rem) {
164+ max-width: 40%;
165+ text-align: right;
166+ }
167+
168+ @media (max-width: ${ responsiveSizes . small } rem) {
169+ //mobile phones
170+ max-width: 100%;
171+ width: 100%;
172+ text-align: left;
173+ }
174+
172175 padding-top: ${ ( props ) => props . theme . bottomLinksDividerSpacing } ;
173176` ;
174177
0 commit comments