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

feat(cx-templates, cx-flowcontainer): Add generic template #1483

Merged
merged 38 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8d03ecb
WIP on generic template
wodenx Mar 23, 2022
151c13d
Fix issue with nested tokens (#1455)
wodenx Mar 24, 2022
70e64eb
Clean template & start shadow
hvanyo Mar 23, 2022
804a6b3
Cleanup and renaming
wodenx Mar 24, 2022
83a08d2
Merge remote-tracking branch 'heidi/fix/generic-v3' into feature/cx-g…
wodenx Mar 24, 2022
a31fb37
Some cleanup, remove hero flow container.
wodenx Mar 24, 2022
bf3b9af
Add gutter to content region
hvanyo Mar 24, 2022
33e50ef
add copyright
hvanyo Mar 24, 2022
7694f68
Fix broken styleguide tokens.
wodenx Mar 25, 2022
5ab8a67
Merge remote-tracking branch 'upstream/main' into feature/cx-generic-…
wodenx Mar 25, 2022
83c6341
Merge remote-tracking branch 'upstream/main' into feature/cx-generic-…
wodenx Mar 29, 2022
f60e48f
fix some issues after merge
wodenx Mar 29, 2022
5608cad
Fix lint
wodenx Mar 29, 2022
7c157f2
move wrapper
hvanyo Mar 29, 2022
5d73137
8512: Add design keys for testing identifiers
hvanyo Mar 29, 2022
5f73310
8541 Add Breadcrumb placeholder & style
hvanyo Mar 30, 2022
a2318bb
AESQ-8536 add border to demonstrate contentregion
hvanyo Mar 30, 2022
29a7c28
8543 Fix lint & add tailwind
hvanyo Mar 30, 2022
de93891
Correct name of footer styleguide page.
wodenx Mar 30, 2022
26d9c27
8537
hvanyo Mar 30, 2022
0db72d3
8549 & 8550
hvanyo Mar 30, 2022
7073958
fix build error
hvanyo Mar 30, 2022
041cccd
Merge pull request #46 from hvanyo/fix/generic-v5
wodenx Mar 30, 2022
bcbf96e
Add tailwind to cx-flowcontainer
hvanyo Mar 30, 2022
05faeab
Merge pull request #47 from hvanyo/fix/generic-v6
wodenx Mar 30, 2022
cd150b9
remove dup of generic template & header/footer
hvanyo Mar 30, 2022
05c5135
Merge pull request #48 from hvanyo/fix/generic-v6
wodenx Mar 30, 2022
8e9e8e8
fix build error
hvanyo Mar 30, 2022
92909e3
Merge pull request #49 from hvanyo/fix/generic-v6
wodenx Mar 30, 2022
0519b00
Single Constrained Flow container & fragments
hvanyo Mar 31, 2022
9a21eee
Move SiteContraint from Wrapper -> container
hvanyo Mar 31, 2022
82f9e22
Merge branch 'main' into feature/cx-generic-template
TatsianaMiraniuk Apr 1, 2022
96af00c
Merge pull request #51 from hvanyo/fix/generic-v7
wodenx Apr 1, 2022
4ceb3c9
Move breadcrumb over hero/top
hvanyo Apr 1, 2022
7f999a1
Merge pull request #53 from hvanyo/fix/generic-v8
wodenx Apr 3, 2022
c59bba9
Merge branch 'main' into feature/cx-generic-template
TatsianaMiraniuk Apr 4, 2022
a1341fa
comment out cypress
hvanyo Apr 4, 2022
0e598b7
Merge pull request #54 from hvanyo/fix/generic-v8
wodenx Apr 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-test-lint-simple.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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' }),
},
}),
};
Original file line number Diff line number Diff line change
@@ -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,
};
Original file line number Diff line number Diff line change
@@ -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),
},
});
Original file line number Diff line number Diff line change
@@ -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),
},
});
Original file line number Diff line number Diff line change
@@ -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),
},
});
Original file line number Diff line number Diff line change
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),
},
});
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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