Skip to content

Commit 6450d4c

Browse files
Merge branch 'develop' into feature/reusableRuleBlocks-CMEM-1590
# Conflicts: # CHANGELOG.md
2 parents a2a6deb + 6008782 commit 6450d4c

22 files changed

Lines changed: 316 additions & 37 deletions

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2525

2626
- `<MultiSelect />`
2727
- border of the BlueprintJS `Tag` elements were fixed
28+
- `extendedTooltip` of a handle in the ReactFlow (v12) component does not show the tooltip.
2829
- `<CodeEditor />`
2930
- `readOnly` appearance uses same borders like read-only text fields and it does not display a blinking cursor
3031
- `<Button />`, `<IconButton />`
3132
- outlines for focus by keyboard navigation are better recognizable on buttons with colored backgrounds (intent states)
33+
- `<Tooltip />`
34+
- given `popoverClassName` is added
3235
- `extendedTooltip` of a handle in the ReactFlow (v12) component does not show the tooltip.
3336

3437
### Changed
@@ -41,6 +44,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
4144
- `Toaster.create` is now an async function
4245
- `<MultiSelect />`
4346
- by default, if no searchPredicate or searchListPredicate is defined, the filtering is done via case-insensitive multi-word filtering.
47+
- `<ProgressBar />`, `<MenuItem />`, `<FieldSet />`, `<FieldItem />`, `<Tooltip />`, `<MultiSuggestField />`
48+
- color for `intent="primary"` was changed to our brand color
49+
- new option `accent` for `intent` uses the accent color
50+
- `<TextField />`, `<TextArea />`
51+
- switch primary and accent colors
4452

4553
### Deprecated
4654

src/components/Form/form.scss

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ form {
5656

5757
.#{$eccgui}-fielditem__message {
5858
&.#{$eccgui}-intent--primary {
59+
color: $eccgui-color-primary;
60+
}
61+
&.#{$eccgui}-intent--accent {
5962
color: $eccgui-color-accent;
6063
}
6164
&.#{$eccgui}-intent--success {
@@ -89,11 +92,20 @@ form {
8992

9093
&.#{$eccgui}-intent--primary {
9194
&.#{$eccgui}-fieldset--boxed {
92-
background-color: $eccgui-color-info-background;
95+
background-color: $eccgui-color-primary-contrast;
96+
}
97+
.#{$eccgui}-fieldset__message,
98+
legend {
99+
color: $eccgui-color-primary;
100+
}
101+
}
102+
&.#{$eccgui}-intent--accent {
103+
&.#{$eccgui}-fieldset--boxed {
104+
background-color: $eccgui-color-accent-contrast;
93105
}
94106
.#{$eccgui}-fieldset__message,
95107
legend {
96-
color: $eccgui-color-info-text;
108+
color: $eccgui-color-accent;
97109
}
98110
}
99111
&.#{$eccgui}-intent--success {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from "react";
2+
import { Classes as BlueprintClasses } from "@blueprintjs/core";
3+
import { render } from "@testing-library/react";
4+
5+
import "@testing-library/jest-dom";
6+
7+
import { MenuItem } from "../../../index";
8+
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
9+
10+
describe("MenuItem", () => {
11+
it("should not apply an intent class when intent is undefined", () => {
12+
const { container } = render(<MenuItem text="item" intent={undefined} />);
13+
const menuItem = container.querySelector(`.${eccgui}-menu__item`);
14+
expect(menuItem).not.toBeNull();
15+
expect((menuItem as HTMLElement).className).not.toMatch(
16+
new RegExp(`${BlueprintClasses.getClassNamespace()}-intent-`),
17+
);
18+
});
19+
it("should apply the intent class for the custom accent intent", () => {
20+
const { container } = render(<MenuItem text="item" intent="accent" />);
21+
const menuItem = container.querySelector(`.${eccgui}-menu__item`);
22+
expect(menuItem).not.toBeNull();
23+
expect(menuItem).toHaveClass(`${BlueprintClasses.getClassNamespace()}-intent-accent`);
24+
});
25+
});

src/components/Menu/MenuItem.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import React from "react";
2-
import { MenuItem as BlueprintMenuItem, MenuItemProps as BlueprintMenuItemProps } from "@blueprintjs/core";
2+
import {
3+
Classes as BlueprintClasses,
4+
MenuItem as BlueprintMenuItem,
5+
MenuItemProps as BlueprintMenuItemProps,
6+
} from "@blueprintjs/core";
7+
import classNames from "classnames";
38

49
import { openInNewTab } from "../../common/utils/openInNewTab";
510
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
@@ -11,10 +16,10 @@ import { TestIconProps } from "./../Icon/TestIcon";
1116

1217
export interface MenuItemProps
1318
extends
14-
Omit<BlueprintMenuItemProps, "icon" | "children">,
19+
Omit<BlueprintMenuItemProps, "icon" | "children" | "intent">,
1520
Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "onClick" | "onFocus" | "target" | "children"> {
16-
/*
17-
* If set the icon is diplayed on the left side of the menu item.
21+
/**
22+
* If set the icon is displayed on the left side of the menu item.
1823
*/
1924
icon?: ValidIconName | string[] | React.ReactElement<TestIconProps>;
2025
/**
@@ -25,6 +30,10 @@ export interface MenuItemProps
2530
* Tooltip, but only added to the label, not to the full menu item.
2631
*/
2732
tooltip?: string | React.JSX.Element;
33+
/**
34+
* Visual intent color to apply to element.
35+
*/
36+
intent?: BlueprintMenuItemProps["intent"] | "accent";
2837
}
2938

3039
/**
@@ -38,6 +47,7 @@ export const MenuItem = ({
3847
href,
3948
text,
4049
tooltip,
50+
intent,
4151
...restProps
4252
}: MenuItemProps) => {
4353
return (
@@ -56,7 +66,10 @@ export const MenuItem = ({
5666
onClick={(e: React.MouseEvent<HTMLElement>) =>
5767
openInNewTab(e as React.MouseEvent<HTMLAnchorElement>, onClick, href)
5868
}
59-
className={`${eccgui}-menu__item ` + className}
69+
className={classNames(`${eccgui}-menu__item`, className, {
70+
// control blueprint intent classes to enhance it by new options
71+
[`${BlueprintClasses.getClassNamespace()}-intent-${intent}`]: intent,
72+
})}
6073
icon={icon ? typeof icon === "string" || Array.isArray(icon) ? <Icon name={icon} /> : icon : false}
6174
>
6275
{children ?? null}

src/components/Menu/Stories/MenuItem.stories.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { OverlaysProvider } from "@blueprintjs/core";
33
import { LogoReact } from "@carbon/icons-react";
44
import { Meta, StoryFn } from "@storybook/react";
55

6+
import { helpersArgTypes } from "../../../../.storybook/helpers";
67
import { Menu, MenuItem, TestIcon } from "../../../components";
78

89
import canonicalIcons from "./../../Icon/canonicalIconNames";
@@ -19,6 +20,10 @@ export default {
1920
...Object.keys(canonicalIcons),
2021
},
2122
},
23+
intent: {
24+
...helpersArgTypes.exampleIntent,
25+
options: ["UNDEFINED", "primary", "accent", "success", "warning", "danger"],
26+
},
2227
},
2328
} as Meta<typeof MenuItem>;
2429

src/components/Menu/menu.scss

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,51 @@ span.#{$ns}-menu-item-icon:empty {
6868
}
6969
}
7070
}
71+
72+
.#{$ns}-menu-item {
73+
@each $intent in ("primary", "accent") {
74+
$colorrange: $intent;
75+
76+
@if $intent == "primary" {
77+
$colorrange: "brand";
78+
}
79+
80+
@include menu-item-intent(
81+
$intent,
82+
false,
83+
eccgui-color-var("identity", $colorrange, "300"),
84+
eccgui-color-var("identity", $colorrange, "700"),
85+
eccgui-color-var("identity", $colorrange, "900")
86+
);
87+
}
88+
}
89+
90+
.#{$ns}-submenu {
91+
.#{$ns}-popover-target {
92+
&.#{$ns}-popover-open > .#{$ns}-menu-item {
93+
&[class*="#{$ns}-intent-"] {
94+
&,
95+
&:hover,
96+
&:active {
97+
@each $intent in ("primary", "accent") {
98+
$colorrange: $intent;
99+
100+
@if $intent == "primary" {
101+
$colorrange: "brand";
102+
}
103+
&.#{$ns}-intent-#{$intent} {
104+
color: eccgui-color-var("identity", $colorrange, "700");
105+
background-color: rgba(eccgui-color-var("identity", $colorrange, "300"), 0.1);
106+
107+
&::before,
108+
.#{$ns}-menu-item-icon,
109+
.#{$ns}-submenu-icon {
110+
color: inherit;
111+
}
112+
}
113+
}
114+
}
115+
}
116+
}
117+
}
118+
}

src/components/MultiSelect/MultiSelect.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
MultiSelect as BlueprintMultiSelect,
66
MultiSelectProps as BlueprintMultiSelectProps,
77
} from "@blueprintjs/select";
8+
import classNames from "classnames";
89

910
import { removeExtraSpaces } from "../../common/utils/stringUtils";
1011
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
@@ -96,7 +97,7 @@ export interface MultiSuggestFieldCommonProps<T>
9697
/**
9798
* Intent state of the multi select.
9899
*/
99-
intent?: BlueprintIntent;
100+
intent?: BlueprintIntent | "accent";
100101
/**
101102
* Disables the input element
102103
*/
@@ -555,10 +556,12 @@ export function MultiSuggestField<T>({
555556
"data-testid": dataTestid ? dataTestid + "_searchinput" : undefined,
556557
...inputProps,
557558
} as React.InputHTMLAttributes<HTMLInputElement>,
558-
className: `${eccgui}-multisuggestfield ${eccgui}-multiselect` + (className ? ` ${className}` : ""),
559+
className: classNames(`${eccgui}-multisuggestfield`, `${eccgui}-multiselect`, className, {
560+
[`${eccgui}-intent--${intent}`]: intent === "accent",
561+
}),
559562
fill: fullWidth,
560563
inputRef: inputRef,
561-
intent: intent,
564+
intent: intent && intent !== "accent" ? intent : undefined,
562565
addOnBlur: true,
563566
onKeyDown: handleOnKeyDown,
564567
onKeyUp: handleOnKeyUp,

src/components/MultiSuggestField/MultiSuggestField.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default {
3535
},
3636
intent: {
3737
...helpersArgTypes.exampleIntent,
38-
options: ["UNDEFINED", "primary", "success", "warning", "danger"],
38+
options: ["UNDEFINED", "primary", "accent", "success", "warning", "danger"],
3939
},
4040
},
4141
args: {

src/components/MultiSuggestField/_multisuggestfield.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
.#{$eccgui}-multisuggestfield {
1111
--#{$eccgui}-a11y-outline-color: #{$eccgui-color-accent};
1212

13+
&.#{$ns}-intent-primary {
14+
@include pt-input-intent(eccgui-color-var("identity", "brand", "900"));
15+
16+
--#{$eccgui}-a11y-outline-color: #{$eccgui-color-primary};
17+
}
18+
&.#{$eccgui}-intent--accent {
19+
@include pt-input-intent(eccgui-color-var("identity", "accent", "900"));
20+
}
1321
&.#{$ns}-intent-success {
1422
--#{$eccgui}-a11y-outline-color: #{$eccgui-color-success-text};
1523
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from "react";
2+
import { render } from "@testing-library/react";
3+
4+
import "@testing-library/jest-dom";
5+
6+
import { ProgressBar } from "../../../index";
7+
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
8+
9+
describe("ProgressBar", () => {
10+
it("should not apply an intent class when no intent is set", () => {
11+
const { container } = render(<ProgressBar />);
12+
const progressbar = container.querySelector(`.${eccgui}-progressbar`);
13+
expect(progressbar).not.toBeNull();
14+
expect((progressbar as HTMLElement).className).not.toMatch(new RegExp(`${eccgui}-progressbar-intent-`));
15+
});
16+
it("should apply the matching intent class for a blueprint intent", () => {
17+
const { container } = render(<ProgressBar intent="success" />);
18+
const progressbar = container.querySelector(`.${eccgui}-progressbar`);
19+
expect(progressbar).not.toBeNull();
20+
expect(progressbar).toHaveClass(`${eccgui}-progressbar-intent-success`);
21+
});
22+
it("should apply the intent class for the custom accent intent", () => {
23+
const { container } = render(<ProgressBar intent="accent" />);
24+
const progressbar = container.querySelector(`.${eccgui}-progressbar`);
25+
expect(progressbar).not.toBeNull();
26+
expect(progressbar).toHaveClass(`${eccgui}-progressbar-intent-accent`);
27+
});
28+
});

0 commit comments

Comments
 (0)