Skip to content

Commit

Permalink
Merge 1d3b40d into 83a7567
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilherme-Almeida-Zeni committed Mar 28, 2022
2 parents 83a7567 + 1d3b40d commit 62526a2
Show file tree
Hide file tree
Showing 109 changed files with 2,538 additions and 51 deletions.
15 changes: 15 additions & 0 deletions packages/__cxstarter__/src/components/Footer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright © 2022 Johnson & Johnson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export { __cxstarter__Footer } from './tokens';
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright © 2022 Johnson & Johnson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { cxFooter, asFooterToken } from '@bodiless/cx-layout';

const Default = asFooterToken({
...cxFooter.Default,
Components: {
...cxFooter.Default.Components,
},
});

export default {
...cxFooter,
Default,
};
17 changes: 17 additions & 0 deletions packages/__cxstarter__/src/components/Footer/tokens/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright © 2022 Johnson & Johnson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import __cxstarter__Footer from './__cxstarter__Footer';

export { __cxstarter__Footer };
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
*/

import { cxLayout, asLayoutToken } from '@bodiless/cx-layout';
import { __cxstarter__Footer } from '../../Footer';
import { __cxstarter__Header } from '../../Header';

const Default = asLayoutToken({
...cxLayout.Default,
Components: {
...cxLayout.Default.Components,
SiteHeader: __cxstarter__Header.Default,
Header: __cxstarter__Header.Default,
Footer: __cxstarter__Footer.Default,
},
Compose: {
...cxLayout.Default.Compose,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import { asStyleGuideTemplateToken, cxStyleGuideTemplate } from '@bodiless/cx-templates';
import { flowHoc, replaceWith } from '@bodiless/fclasses';

export const Footer = asStyleGuideTemplateToken(cxStyleGuideTemplate.FooterOnly, {
Meta: flowHoc.meta.term('Token')('Footer'),
Content: {
Title: replaceWith(() => <>Footer</>),
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const Examples = () => (
<ul>
<li><a href="./layout">Layout</a></li>
<li><a href="./header">Header</a></li>
<li><a href="./footer">Footer</a></li>
<li><a href="./editors">Editors</a></li>
<li><a href="./editors-monofont">Editors with MonoFont</a></li>
<li><a href="./typography">Typography</a></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Editors, EditorsMonoFont } from './Editors';
import { Typography } from './Typography';
import { Layout } from './Layout';
import { Header } from './Header';
import { Footer } from './Footer';
import { _default } from './_default';

export const __cxstarter__StyleGuideTemplate = {
Expand All @@ -25,4 +26,5 @@ export const __cxstarter__StyleGuideTemplate = {
Typography,
Layout,
Header,
Footer,
};
2 changes: 2 additions & 0 deletions packages/__cxstarter__/src/styleguide/Page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const {
Typography,
Layout,
Header,
Footer,
_default
} = __cxstarter__StyleGuideTemplate;

Expand All @@ -36,6 +37,7 @@ const Default = asFluidToken({
Typography,
Layout,
Header,
Footer,
},
});

Expand Down
26 changes: 18 additions & 8 deletions packages/bodiless-core/src/withChild.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import omit from 'lodash/omit';

type InsertChildOptions = {
designKey: string,
componentName: string,
mode?: 'append' | 'prepend',
};

Expand All @@ -38,7 +39,7 @@ const insertChild = (Child: CT, options: InsertChildOptions): HOC => (
Component = Fragment,
) => {
type Components = { [Child: string]: CT };
const { designKey, mode } = options;
const { designKey, componentName, mode } = options;
const startComponents: Components = { [designKey]: Child };
const WithChild: FC<any> = (props: PropsWithChildren<DesignableComponentsProps<Components>>) => {
const { components, ...rest } = props;
Expand Down Expand Up @@ -68,7 +69,7 @@ const insertChild = (Child: CT, options: InsertChildOptions): HOC => (
}
};
const applyDesign = extendDesignable(design => omit(design, [designKey]));
return applyDesign(startComponents, designKey)(WithChild) as ComponentType<any>;
return applyDesign(startComponents, componentName)(WithChild) as ComponentType<any>;
};

/**
Expand All @@ -77,6 +78,7 @@ const insertChild = (Child: CT, options: InsertChildOptions): HOC => (
*
* @param Child - Component to add as a child
* @param designKey - Design key to reach the Child component using Design API.
* @param componentName - Optional component namespace for design key data attribute.
*
* @return An HOC which will add the Child to the given Parent.
*
Expand All @@ -97,34 +99,42 @@ const insertChild = (Child: CT, options: InsertChildOptions): HOC => (
* ```
*/
const withChild = <P extends object>(
Child: CT, designKey = 'Child',
): HOC<P> => insertChild(Child, { designKey });
Child: CT,
designKey: string = 'Child',
componentName: string = 'Component',
): HOC<P> => insertChild(Child, { designKey, componentName });

/**
* Utility function to append a Child to the given component
* so that the Child can be altered using Design API.
*
* @param Child - Component to add as a child
* @param designKey - Design key to reach the Child component using Design API.
* @param componentName - Optional component namespace for design key data attribute.
*
* @return An HOC which will append the Child to the given Component.
*/
const withAppendChild = <P extends object>(
Child: CT, designKey: string,
): HOC<P> => insertChild(Child, { designKey, mode: 'append' });
Child: CT,
designKey: string,
componentName: string = 'Component',
): HOC<P> => insertChild(Child, { designKey, componentName, mode: 'append' });

/**
* Utility function to prepend a Child to the given component
* so that the Child can be altered using Design API.
*
* @param Child - Component to add as a child
* @param designKey - Design key to reach the Child component using Design API.
* @param componentName - Optional component namespace for design key data attribute.
*
* @return An HOC which will prepend the Child to the given Component.
*/
const withPrependChild = <P extends object>(
Child: CT, designKey: string,
): HOC<P> => insertChild(Child, { designKey, mode: 'prepend' });
Child: CT,
designKey: string,
componentName: string = 'Component',
): HOC<P> => insertChild(Child, { designKey, componentName, mode: 'prepend' });

export default withChild;
export {
Expand Down
9 changes: 7 additions & 2 deletions packages/bodiless-core/src/withParent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { HOC, DesignableComponentsProps, extendDesignable } from '@bodiless/fcla
*
* @param Parent - Component to add as a Parent
* @param designKey - A Design key to reach the Parent. 'Parent' by default.
* @param componentName - Optional component namespace for design key data attribute.
*
* @return An HOC which will wrap the given Child component with provided Parent.
*
Expand All @@ -39,7 +40,11 @@ import { HOC, DesignableComponentsProps, extendDesignable } from '@bodiless/fcla
* )(Child);
* ```
*/
const withParent = (Parent: ComponentType, designKey: string = 'Parent'): HOC => (
const withParent = (
Parent: ComponentType,
designKey: string = 'Parent',
componentName: string = 'Component',
): HOC => (
Component,
) => {
type Components = { [Parent: string]: ComponentType };
Expand All @@ -55,7 +60,7 @@ const withParent = (Parent: ComponentType, designKey: string = 'Parent'): HOC =>
);
};
const applyDesign = extendDesignable(design => omit(design, [designKey]));
return applyDesign(startComponents, designKey)(WithParent) as ComponentType<any>;
return applyDesign(startComponents, componentName)(WithParent) as ComponentType<any>;
};

export default withParent;
2 changes: 1 addition & 1 deletion packages/bodiless-navigation/src/Menu/MenuTitles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
withDesign, startWith, DesignableComponentsProps,
} from '@bodiless/fclasses';

type MenuTitleComponents = {
export type MenuTitleComponents = {
Link: ComponentType<any>,
Title: ComponentType<any>,
};
Expand Down
7 changes: 6 additions & 1 deletion packages/bodiless-navigation/src/Menu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import asTopNav, {
import { useIsMenuOpen, useMenuContext } from './withMenuContext';
import { useSubmenuContext } from './withMenuItemContext';
import { withListSubMenu, withCardsSubMenu, withColumnSubMenu } from './withSubMenu';
import { withMenuTitleEditors, withDefaultMenuTitleEditors, asMenuTitle } from './MenuTitles';
import MenuTitle, {
withMenuTitleEditors, withDefaultMenuTitleEditors, asMenuTitle,
} from './MenuTitles';
import type { MenuTitleComponents } from './MenuTitles';

export {
asBodilessMenu,
Expand All @@ -42,6 +45,8 @@ export {
isMenuContextNotActive,
withMenuTitleEditors,
withDefaultMenuTitleEditors,
MenuTitle,
MenuTitleComponents,
};

export * from './asAccessibleMenu';
47 changes: 44 additions & 3 deletions packages/cx-editors/src/components/RichText/tokens/cxRichText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* limitations under the License.
*/

import pick from 'lodash/pick';
import {
replaceWith,
P,
Expand All @@ -22,6 +23,7 @@ import {
H4,
H5,
startWith,
removeClasses,
} from '@bodiless/fclasses';
import {
asBlock,
Expand All @@ -42,7 +44,11 @@ import {
} from '@bodiless/components';
import { ifComponentSelector } from '@bodiless/layouts';
import {
asCxTokenSpec, cxTextDecoration, cxTypography,
asCxTokenSpec,
cxColor,
cxFontSize,
cxTextDecoration,
cxTypography,
} from '@bodiless/cx-elements';
import { LinkClean, cxLink } from '@bodiless/cx-link';

Expand Down Expand Up @@ -85,7 +91,7 @@ const Default = asCxTokenSpec()({
Content: {
_: addProps({ placeholder: 'Placeholder' }),
},
Components: {
Theme: {
paragraph: cxTypography.Body,
Bold: cxTextDecoration.Bold,
Underline: cxTextDecoration.Underline,
Expand All @@ -105,4 +111,39 @@ const Default = asCxTokenSpec()({
},
});

export default { Default, AsFlowContainerItem };
const Basic = asCxTokenSpec()({
...Default,
Core: pick(Default.Core, 'paragraph', 'Bold', 'Underline', 'Link', 'SuperScript'),
Theme: pick(Default.Theme, 'paragraph', 'Bold', 'Underline', 'Link', 'SuperScript'),
});

const Copyright = asCxTokenSpec()({
...Basic,
Theme: {
...Basic.Theme,
paragraph: as(
cxColor.TextPrimaryFooterCopy,
cxFontSize.XS,
cxTextDecoration.Normal,
),
Link: as(
cxLink.Default,
cxColor.TextPrimaryFooterCopy,
cxColor.TextPrimaryInteractive,
cxFontSize.XS,
cxTextDecoration.Bold,
cxTextDecoration.Underline,
removeClasses('text-m-base lg:text-base'),
),
},
Content: {
_: addProps({ placeholder: 'Insert Copyright' }),
},
});

export default {
Default,
Basic,
AsFlowContainerItem,
Copyright,
};

0 comments on commit 62526a2

Please sign in to comment.