Skip to content

Commit

Permalink
Feature/bc navigation (johnsonandjohnson#19)
Browse files Browse the repository at this point in the history
* Replace WTB with styled link

* Fix lint
  • Loading branch information
wodenx committed Mar 29, 2022
1 parent af2b686 commit c5ff2d8
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 191 deletions.
1 change: 1 addition & 0 deletions packages/cx-layout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@bodiless/cx-editors": "^1.0.0-beta.1",
"@bodiless/cx-elements": "^1.0.0-beta.1",
"@bodiless/cx-image": "^1.0.0-beta.1",
"@bodiless/cx-link": "^1.0.0-beta.1",
"@bodiless/cx-navigation": "^1.0.0-beta.1",
"@bodiless/fclasses": "^1.0.0-beta.1",
"@bodiless/gatsby-theme-bodiless": "^1.0.0-beta.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/cx-layout/src/components/Header/HeaderClean.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import React, { FC } from 'react';
import { Div, Fragment, designable } from '@bodiless/fclasses';
import { withoutHydration } from '@bodiless/hydration';
import { asCxTokenSpec } from '@bodiless/cx-elements';
import { LinkClean } from '@bodiless/cx-link';
import {
BurgerMenuClean,
MenuClean,
MenuTogglerClean,
} from '@bodiless/cx-navigation';
import { LogoClean } from '../Logo';
import { SearchTogglerClean, DesktopSearchClean } from '../Search';
import { WhereToBuyClean } from '../WhereToBuy';
import type { HeaderComponents, HeaderProps } from './types';

const headerComponents: HeaderComponents = {
Expand All @@ -44,7 +44,7 @@ const headerComponents: HeaderComponents = {
SearchToggler: SearchTogglerClean,
LanguageButton: Fragment,
WhereToBuyWrapper: Fragment,
WhereToBuy: WhereToBuyClean,
WhereToBuy: LinkClean,
};

const HeaderCleanBase: FC<HeaderProps> = ({ components: C, ...rest }) => (
Expand Down
5 changes: 2 additions & 3 deletions packages/cx-layout/src/components/Header/tokens/cxHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import {
withDesign,
withProps,
} from '@bodiless/fclasses';
import { cxLink } from '@bodiless/cx-link';
import { cxLogo } from '../../Logo';
import { cxDesktopSearch, cxSearchToggler } from '../../Search';
import { cxWhereToBuy, WhereToBuyClean } from '../../WhereToBuy';
import { asHeaderToken } from '../HeaderClean';

// @TODO: Get rid of this after language button is implemented.
Expand Down Expand Up @@ -60,7 +60,6 @@ const Base = asHeaderToken({
// @TODO: Is there a better way to inject WhereToBuy and (future) LanguageButton
// components into the menu? Maybe, move the components to another package...
withDesign({
WhereToBuy: replaceWith(as(cxWhereToBuy.WithoutIcon)(WhereToBuyClean)),
// @TODO: Replace LanguageButton placeholder.
LanguageButton: WithLanguageButton,
}),
Expand All @@ -69,7 +68,7 @@ const Base = asHeaderToken({
UtilityMenu: cxMenu.Utility,
// @TODO: Replace LanguageButton placeholder.
LanguageButton: WithLanguageButton,
WhereToBuy: cxWhereToBuy.Default,
WhereToBuy: cxLink.WhereToBuy,
},
Layout: {
Container: 'flex justify-between items-center',
Expand Down
47 changes: 0 additions & 47 deletions packages/cx-layout/src/components/WhereToBuy/WhereToBuyClean.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions packages/cx-layout/src/components/WhereToBuy/index.ts

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions packages/cx-layout/src/components/WhereToBuy/tokens/index.ts

This file was deleted.

29 changes: 0 additions & 29 deletions packages/cx-layout/src/components/WhereToBuy/types.ts

This file was deleted.

2 changes: 2 additions & 0 deletions packages/cx-link/src/components/Link/LinkClean.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ import { LinkComponents, LinkBaseProps } from './types';

const linkComponents: LinkComponents = {
Wrapper: A,
Icon: Fragment,
Body: Span,
ExternalSRText: Fragment,
};

const LinkBase: FC<LinkBaseProps> = ({ components: C, children, ...rest }) => (
<C.Wrapper {...rest}>
<C.ExternalSRText />
<C.Icon />
<C.Body>
{children}
</C.Body>
Expand Down
45 changes: 42 additions & 3 deletions packages/cx-link/src/components/Link/tokens/cxLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
*/

import {
addProps, Span, addPropsIf, flowIf, as, on, addClassesIf
addProps, Span, addPropsIf, flowIf, as, on, addClassesIf, withProps, startWith
} from '@bodiless/fclasses';
import { withSidecarNodes, withNodeKey } from '@bodiless/core';
import { cxTypography } from '@bodiless/cx-elements';
import { cxColor, cxTextDecoration, cxTypography } from '@bodiless/cx-elements';
import { asLinkToken } from '../LinkClean';
import { useExternalLinkToggle, asEditableLink, useIsDownloadLink } from '../util';
import { CartIcon } from '../assets/CartIcon';

/**
* Token which causes link to display as an external link.
Expand Down Expand Up @@ -84,6 +85,44 @@ const Sidecar = asLinkToken({
},
});

const WhereToBuy = asLinkToken({
Components: {
Icon: startWith(CartIcon),
},
Layout: {
Wrapper: 'w-full lg:w-auto flex justify-center items-center max-w-64 h-12 lg:w-48',
},
Spacing: {
Wrapper: 'mx-auto p-3',
Icon: 'mr-3',
},
Theme: {
Wrapper: as(
cxColor.BgPrimaryInteractive,
cxColor.TextPrimaryFooterCopy,
cxTextDecoration.Bold,
cxTextDecoration.Uppercase,
// @TODO: Create token? It should be same size for both mobile and desktop...
'text-m-base',
'rounded',
),
Icon: 'w-6 h-6',
Body: 'leading',
},
Content: {
Wrapper: withProps({
href: '/where-to-buy',
}),
Body: withProps({
children: 'Where to Buy',
}),
},
});

export default {
Default, WithExternalStyles, WithDownloadStyles, Sidecar,
Default,
WithExternalStyles,
WithDownloadStyles,
Sidecar,
WhereToBuy,
};
1 change: 1 addition & 0 deletions packages/cx-link/src/components/Link/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ComponentOrTag, DesignableComponentsProps } from '@bodiless/fclasses';

export type LinkComponents = {
Wrapper: ComponentOrTag<any>,
Icon: ComponentOrTag<any>,
Body: ComponentOrTag<any>,
ExternalSRText: ComponentOrTag<any>,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import React, { FC } from 'react';
import { asCxTokenSpec } from '@bodiless/cx-elements';
import { Div, Fragment, designable } from '@bodiless/fclasses';
import { LinkClean } from '@bodiless/cx-link';
import { MenuClean } from '../Menu';
import { MenuTogglerClean } from '../MenuToggler';
import type { BurgerMenuComponents, BurgerMenuProps } from './types';
Expand All @@ -28,7 +29,7 @@ const burgerMenuComponents: BurgerMenuComponents = {
Menu: MenuClean,
FooterWrapper: Div,
WhereToBuyWrapper: Fragment,
WhereToBuy: Fragment,
WhereToBuy: LinkClean,
ActionFooterContainer: Div,
UtilityMenuWrapper: Fragment,
UtilityMenu: MenuClean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import { asStatic } from '@bodiless/core';
import { cxColor } from '@bodiless/cx-elements';
import { cxLink } from '@bodiless/cx-link';
import {
addClassesIf,
as,
Expand Down Expand Up @@ -48,6 +49,7 @@ const Base = asBurgerMenuToken({
MenuToggler: cxMenuToggler.Close,
Menu: cxMenu.Burger,
UtilityMenu: cxMenu.Utility,
WhereToBuy: cxLink.WhereToBuy,
},
Layout: {
Wrapper: 'w-full h-full fixed left-0 top-0 md:w-7/12 lg:hidden',
Expand Down

0 comments on commit c5ff2d8

Please sign in to comment.