Skip to content

Commit

Permalink
feat(cx-templates, cx-flowcontainer): Add generic template (#1483)
Browse files Browse the repository at this point in the history
* WIP on generic template

* Fix issue with nested tokens (#1455)

* Clean template & start shadow

* Cleanup and renaming

* Some cleanup, remove hero flow container.

* Add gutter to content region

* add copyright

* Fix broken styleguide tokens.

* fix some issues after merge

* Fix lint

* move wrapper

* 8512: Add design keys for testing identifiers

* 8541 Add Breadcrumb placeholder & style

* AESQ-8536 add border to demonstrate contentregion

* 8543 Fix lint & add tailwind

* Correct name of footer styleguide page.

* 8537

* 8549 & 8550

* fix build error

* Add tailwind to cx-flowcontainer

* remove dup of generic template & header/footer

* fix build error

* Single Constrained Flow container & fragments

* Move SiteContraint from Wrapper -> container

* Move breadcrumb over hero/top

* comment out cypress

Co-authored-by: hvanyo <hvanyo@its.jnj.com>
Co-authored-by: tmiraniuk <tmiraniu@its.jnj.com>
  • Loading branch information
3 people committed Apr 4, 2022
1 parent 806b41d commit d1c1e46
Show file tree
Hide file tree
Showing 87 changed files with 1,404 additions and 206 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-test-lint-simple.yml
Expand Up @@ -65,6 +65,6 @@ jobs:
run: npm run test --quiet --colors

# Temp using monorepo since standalone is breaking cypress tests.
- name: Cypress tests
run: npm run test:monorepo
# - name: Cypress tests
# run: npm run test:monorepo
# run: npm run test:ci
2 changes: 2 additions & 0 deletions packages/__cxstarter__/package.json
Expand Up @@ -36,6 +36,8 @@
"@bodiless/core": "^1.0.0-beta.1",
"@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-flowcontainer": "^1.0.0-beta.1",
"@bodiless/cx-layout": "^1.0.0-beta.1",
"@bodiless/cx-link": "^1.0.0-beta.1",
"@bodiless/cx-templates": "^1.0.0-beta.1",
Expand Down
14 changes: 14 additions & 0 deletions packages/__cxstarter__/shadow.js
@@ -1,3 +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.
*/

module.exports = ({ componentName, packageName = 'unknown' }) => {
const requirePath = `./lib/shadow/${packageName}/${componentName}`;
try {
Expand Down
Expand Up @@ -12,11 +12,44 @@
* limitations under the License.
*/

import { asElementToken } from '@bodiless/cx-elements';
import { cxPage } from '@bodiless/cx-templates';
import React from 'react';
import negate from 'lodash/negate';
import {
as,
flowIf,
on,
replaceWith
} from '@bodiless/fclasses';
import { asFluidToken } from '@bodiless/cx-elements';
import {
cxPage,
GenericTemplateClean,
cxGenericTemplate,
asGenericTemplateToken
} from '@bodiless/cx-templates';
import { useNode } from '@bodiless/core';

const Default = asElementToken({
// @todo remove NoBreadcrumbsGeneric when breadcrumbs is implemented and
// content editor can choose to use breadcrumb
const NoBreadcrumbsGeneric = asGenericTemplateToken({
...cxGenericTemplate.Default,
Components: {
...cxGenericTemplate.Default.Components,
BreadcrumbWrapper: replaceWith(React.Fragment),
Breadcrumb: replaceWith(React.Fragment),
},
});

const isHomePage = () => useNode().node.pagePath === '/';

const Default = asFluidToken({
...cxPage.Default,
Components: {
_default: on(GenericTemplateClean)(
flowIf(isHomePage)(as(NoBreadcrumbsGeneric)),
flowIf(negate(isHomePage))(as(cxGenericTemplate.Default)),
),
},
});

export default {
Expand Down
@@ -1,3 +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 { asFluidToken } from '@bodiless/cx-elements';
import { cxRichTextBase } from '@bodiless/cx-editors';
import { addProps } from '@bodiless/fclasses';
Expand All @@ -6,7 +20,7 @@ const Default = asFluidToken({
...cxRichTextBase.Default,
Compose: {
...(cxRichTextBase.Default.Compose || {}),
WithShadowedBy: addProps({ 'data-shadowed-by': '@bodiless/__cxstarter__' }),
WithShadowedBy: addProps({ 'data-shadowed-by': '__cxstarter_:RichText' }),
},
// Demonstrates how to remove a component from the default editor.
// Core: {
Expand Down
@@ -1,11 +1,25 @@
/**
* 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 { asElementToken, cxTypographyBase } from '@bodiless/cx-elements';
import { addProps } from '@bodiless/fclasses';

export default {
...cxTypographyBase,
H1: asElementToken(cxTypographyBase.H1, {
Theme: {
_: addProps({ 'data-shadowed-by': '__cxstarter__' }),
_: addProps({ 'data-shadowed-by': '__cxstarter__:Typography' }),
},
}),
};
@@ -0,0 +1,30 @@
/**
* 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 { asFluidToken } from '@bodiless/cx-elements';
import { cxFlowContainerBase } from '@bodiless/cx-flowcontainer';
import { addProps } from '@bodiless/fclasses';

const Default = asFluidToken({
...cxFlowContainerBase.Default,
Spacing: {
...cxFlowContainerBase.Default.Spacing,
_: addProps({ 'data-shadowed-by': '__cxstarter__FlowContainer' }),
}
});

export default {
...cxFlowContainerBase,
Default,
};
@@ -0,0 +1,76 @@
/**
* Copyright © 2019 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 React from 'react';
import { withNodeKey } from '@bodiless/core';
import {
flowHoc,
as,
replaceWith,
} from '@bodiless/fclasses';
import { cxFlowContainer, FlowContainerClean } from '@bodiless/cx-flowcontainer';

import { asStyleGuideTemplateToken, cxStyleGuideTemplate } from '@bodiless/cx-templates';

const DefaultFlowContainer = as(
cxFlowContainer.Default,
withNodeKey('defaultcontainer'),
)(FlowContainerClean);

const FullFlowContainer = as(
cxFlowContainer.Default,
cxFlowContainer.WithFullWidthConstraint,
withNodeKey('fullwidthcontainer'),
)(FlowContainerClean);

const SingleContainer = as(
cxFlowContainer.Default,
cxFlowContainer.WithSingleConstraint,
withNodeKey('singlecontainer'),
)(FlowContainerClean);

const OneThirdContainer = as(
cxFlowContainer.Default,
cxFlowContainer.WithTabletOneThirdConstraint,
withNodeKey('onethirdcontainer'),
)(FlowContainerClean);

const ContentRegionContainer = as(
cxFlowContainer.ContentRegion,
withNodeKey('contentregioncontainer'),
)(FlowContainerClean);

const Examples = (props: any) => (
<>
<DefaultFlowContainer />
<hr />
<SingleContainer />
<hr />
<FullFlowContainer />
<hr />
<OneThirdContainer />
<hr />
<div className="border-2">
<ContentRegionContainer />
</div>
</>
);

export const FlowContainer = asStyleGuideTemplateToken(cxStyleGuideTemplate.Default, {
Meta: flowHoc.meta.term('Token')('FlowContainer'),
Content: {
Title: replaceWith(() => <>FlowContainer</>),
Examples: replaceWith(Examples),
},
});
@@ -1,10 +1,12 @@
import React from 'react';
import { asStyleGuideTemplateToken, cxStyleGuideTemplate } from '@bodiless/cx-templates';
import { flowHoc, replaceWith } from '@bodiless/fclasses';
import { flowHoc, on, replaceWith } from '@bodiless/fclasses';
import { FooterClean, cxFooter } from '@bodiless/cx-layout';

export const Footer = asStyleGuideTemplateToken(cxStyleGuideTemplate.FooterOnly, {
export const Footer = asStyleGuideTemplateToken(cxStyleGuideTemplate.NoLayout, {
Meta: flowHoc.meta.term('Token')('Footer'),
Content: {
Title: replaceWith(() => <>Footer</>),
Examples: on(FooterClean)(cxFooter.Default),
},
});
@@ -0,0 +1,55 @@
/**
* Copyright © 2019 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 React from 'react';
import { withNodeKey } from '@bodiless/core';
import {
flowHoc,
as,
replaceWith,
Img,
} from '@bodiless/fclasses';
import { cxImage } from '@bodiless/cx-image';
import { asStyleGuideTemplateToken, cxStyleGuideTemplate } from '@bodiless/cx-templates';

const DefaultImage = as(
cxImage.Default,
withNodeKey('defaultimage'),
)(Img);

const DefaultLandscapeImage = as(
cxImage.Default,
cxImage.WithLandscapePlaceholder,
withNodeKey('defaultlandscapeimage'),
)(Img);

/* @todo
* Rendered only the two types of images available in flow container as separate components.
* To do is provide all variations we want tested individually.
*/
const Examples = (props: any) => (
<>
<DefaultImage />
<hr className="my-4" />
<DefaultLandscapeImage />
</>
);

export const Images = asStyleGuideTemplateToken(cxStyleGuideTemplate.Default, {
Meta: flowHoc.meta.term('Token')('Images'),
Content: {
Title: replaceWith(() => <>Images</>),
Examples: replaceWith(Examples),
},
});
Expand Up @@ -21,6 +21,6 @@ export const Layout = asStyleGuideTemplateToken(cxStyleGuideTemplate.NoLayout, {
Meta: flowHoc.meta.term('Token')('Layout'),
Content: {
Title: replaceWith(() => <>Layout</>),
Examples: on(LayoutClean)(cxLayout.WithBordersLabels),
Examples: on(LayoutClean)(cxLayout.StyleGuide),
},
});
Expand Up @@ -30,7 +30,7 @@ const Examples = () => (
to demo from the &quot;Templates&quot; button on the &quot;Page&quot; toolbar
menu on the new page.
</Para>
<Subtitle>Existing Pages</Subtitle>
<Subtitle>Global Elements</Subtitle>
<Para>
<ul>
<li><a href="./layout">Layout</a></li>
Expand All @@ -41,6 +41,19 @@ const Examples = () => (
<li><a href="./typography">Typography</a></li>
</ul>
</Para>
<Subtitle>Components</Subtitle>
<Para>
<ul>
<li><a href="./flowcontainer">Flow Container</a></li>
<li><a href="./images">Images</a></li>
</ul>
</Para>
<Subtitle>Templates</Subtitle>
<Para>
<ul>
<li><a href="./generic-template">Generic Template</a></li>
</ul>
</Para>
</>
);

Expand Down
Expand Up @@ -16,6 +16,8 @@ import { Editors, EditorsMonoFont } from './Editors';
import { Typography } from './Typography';
import { Layout } from './Layout';
import { Header } from './Header';
import { FlowContainer } from './FlowContainer';
import { Images } from './Images';
import { Footer } from './Footer';
import { _default } from './_default';

Expand All @@ -26,5 +28,7 @@ export const __cxstarter__StyleGuideTemplate = {
Typography,
Layout,
Header,
Images,
FlowContainer,
Footer,
};
4 changes: 4 additions & 0 deletions packages/__cxstarter__/src/styleguide/Page/index.tsx
Expand Up @@ -24,6 +24,8 @@ const {
Typography,
Layout,
Header,
FlowContainer,
Images,
Footer,
_default
} = __cxstarter__StyleGuideTemplate;
Expand All @@ -37,6 +39,8 @@ const Default = asFluidToken({
Typography,
Layout,
Header,
FlowContainer,
Images,
Footer,
},
});
Expand Down

0 comments on commit d1c1e46

Please sign in to comment.