-
Notifications
You must be signed in to change notification settings - Fork 7
/
FooterVtexLogo.js
62 lines (54 loc) · 1.83 KB
/
FooterVtexLogo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import { Functions } from '@gocommerce/utils'
import { includes } from 'ramda'
import { withRuntimeContext } from 'vtex.render-runtime'
import withImage from '../components/withImage'
import footer from './footer.css'
/**
* "Powered By Vtex" image's component, used in Footer
*/
const FooterVtexLogo = ({ runtime, logoUrl, imageSrc }) => {
if (!imageSrc) {
return null
}
const isPlatformGCResult = Functions.isGoCommerceAcc(runtime.account)
const vtexLogoItemClasses = classNames(footer.vtexLogoItem, {
w4: isPlatformGCResult,
'h3 w3': !isPlatformGCResult,
})
return (
<div
className={`${
footer.badgeList
} flex flex-row justify-center pv4-s pa0-ns items-center ml-auto-m`}>
{logoUrl && (
<span className={`${footer.badge} pa2-s pa1-ns`}>
<img className={`${footer.logoImage} h3`} src={logoUrl} />
</span>
)}
<span className={`${footer.badge} pa2-s pa1-ns nt7-ns`}>
<img className={vtexLogoItemClasses} src={imageSrc} />
</span>
</div>
)
}
FooterVtexLogo.displayName = 'FooterVtexLogo'
FooterVtexLogo.propTypes = {
/** Get the account name to find the correct platfom */
runtime: PropTypes.shape({
account: PropTypes.string.isRequired,
}).isRequired,
/** If true, the original logo (with color) is used. If not, the grayscale's one */
showInColor: PropTypes.bool,
/** The source for an external customizable logo to show above "Powered By Vtex" */
logoUrl: PropTypes.string,
}
const getImagePathFromProps = ({ runtime, showInColor }) =>
`${Functions.isGoCommerceAcc(runtime.account) ? 'gocommerce' : 'vtex'}${
showInColor ? '' : '-bw'
}.svg`
export default withRuntimeContext(
withImage(getImagePathFromProps)(FooterVtexLogo)
)