Skip to content

Commit

Permalink
Merge branch 'next' into feature/inlineDocumentationPointers-CMEM-6044
Browse files Browse the repository at this point in the history
  • Loading branch information
arausly committed Oct 9, 2024
2 parents 3823956 + 8a4ce72 commit b08fe34
Show file tree
Hide file tree
Showing 17 changed files with 319 additions and 22 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- `noTogglerContentSuffix`: Allows to add non-string elements at the end of the content if the full description is shown, i.e. no toggler is necessary. This allows to add non-string elements to both the full-view content and the pure string content.
- `<MultiSuggestField />`
- An optional custom search function property has been added, it defines how to filter elements.
- `<FlexibleLayoutContainer />` and `<FlexibleLayoutItem />`
- helper components to create flex layouts for positioning sub elements
- stop misusing `Toolbar*` components to do that (anti pattern)
- `<PropertyValueList />` and `<PropertyValuePair />`
- `singleColumn` property to display label and value below each other
- `<Label />`
- `emphasis` property to control visual appearance of the label text
- basic Storybook example for `<Application* />` components
- `$eccgui-selector-text-spot-highlight` config variable to specify selector that is used to create shortly highlighted spots
- it is highlighted when the selector is also active local anchor target or if it has the `.eccgui-typography--spothighlight` class attached to it
Expand All @@ -30,6 +37,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- upgrade to Storybook v8
- include a few patches for actions, see https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#implicit-actions-can-not-be-used-during-rendering-for-example-in-the-play-function
- allow `next` and `legacy` as branch names
- switch icons for `item-clone` and `item-copy` to Carbon's `<Replicate/>` and `<Copy/>`

## [23.8.0] - 2024-08-19

Expand Down
67 changes: 67 additions & 0 deletions src/components/FlexibleLayout/FlexibleLayoutContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, { forwardRef } from "react"; // @see https://github.com/storybookjs/storybook/issues/8881#issuecomment-831937051

import { CLASSPREFIX as eccgui } from "../../configuration/constants";

import { DividerProps } from "./../Separation/Divider";

export interface FlexibleLayoutContainerProps extends React.HTMLAttributes<HTMLDivElement> {
/**
* Use the exact space defined by the parent element.
* This parent element must be displayed using a fixed, relative or absolute position.
*/
useAbsoluteSpace?: boolean;
/**
* If set then the container behaves similar to a column and displays its items on a vertical axis.
* Children could used as rows in this situation.
*/
vertical?: boolean;
/**
* If true the used amount of space for each item is related to the amout of its content compared to each other.
* Otherwise the items use equal amounts as long this is possible.
*/
noEqualItemSpace?: boolean;
/**
* Quick way to add whitespace between container children.
* For more complex usecases like dividers you need to use extra `<FlexibleLayoutItem/>` components in combination with `<Divider/>` components.
*/
gapSize?: DividerProps["addSpacing"];
}

/**
* Simple layout helper to organize items into rows and columns that are not necessarily need to be aligned.
* A `FlexibleLayoutContainer` can contain `FlexibleLayoutItem`s.
* Do not misuse it as grid because it comes without any predefined ratios for widths and heights.
*/
export const FlexibleLayoutContainer = forwardRef<HTMLDivElement, FlexibleLayoutContainerProps>(
(
{
children,
className = "",
useAbsoluteSpace,
vertical,
noEqualItemSpace,
gapSize = "none",
...otherDivProps
}: FlexibleLayoutContainerProps,
ref
) => {
return (
<div
className={
`${eccgui}-flexible__container` +
(useAbsoluteSpace ? ` ${eccgui}-flexible__container--absolutespace` : "") +
(vertical ? ` ${eccgui}-flexible__container--vertical` : "") +
(noEqualItemSpace ? ` ${eccgui}-flexible__container--notequalitemspace` : "") +
(gapSize !== "none" ? ` ${eccgui}-flexible__container--gap-${gapSize}` : "") +
(className ? " " + className : "")
}
ref={ref}
{...otherDivProps}
>
{children}
</div>
);
}
);

export default FlexibleLayoutContainer;
59 changes: 59 additions & 0 deletions src/components/FlexibleLayout/FlexibleLayoutItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React, { forwardRef } from "react";

import { CLASSPREFIX as eccgui } from "../../configuration/constants";

export interface FlexibleLayoutItemProps extends React.HTMLAttributes<HTMLDivElement> {
/**
* Defines the ability for the item to grow.
* The factor defines how much space the item would take up compared to the other items with a grow factor greater than zero.
* Must be equal or greater than zero.
* With a factor of `0` the item cannot grow.
*/
growFactor?: number;
/**
* Defines the ability for the item to shrink.
* The factor defines how strong the shrink effect has impact on the item compared to the other items with a shrink factor greater than zero.
* Must be equal or greater than zero.
* With a factor of `0` the item cannot shrink.
*/
shrinkFactor?: number;
}

/**
* Simple layout helper to organize items into rows and columns that are not necessarily need to be aligned.
* `FlexibleLayoutItem`s can contain `FlexibleLayoutContainer` for more partitions.
* `FlexibleLayoutItem` siblings will share all available space from the `FlexibleLayoutContainer` container.
*/
export const FlexibleLayoutItem = forwardRef<HTMLDivElement, FlexibleLayoutItemProps>(
(
{
children,
className = "",
growFactor = 1,
shrinkFactor = 1,
style,
...otherDivProps
}: FlexibleLayoutItemProps,
ref
) => {
const sizing = {} as any;
if (typeof growFactor !== "undefined" && growFactor >= 0 && growFactor !== 1) {
sizing[`--${eccgui}-flexible-item-grow`] = growFactor.toString(10);
}
if (typeof shrinkFactor !== "undefined" && shrinkFactor >= 0 && shrinkFactor !== 1) {
sizing[`--${eccgui}-flexible-item-shrink`] = shrinkFactor.toString(10);
}
return (
<div
className={`${eccgui}-flexible__item` + (className ? " " + className : "")}
style={{ ...(style ?? {}), ...sizing }}
ref={ref}
{...otherDivProps}
>
{children}
</div>
);
}
);

export default FlexibleLayoutItem;
48 changes: 48 additions & 0 deletions src/components/FlexibleLayout/flexiblelayout.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.#{$eccgui}-flexible__container {
--#{$eccgui}-flexible-item-shrink: 1;
--#{$eccgui}-flexible-item-grow: 1;
--#{$eccgui}-flexible-container-gapsize: 0;

position: relative;
display: flex;
flex-flow: row nowrap;
gap: var(--#{$eccgui}-flexible-container-gapsize);
place-content: stretch center;
align-items: stretch;
width: 100%;
}

.#{$eccgui}-flexible__container--absolutespace {
position: absolute;
inset: 0;
}

.#{$eccgui}-flexible__container--vertical {
flex-direction: column;
}

.#{$eccgui}-flexible__container--gap-tiny {
--#{$eccgui}-flexible-container-gapsize: #{$eccgui-size-block-whitespace * 0.25};
}
.#{$eccgui}-flexible__container--gap-small {
--#{$eccgui}-flexible-container-gapsize: #{$eccgui-size-block-whitespace * 0.5};
}
.#{$eccgui}-flexible__container--gap-medium {
--#{$eccgui}-flexible-container-gapsize: #{$eccgui-size-block-whitespace};
}
.#{$eccgui}-flexible__container--gap-large {
--#{$eccgui}-flexible-container-gapsize: #{$eccgui-size-block-whitespace * 1.5};
}
.#{$eccgui}-flexible__container--gap-xlarge {
--#{$eccgui}-flexible-container-gapsize: #{$eccgui-size-block-whitespace * 2};
}

.#{$eccgui}-flexible__item {
position: relative;
flex: var(--#{$eccgui}-flexible-item-grow) var(--#{$eccgui}-flexible-item-shrink) 100%;
min-width: 0;

.#{$eccgui}-flexible__container--notequalitemspace > & {
flex-basis: auto;
}
}
2 changes: 2 additions & 0 deletions src/components/FlexibleLayout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./FlexibleLayoutContainer";
export * from "./FlexibleLayoutItem";
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from "react";
import { LoremIpsum } from "react-lorem-ipsum";
import { Meta, StoryFn } from "@storybook/react";

import { Divider, FlexibleLayoutContainer, FlexibleLayoutItem, HtmlContentBlock } from "../../../../index";

export default {
title: "Components/FlexibleLayout/Container",
component: FlexibleLayoutContainer,
} as Meta<typeof FlexibleLayoutContainer>;

const Template: StoryFn<typeof FlexibleLayoutContainer> = (args) => (
<div style={{ position: "relative", height: "400px" }}>
<FlexibleLayoutContainer {...args}>
<FlexibleLayoutItem>
<HtmlContentBlock>
<LoremIpsum p={1} avgSentencesPerParagraph={3} random={false} />
</HtmlContentBlock>
</FlexibleLayoutItem>
<FlexibleLayoutItem>
<Divider />
<HtmlContentBlock>
<LoremIpsum p={3} avgSentencesPerParagraph={2} random={false} />
</HtmlContentBlock>
</FlexibleLayoutItem>
</FlexibleLayoutContainer>
</div>
);

export const Default = Template.bind({});
Default.args = {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from "react";
import { LoremIpsum } from "react-lorem-ipsum";
import { Meta, StoryFn } from "@storybook/react";

import { FlexibleLayoutContainer, FlexibleLayoutItem, HtmlContentBlock } from "../../../../index";

export default {
title: "Components/FlexibleLayout/Item",
component: FlexibleLayoutItem,
} as Meta<typeof FlexibleLayoutItem>;

const Template: StoryFn<typeof FlexibleLayoutItem> = (args) => (
<FlexibleLayoutContainer horizontal>
<FlexibleLayoutItem {...args}>
<HtmlContentBlock>
<LoremIpsum p={1} avgSentencesPerParagraph={1} avgWordsPerSentence={3} random={false} />
</HtmlContentBlock>
</FlexibleLayoutItem>
<FlexibleLayoutItem>
<HtmlContentBlock>
<LoremIpsum p={2} avgSentencesPerParagraph={4} random={false} />
</HtmlContentBlock>
</FlexibleLayoutItem>
</FlexibleLayoutContainer>
);

export const Default = Template.bind({});
Default.args = {};
4 changes: 2 additions & 2 deletions src/components/Icon/canonicalIconNames.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ const canonicalIcons = {
"entity-robot": icons.Bot,

"item-add-artefact": icons.AddAlt,
"item-clone": icons.Copy,
"item-clone": icons.Replicate,
"item-comment": icons.AddComment,
"item-copy": icons.CopyFile,
"item-copy": icons.Copy,
"item-download": icons.Download,
"item-draggable": icons.Draggable,
"item-edit": icons.Edit,
Expand Down
7 changes: 6 additions & 1 deletion src/components/Label/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement>
* If there is no `isLayoutForElement` set then a `span` is used.
*/
disabled?: boolean;
/**
* visual appearance of the label
*/
emphasis?: "strong" | "normal";
}

export const Label = ({
Expand All @@ -41,6 +45,7 @@ export const Label = ({
tooltip,
tooltipProps,
isLayoutForElement = "label",
emphasis = "normal",
...otherLabelProps
}: LabelProps) => {
let htmlElementstring = isLayoutForElement;
Expand All @@ -66,7 +71,7 @@ export const Label = ({
htmlElementstring,
{
className:
`${eccgui}-label` +
`${eccgui}-label ${eccgui}-label--${emphasis}` +
(className ? " " + className : "") +
(disabled ? ` ${eccgui}-label--disabled` : ""),
...otherLabelProps,
Expand Down
6 changes: 6 additions & 0 deletions src/components/Label/label.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ $eccgui-color-label-info: rgba($eccgui-color-workspace-text, $eccgui-opacity-mut
opacity: $eccgui-opacity-disabled;
}

.#{$eccgui}-label--strong {
.#{$eccgui}-label__text {
font-weight: bolder;
}
}

.#{$eccgui}-label__text {
.#{$eccgui}-typography__overflowtext--passdown > .#{$eccgui}-label > & {
display: block;
Expand Down
29 changes: 26 additions & 3 deletions src/components/PropertyValuePair/PropertyValueList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,35 @@ import React from "react";

import { CLASSPREFIX as eccgui } from "../../configuration/constants";

export type PropertyValueListProps = React.HTMLAttributes<HTMLDListElement>;
import { PropertyValuePair } from "./PropertyValuePair";

export interface PropertyValueListProps extends React.HTMLAttributes<HTMLDListElement> {
/**
* Only use one single column and put property label and value below each other.
* This property is forwardd to direct `PropertyValuePair` children.
*/
singleColumn?: boolean;
}

export const PropertyValueList = ({
className = "",
children,
singleColumn = false,
...otherProps
}: PropertyValueListProps) => {
const alteredChildren = singleColumn
? React.Children.map(children, (child) => {
const originalChild = child as React.ReactElement;
if (originalChild && originalChild.type && originalChild.type === PropertyValuePair) {
return React.cloneElement(originalChild, { singleColumn: true });
}
return child;
})
: children;

export const PropertyValueList = ({ className = "", children, ...otherProps }: PropertyValueListProps) => {
return (
<dl className={`${eccgui}-propertyvalue__list` + (className ? " " + className : "")} {...otherProps}>
{children}
{alteredChildren}
</dl>
);
};
Expand Down
8 changes: 7 additions & 1 deletion src/components/PropertyValuePair/PropertyValuePair.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export interface PropertyValuePairProps extends React.HTMLAttributes<HTMLDivElem
* Forward the `nowrap` option to it `PropertyName` and `PropertyValue` children.
*/
nowrap?: boolean;
/**
* Only use one single column and put property label and value below each other.
*/
singleColumn?: boolean;
}

export const PropertyValuePair = ({
Expand All @@ -26,6 +30,7 @@ export const PropertyValuePair = ({
nowrap,
hasSpacing = false,
hasDivider = false,
singleColumn = false,
...otherProps
}: PropertyValuePairProps) => {
const alteredChildren = nowrap
Expand All @@ -44,7 +49,8 @@ export const PropertyValuePair = ({
`${eccgui}-propertyvalue__pair` +
(className ? " " + className : "") +
(hasSpacing ? ` ${eccgui}-propertyvalue__pair--hasspacing` : "") +
(hasDivider ? ` ${eccgui}-propertyvalue__pair--hasdivider` : "")
(hasDivider ? ` ${eccgui}-propertyvalue__pair--hasdivider` : "") +
(singleColumn ? ` ${eccgui}-propertyvalue__pair--singlecolumn` : "")
}
{...otherProps}
>
Expand Down
Loading

0 comments on commit b08fe34

Please sign in to comment.