Skip to content

Commit 8c5f165

Browse files
committed
extend component by addBorder property
1 parent a342b8f commit 8c5f165

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2020
- `isValidNewOption` property: Checks if an input string is or can be turned into a valid new option.
2121
- `<OverviewItem />`
2222
- `intent` property: visualize the state
23+
- `hasBorder` property: add border around element
2324

2425
### Fixed
2526

src/components/OverviewItem/OverviewItem.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ export interface OverviewItemProps extends React.HTMLAttributes<HTMLDivElement>
1717
* Add a bit white space around the element.
1818
*/
1919
hasSpacing?: boolean;
20+
/**
21+
* Add a border around the element.
22+
* On default the background uses the default color from the `Card`.
23+
* Otherwise, color is managed automatically by the intent state.
24+
*/
25+
hasBorder?: boolean;
2026
/**
2127
* Uses a `Card` element to wrap the `OverviewItem` inside.
2228
* It is always used with `isOnlyLayout` set to `true`.
@@ -39,6 +45,7 @@ export const OverviewItem = ({
3945
className = "",
4046
densityHigh = false,
4147
hasSpacing = false,
48+
hasBorder = false,
4249
hasCardWrapper = false,
4350
cardProps,
4451
intent,
@@ -51,6 +58,7 @@ export const OverviewItem = ({
5158
`${eccgui}-overviewitem__item ` +
5259
(densityHigh ? `${eccgui}-overviewitem__item--highdensity ` : "") +
5360
(hasSpacing ? `${eccgui}-overviewitem__item--hasspacing ` : "") +
61+
(hasBorder ? `${eccgui}-overviewitem__item--hasborder ` : "") +
5462
(intent ? `${intentClassName(intent)} ` : "") +
5563
className
5664
}

src/components/OverviewItem/overviewitem.scss

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,37 +81,48 @@ $eccgui-size-overviewitem-line-typo-large-lineheight: $eccgui-size-typo-subtitle
8181
&.#{$eccgui}-intent--info {
8282
--eccgui-overviewitem-color-background: #{$eccgui-color-info-background};
8383
--eccgui-overviewitem-color-text: #{$eccgui-color-info-text};
84+
--eccgui-overviewitem-color-border: #{eccgui-color-var("semantic", "info", "300")};
8485
}
8586
&.#{$eccgui}-intent--success {
8687
--eccgui-overviewitem-color-background: #{$eccgui-color-success-background};
8788
--eccgui-overviewitem-color-text: #{$eccgui-color-success-text};
89+
--eccgui-overviewitem-color-border: #{eccgui-color-var("semantic", "success", "300")};
8890
}
8991
&.#{$eccgui}-intent--warning {
9092
--eccgui-overviewitem-color-background: #{$eccgui-color-warning-background};
9193
--eccgui-overviewitem-color-text: #{$eccgui-color-warning-text};
94+
--eccgui-overviewitem-color-border: #{eccgui-color-var("semantic", "warning", "300")};
9295
}
9396
&.#{$eccgui}-intent--danger {
9497
--eccgui-overviewitem-color-background: #{$eccgui-color-danger-background};
9598
--eccgui-overviewitem-color-text: #{$eccgui-color-danger-text};
99+
--eccgui-overviewitem-color-border: #{eccgui-color-var("semantic", "danger", "300")};
96100
}
97101
&.#{$eccgui}-intent--neutral {
98102
--eccgui-overviewitem-color-background: #{$eccgui-color-workspace-background};
99103
--eccgui-overviewitem-color-text: #{$eccgui-color-workspace-text};
100-
}
101-
&.#{$eccgui}-intent--neutral {
102-
--eccgui-overviewitem-color-background: #{$eccgui-color-workspace-background};
103-
--eccgui-overviewitem-color-text: #{$eccgui-color-workspace-text};
104+
--eccgui-overviewitem-color-border: #{eccgui-color-var("identity", "background", "500")};
104105
}
105106
&.#{$eccgui}-intent--primary {
106107
--eccgui-overviewitem-color-background: #{eccgui-color-var("identity", "brand", "100")};
107108
--eccgui-overviewitem-color-text: #{eccgui-color-var("identity", "brand", "900")};
109+
--eccgui-overviewitem-color-border: #{eccgui-color-var("identity", "brand", "300")};
108110
}
109111
&.#{$eccgui}-intent--accent {
110112
--eccgui-overviewitem-color-background: #{eccgui-color-var("identity", "accent", "100")};
111113
--eccgui-overviewitem-color-text: #{eccgui-color-var("identity", "accent", "900")};
114+
--eccgui-overviewitem-color-border: #{eccgui-color-var("identity", "accent", "300")};
112115
}
113116
}
114117

118+
.#{$eccgui}-overviewitem__item--hasborder {
119+
--eccgui-overviewitem-color-background: #{$card-background-color};
120+
--eccgui-overviewitem-color-border: #{eccgui-color-var("identity", "background", "500")};
121+
122+
border: 1px solid var(--eccgui-overviewitem-color-border);
123+
border-radius: $pt-border-radius;
124+
}
125+
115126
.#{$eccgui}-overviewitem__item--highdensity {
116127
// same fix for Firefox v132+ like for the normal element height
117128
min-height: $button-height;

0 commit comments

Comments
 (0)