Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
59 changed files
with
1,339 additions
and
193 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "vtex", | ||
"env": { | ||
"es6": true, | ||
"jest": true, | ||
"node": true | ||
}, | ||
"rules": { | ||
"prettier/prettier": "off", | ||
"@typescript-eslint/camelcase": "off", | ||
"@typescript-eslint/no-use-before-define": "off", | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"@typescript-eslint/no-object-literal-type-assertion": "off", | ||
"@typescript-eslint/no-explicit-any": "off" | ||
}, | ||
"globals": { | ||
"metrics": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"jsxBracketSameLine": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react' | ||
import PaymentMethodIcon, { | ||
PaymentMethod, | ||
} from './components/PaymentMethodIcon' | ||
import style from './components/AcceptedPaymentMethods.css' | ||
|
||
const AcceptedPaymentMethods: StorefrontFunctionComponent< | ||
AcceptedPaymentMethodsProps | ||
> = props => { | ||
return ( | ||
<div className={`${style.acceptedPaymentMethodContainer} nh2 flex`}> | ||
{props.paymentMethods.map(paymentMethod => ( | ||
<PaymentMethodIcon | ||
paymentMethod={paymentMethod} | ||
showInColor={props.showInColor} | ||
/> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
AcceptedPaymentMethods.defaultProps = { | ||
paymentMethods: [], | ||
showInColor: false, | ||
} | ||
|
||
interface AcceptedPaymentMethodsProps { | ||
paymentMethods: PaymentMethod[] | ||
showInColor: boolean | ||
} | ||
|
||
// tslint:disable: object-literal-sort-keys | ||
AcceptedPaymentMethods.schema = { | ||
title: 'editor.footer.acceptedPaymentMethods.title', | ||
description: 'editor.footer.acceptedPaymentMethods.description', | ||
type: 'object', | ||
properties: { | ||
showInColor: { | ||
default: false, | ||
isLayout: true, | ||
title: 'editor.footer.showPaymentMethodsInColor.title', | ||
type: 'boolean', | ||
}, | ||
paymentMethods: { | ||
title: 'editor.footer.acceptedPaymentMethods.title', | ||
type: 'array', | ||
minItems: 1, | ||
maxItems: 5, | ||
items: { | ||
title: 'editor.footer.paymentMethodIcon.method', | ||
type: 'string', | ||
default: 'MasterCard', | ||
enum: ['MasterCard', 'Visa', 'Diners Club'], | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
export default AcceptedPaymentMethods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react' | ||
import { ExtensionPoint, useChildBlock, useRuntime } from 'vtex.render-runtime' | ||
import LegacyFooter from './legacy/Footer' | ||
import Media from 'react-media' | ||
|
||
const Footer = props => { | ||
const footerDesktop = !!useChildBlock({ | ||
id: 'footer-layout.desktop', | ||
}) | ||
const footerMobile = !!useChildBlock({ | ||
id: 'footer-layout.mobile', | ||
}) | ||
|
||
const { | ||
hints: { mobile }, | ||
} = useRuntime() | ||
|
||
const hasFooterLayout = footerDesktop || footerMobile | ||
|
||
if (!hasFooterLayout) { | ||
return <LegacyFooter {...props} /> | ||
} | ||
|
||
// SSR fallback | ||
if (!window || !window.matchMedia) { | ||
return mobile ? ( | ||
<ExtensionPoint id="footer-layout.mobile" /> | ||
) : ( | ||
<ExtensionPoint id="footer-layout.desktop" /> | ||
) | ||
} | ||
|
||
return ( | ||
<Media query="(max-width:40rem)"> | ||
{matches => | ||
matches ? ( | ||
<ExtensionPoint id="footer-layout.mobile" /> | ||
) : ( | ||
<ExtensionPoint id="footer-layout.desktop" /> | ||
) | ||
} | ||
</Media> | ||
) | ||
} | ||
|
||
Footer.schema = LegacyFooter.schema | ||
|
||
export default Footer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React, { Component } from 'react' | ||
import style from './components/FooterLayout.css' | ||
|
||
const FooterLayout: StorefrontFunctionComponent<FooterLayoutProps> = props => { | ||
return <div className={style.footerLayout}>{props.children}</div> | ||
} | ||
|
||
interface FooterLayoutProps { | ||
children: Component | ||
} | ||
|
||
FooterLayout.getSchema = () => { | ||
// tslint:disable: object-literal-sort-keys | ||
return { | ||
title: 'editor.footer.title', | ||
description: 'editor.footer.description', | ||
type: 'object', | ||
} | ||
} | ||
|
||
export default FooterLayout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react' | ||
import classNames from 'classnames' | ||
import { withRuntimeContext } from 'vtex.render-runtime' | ||
import { Functions } from '@gocommerce/utils' | ||
import withImage from './components/withImage' | ||
import style from './components/PoweredBy.css' | ||
|
||
/** | ||
* "Powered By VTEX/GoCommerce" image component, used in Footer | ||
*/ | ||
const PoweredBy: StorefrontFunctionComponent<PoweredByProps> = ({ | ||
runtime, | ||
imageSrc, | ||
}) => { | ||
if (!imageSrc) { | ||
return null | ||
} | ||
|
||
const isPlatformGCResult = Functions.isGoCommerceAcc(runtime.account) | ||
|
||
return ( | ||
<div | ||
className={classNames(style.poweredBy, 'flex items-center', { | ||
w4: isPlatformGCResult, | ||
'h3 w3': !isPlatformGCResult, | ||
})}> | ||
<img | ||
className={`${style.poweredByImage} w-100`} | ||
src={imageSrc} | ||
title={isPlatformGCResult ? 'GoCommerce' : 'VTEX'} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
interface PoweredByProps extends PoweredBySchema { | ||
runtime: { | ||
account: string | ||
} | ||
logoUrl: string | ||
imageSrc: string | ||
} | ||
|
||
interface PoweredBySchema { | ||
showInColor: boolean | ||
} | ||
|
||
PoweredBy.displayName = 'PoweredBy' | ||
|
||
const getImagePathFromProps = ({ runtime, showInColor }: PoweredByProps) => | ||
`${Functions.isGoCommerceAcc(runtime.account) ? 'GoCommerce' : 'VTEX'}${ | ||
showInColor ? '' : '-BW' | ||
}.svg` | ||
|
||
export default withRuntimeContext(withImage(getImagePathFromProps)(PoweredBy)) |
Oops, something went wrong.