Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] Add Convenience Components #1183

Merged
merged 4 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/template-retail-react-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## v2.8.0-dev (Mar 03, 2023)
- Add app `above-header` and product-list `above-page-header` convenience components [#1183](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/1183)
- Remove `cross-fetch` dependency [#1160](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/1160)
- Make `mergeBasket` conditional more robust [#1048](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/1048)

Expand Down
49 changes: 26 additions & 23 deletions packages/template-retail-react-app/app/components/_app/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import CheckoutFooter from '../../pages/checkout/partials/checkout-footer'
import DrawerMenu from '../drawer-menu'
import ListMenu from '../list-menu'
import {HideOnDesktop, HideOnMobile} from '../responsive'
import AboveHeader from './partials/above-header'

// Hooks
import {AuthModal, useAuthModal} from '../../hooks/use-auth-modal'
Expand Down Expand Up @@ -283,33 +284,35 @@ const App = (props) => {

<Box {...styles.headerWrapper}>
{!isCheckout ? (
<Header
onMenuClick={onOpen}
onLogoClick={onLogoClick}
onMyCartClick={onCartClick}
onMyAccountClick={onAccountClick}
onWishlistClick={onWishlistClick}
>
<HideOnDesktop>
<DrawerMenu
isOpen={isOpen}
onClose={onClose}
onLogoClick={onLogoClick}
root={categories?.[CAT_MENU_DEFAULT_ROOT_CATEGORY]}
/>
</HideOnDesktop>

<HideOnMobile>
<ListMenu
root={categories?.[CAT_MENU_DEFAULT_ROOT_CATEGORY]}
/>
</HideOnMobile>
</Header>
<>
<AboveHeader />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to have <AboveHeader /> show for checkout, better move it up and out from the condition !isCheckout ? ...

<Header
onMenuClick={onOpen}
onLogoClick={onLogoClick}
onMyCartClick={onCartClick}
onMyAccountClick={onAccountClick}
onWishlistClick={onWishlistClick}
>
<HideOnDesktop>
<DrawerMenu
isOpen={isOpen}
onClose={onClose}
onLogoClick={onLogoClick}
root={categories?.[CAT_MENU_DEFAULT_ROOT_CATEGORY]}
/>
</HideOnDesktop>

<HideOnMobile>
<ListMenu
root={categories?.[CAT_MENU_DEFAULT_ROOT_CATEGORY]}
/>
</HideOnMobile>
</Header>
</>
) : (
<CheckoutHeader />
)}
</Box>

{!isOnline && <OfflineBanner />}
<AddToCartModalProvider>
<SkipNavContent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright (c) 2023, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

const AboveHeader = () => null

export default AboveHeader
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import Refinements from './partials/refinements'
import SelectedRefinements from './partials/selected-refinements'
import EmptySearchResults from './partials/empty-results'
import PageHeader from './partials/page-header'
import AbovePageHeader from './partials/above-page-header'

// Icons
import {FilterIcon, ChevronDownIcon} from '../../components/icons'
Expand Down Expand Up @@ -380,8 +381,8 @@ const ProductList = (props) => {
<EmptySearchResults searchQuery={searchQuery} category={category} />
) : (
<>
<AbovePageHeader />
{/* Header */}

<Stack
display={{base: 'none', lg: 'flex'}}
direction="row"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright (c) 2023, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

const AbovePageHeader = () => null

export default AbovePageHeader
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
export default {
baseStyle: {
container: {
height: 'full',
minWidth: 'xs',
width: 'full',
boxShadow: 'base',
Expand Down