Skip to content

Commit ffd15a4

Browse files
committed
dynamically set the footer link, text and social icon colors
1 parent 55876e6 commit ffd15a4

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/compounds/Footer/Footer.jsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import PropTypes from 'prop-types'
33
import LinkGroup from '../LinkGroup/LinkGroup'
44
import SocialIcon from '../../components/SocialIcon/SocialIcon'
55

6-
const Footer = ({ companyName, sections, socials }) => (
7-
<footer id='footer' className='container-fluid bg-secondary py-4'>
6+
const Footer = ({ companyName, sections, socials, color, ...props }) => (
7+
<footer id='footer' className={`container-fluid bg-primary py-4 text-${color}`}>
88
<div className='container'>
99
<div className='row'>
1010
<div className='col-12 col-md-3 text-center text-md-start'>
@@ -17,12 +17,24 @@ const Footer = ({ companyName, sections, socials }) => (
1717
>
1818
{sections && sections.map((section) => {
1919
const { header, links } = section
20-
return <LinkGroup header={header} links={links} key={header} {...section} />
20+
let linkStyle = props.linkStyle || { color }
21+
22+
return (
23+
<LinkGroup
24+
header={header}
25+
links={links}
26+
linkStyle={linkStyle}
27+
key={header}
28+
{...section}
29+
/>
30+
)
2131
})}
2232
</div>
2333
<div className='col-12 col-md-2 d-flex justify-content-center justify-content-md-end mt-5 mt-md-0'>
2434
{socials && socials.map((social) => {
2535
const { icon, url } = social
36+
social.color = social.color || color
37+
2638
return <SocialIcon icon={icon} url={url} key={icon} {...social} />
2739
})}
2840
</div>
@@ -32,12 +44,14 @@ const Footer = ({ companyName, sections, socials }) => (
3244
)
3345

3446
Footer.propTypes = {
47+
color: PropTypes.string,
3548
companyName: PropTypes.string.isRequired,
3649
sections: PropTypes.arrayOf(PropTypes.shape(LinkGroup.propTypes)),
3750
socials: PropTypes.arrayOf(PropTypes.shape(SocialIcon.propTypes)),
3851
}
3952

4053
Footer.defaultProps = {
54+
color: 'dark',
4155
sections: [],
4256
socials: [],
4357
}

src/compounds/Footer/Footer.stories.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ const Template = (args) => <Footer {...args} />
1414

1515
export const Default = Template.bind({})
1616
Default.args = {
17+
color: 'dark',
1718
companyName: 'Company A',
1819
sections: [],
1920
socials: [],
2021
}
2122

2223
export const Alternate = Template.bind({})
2324
Alternate.args = {
25+
color: 'white',
2426
companyName: 'Company B',
2527
sections,
2628
socials,

0 commit comments

Comments
 (0)