-
Notifications
You must be signed in to change notification settings - Fork 0
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
CUI-156 Add new admin components directory with microfrontend container #689
Closed
Closed
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3727aa3
CUI-156 Add new admin components directory with microfrontend container
MichalGorskiOnegini 3403578
CUI-156 Add component test
MichalGorskiOnegini f92273c
Merge branch 'master' into CUI-156
MichalGorskiOnegini 7524b32
Merge remote-tracking branch 'origin/master' into CUI-156
MichalGorskiOnegini 03e089f
CUI-156 Rename MicrofrontendContainer to GenericMicrofrontendContainer
MichalGorskiOnegini ba2ba38
CUI-156 Get rid of ultra-wide params
MichalGorskiOnegini a3251f8
CUI-156 Adding back bigger viewport to differentiate stories
MichalGorskiOnegini 1e383a2
CUI-156 Adding back bigger viewport to differentiate stories
MichalGorskiOnegini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/admin_components/Container/MicrofrontendContainer.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/*! | ||
* Copyright 2022 OneWelcome B.V. | ||
* | ||
* 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. | ||
*/ | ||
|
||
.container { | ||
margin: 1.5rem 2rem 1rem; | ||
max-width: 75rem; | ||
} | ||
|
||
.full-width { | ||
max-width: unset; | ||
} |
50 changes: 50 additions & 0 deletions
50
src/admin_components/Container/MicrofrontendContainer.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2022 OneWelcome B.V. | ||
* | ||
* 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 { render } from "@testing-library/react"; | ||
import { MicrofrontendContainer, Props } from "./MicrofrontendContainer"; | ||
|
||
const createMicrofrontendContainer = (props?: Props) => { | ||
const queries = render( | ||
<MicrofrontendContainer | ||
{...props} | ||
data-testid="microfrontend-container" | ||
></MicrofrontendContainer> | ||
); | ||
const microfrontendContainer = queries.getByTestId("microfrontend-container"); | ||
|
||
return { | ||
...queries, | ||
microfrontendContainer | ||
}; | ||
}; | ||
|
||
describe("MicrofrontendContainer component", () => { | ||
test("should render without crashing", () => { | ||
const { microfrontendContainer } = createMicrofrontendContainer(); | ||
|
||
expect(microfrontendContainer).toBeDefined(); | ||
expect(microfrontendContainer.className).not.toContain("full-width"); | ||
}); | ||
|
||
test("should render with full-width class", () => { | ||
const { microfrontendContainer } = createMicrofrontendContainer({ fullWidth: true }); | ||
|
||
expect(microfrontendContainer).toBeDefined(); | ||
expect(microfrontendContainer.className).toContain("full-width"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2022 OneWelcome B.V. | ||
* | ||
* 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, { ForwardRefRenderFunction, HTMLProps } from "react"; | ||
import classes from "./MicrofrontendContainer.module.scss"; | ||
|
||
export interface Props extends HTMLProps<HTMLDivElement> { | ||
fullWidth?: boolean; | ||
} | ||
|
||
/* | ||
* FIXME: This component is meant to be moved to a separate UCL package when it's finished. | ||
*/ | ||
export const MicrofrontendContainer: ForwardRefRenderFunction<HTMLDivElement, Props> = ({ | ||
fullWidth = false, | ||
children, | ||
...rest | ||
}: Props) => { | ||
const containerClasses: string[] = []; | ||
|
||
fullWidth && containerClasses.push(classes["full-width"]); | ||
containerClasses.push(classes["container"]); | ||
|
||
return ( | ||
<div {...rest} className={containerClasses.join(" ")}> | ||
{children} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
stories/admin/MicrofrontendContainer/MicrofrontendContainer.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Canvas, Story, Title, Subtitle, ArgTypes, PRIMARY_STORY } from "@storybook/blocks"; | ||
import * as MicrofrontendContainerStories from "./MicrofrontendContainer.stories.tsx"; | ||
|
||
<Title /> | ||
<Subtitle /> | ||
|
||
The Microfrontend Container component is designed to simplify the implementation of responsive layouts and spacing management | ||
within microfrontend architectures. This component offers developers a straightforward solution for ensuring that content remains | ||
visually appealing and well-structured across various screen sizes and devices. | ||
|
||
At its core, the Microfrontend Container utilizes standard CSS techniques to adjust its size and layout based on the dimensions of the viewport. | ||
This ensures that content within the container adapts seamlessly to different screen sizes, providing a consistent user experience across desktops, tablets, | ||
and mobile devices. It comes with pre-applied margin properties. | ||
MichalGorskiOnegini marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
In essence, the Microfrontend Container streamlines the process of creating responsive and well-structured user interfaces within Admin UI container. | ||
By abstracting away the complexities of responsiveness and margin management, this component allows developers to focus on designing engaging | ||
content while ensuring a polished and cohesive user experience across all devices. | ||
|
||
The component is based on the following design: [LINK](https://www.figma.com/file/tZLMF6dw6LOSkmEhlV3rkF/UI-Patterns?type=design&node-id=2107%3A16959&mode=design&t=9UWjpVqhIeYZOXXR-1) | ||
|
||
# Props | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd see example usage here ;P. WDYT? Worth to add? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's quite specific so IMO it's sufficient how it is |
||
|
||
<ArgTypes story={PRIMARY_STORY} /> |
77 changes: 77 additions & 0 deletions
77
stories/admin/MicrofrontendContainer/MicrofrontendContainer.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright 2022 OneWelcome B.V. | ||
* | ||
* 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, { Fragment } from "react"; | ||
import { Meta, StoryFn } from "@storybook/react"; | ||
import MicrofrontendContainerDocumentation from "./MicrofrontendContainer.mdx"; | ||
import { | ||
MicrofrontendContainer as MicrofrontendContainerComponent, | ||
Props | ||
} from "../../../src/admin_components/Container/MicrofrontendContainer"; | ||
|
||
const meta: Meta = { | ||
title: "Admin components/Microfrontend Container", | ||
component: MicrofrontendContainerComponent, | ||
parameters: { | ||
docs: { | ||
page: MicrofrontendContainerDocumentation | ||
} | ||
}, | ||
argTypes: { | ||
fullWidth: { | ||
description: | ||
"In some cases, such as complex data tables, there might be a need to not limit the maximum width of the container. <br/>" | ||
} | ||
} | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template: StoryFn<Props> = args => { | ||
const outline = { | ||
outlineColor: "black", | ||
outlineWidth: "2px", | ||
outlineStyle: "dashed" | ||
}; | ||
const centerText = { | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center" | ||
}; | ||
|
||
return ( | ||
<Fragment> | ||
<div style={{ height: "5vw", ...outline, ...centerText }}>HEADER</div> | ||
<div style={{ display: "flex" }}> | ||
<div style={{ ...outline, ...centerText, width: "8vw" }}>NAV</div> | ||
<MicrofrontendContainerComponent style={{ width: "100%" }} {...args}> | ||
<div style={{ height: "50vw", ...outline, ...centerText }}>CONTENT</div> | ||
</MicrofrontendContainerComponent> | ||
</div> | ||
</Fragment> | ||
); | ||
}; | ||
export const MicrofrontendContainer = Template.bind({}); | ||
|
||
MicrofrontendContainer.args = {}; | ||
|
||
export const MicrofrontendContainerFullWidth = Template.bind({}); | ||
|
||
MicrofrontendContainerFullWidth.args = { fullWidth: true }; | ||
|
||
MicrofrontendContainerFullWidth.parameters = { | ||
chromatic: { viewports: [1440, 3440] } | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it experimental, as it may change when a new form component is ready.