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 6 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Default = asLayoutToken({
...cxLayout.Default,
Components: {
...cxLayout.Default.Components,
SiteHeader: __cxstarter__Header.Default,
Header: __cxstarter__Header.Default,
},
Compose: {
...cxLayout.Default.Compose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
* limitations under the License.
*/

import { asElementToken } from '@bodiless/cx-elements';
import { cxPage } from '@bodiless/cx-templates';
import { on } from '@bodiless/fclasses';
import { asFluidToken } from '@bodiless/cx-elements';
import { cxPage, GenericTemplateClean, cxGenericTemplate } from '@bodiless/cx-templates';

const Default = asElementToken({
const Default = asFluidToken({
...cxPage.Default,
Components: {
_default: on(GenericTemplateClean)(cxGenericTemplate.Default),
},
});

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,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
Expand Up @@ -5,7 +5,7 @@ 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
Expand Up @@ -12,33 +12,19 @@
* limitations under the License.
*/

import {
replaceWith,
Fragment,
on,
} from '@bodiless/fclasses';
import { LayoutClean, cxLayout } from '@bodiless/cx-layout';
import { asGenericTemplateToken } from '../GenericClean';
import { asFluidToken } from '@bodiless/cx-elements';
import { cxFlowContainerBase } from '@bodiless/cx-flowcontainer';
import { addProps } from '@bodiless/fclasses';

const Default = asGenericTemplateToken({
Components: {
PageWrapper: on(LayoutClean)(cxLayout.Default),
},
Schema: {
},
SEO: {
},
Theme: {
},
const Default = asFluidToken({
...cxFlowContainerBase.Default,
Spacing: {
...cxFlowContainerBase.Default.Spacing,
_: addProps({ 'data-shadowed-by': '__cxstarter__FlowContainer' }),
}
});

const WithoutBreadcrumbs = asGenericTemplateToken({
Components: {
Breadcrumb: replaceWith(Fragment),
},
});

export const cxGenericTemplate = {
export default {
...cxFlowContainerBase,
Default,
WithoutBreadcrumbs,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* 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 OneThirdContainer = as(
cxFlowContainer.Default,
cxFlowContainer.WithTabletOneThirdConstraint,
withNodeKey('onethirdcontainer'),
)(FlowContainerClean);

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

const Examples = (props: any) => (
<>
<DefaultFlowContainer />
<hr />
<FullFlowContainer />
<hr />
<OneThirdContainer />
<hr />
<ContentRegionContainer />
</>
);

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
@@ -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 @@ -40,6 +40,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 { _default } from './_default';

export const __cxstarter__StyleGuideTemplate = {
Expand All @@ -25,4 +27,6 @@ export const __cxstarter__StyleGuideTemplate = {
Typography,
Layout,
Header,
Images,
FlowContainer,
};
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,
_default
} = __cxstarter__StyleGuideTemplate;

Expand All @@ -36,6 +38,8 @@ const Default = asFluidToken({
Typography,
Layout,
Header,
FlowContainer,
Images,
},
});

Expand Down
11 changes: 11 additions & 0 deletions packages/cx-editors/src/components/FlowContainer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { asFluidToken } from '@bodiless/cx-elements';
import { on } from '@bodiless/fclasses';
import { cxRichText, RichTextClean } from '../RichText';

const WithEditorVariations = asFluidToken({
Components: {
RichText: on(RichTextClean)(cxRichText.Default),
},
});

export const cxEditorsFlowContainer = { WithEditorVariations };
1 change: 1 addition & 0 deletions packages/cx-editors/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
export * from './withEditor';
export * from './components/RichText';
export * from './components/EditorPlain';
export * from './components/FlowContainer';
2 changes: 1 addition & 1 deletion packages/cx-elements/doc/CX_Elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Foo = {
};
```

If combining multiple tokens, you can put them within `as()` or `flowHOC()`:
If combining multiple tokens, you can put them within `as()` or `flowHoc()`:

```js
import { cxColor, cxTextDecoration } from '@bodiless/cx-elements';
Expand Down
4 changes: 3 additions & 1 deletion packages/cx-elements/site.tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ module.exports = {
margin: {
4.5: '1.125rem',
5.75: '1.438rem',
}
'site-percent': '5%',
'md-site-percent': '8%',
},
},
},
variants: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@
* limitations under the License.
*/

export { GenericTemplateClean, asGenericTemplateToken } from './GenericClean';
export { cxGenericTemplate } from './tokens/token';
export type { GenericTemplateComponents, BaseGenericTemplateProps } from './types';
export { default as cxSpacing } from './tokens';
export { default as cxSpacingBase } from './tokens/cxSpacing';
35 changes: 35 additions & 0 deletions packages/cx-elements/src/components/Spacing/tokens/cxSpacing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* 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 { asTokenGroup } from '../../../util';

const meta = {
categories: {
Type: ['Element'],
Group: ['Spacing'],
},
};

/*
* Tailwind's container is specifically not used due to its feature it set's max-width
* to min-width of breakpoint. So instead rely on ContainerWrapper to margin percent
* to contain content (WithSiteMargin) until we get to xl and then constrain by
* max-width (WithSiteXLConstraint).
*/
export default asTokenGroup(meta)({
WithSiteMargin: 'mx-site-percent md:mx-md-site-percent xl:px-40',
WithSiteXLConstraint: 'xl:container xl:mx-auto',
Gutter: 'p-1 md:p-2 lg:p-3',
GutterOffset: '-mx-1 md:-mx-2 lg:-mx-3',
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
* limitations under the License.
*/

import React from 'react';
import tokens from './cxSpacing';

export default () => (
<>
Placeholder home page
</>
);
export default tokens;
1 change: 1 addition & 0 deletions packages/cx-elements/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export * from './components/Typography';
export * from './components/Color';
export * from './components/TextDecoration';
export * from './components/FontSize';
export * from './components/Spacing';
export * from './util';