Skip to content

Commit c585a49

Browse files
[OP-230] Update card to not use contain paint (#281)
This PR updates the card component to no longer use `contain: paint`. This should reduce the amount of overriding to allow for things like tooltips.
1 parent aebed01 commit c585a49

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rolemodel/optics",
3-
"version": "2.1.3",
3+
"version": "2.1.4",
44
"packageManager": "[email protected]",
55
"description": "Optics is a css package that provides base styles and components that can be integrated and customized in a variety of projects.",
66
"main": "dist/css/optics.css",

src/components/card.css

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
/* Public API (customizable component options) */
33
--_op-card-padding: var(--op-space-medium);
44
--_op-card-box-shadow: var(--op-border-all) var(--op-color-border);
5+
--_op-card-radius: var(--op-radius-medium);
56

67
position: relative;
7-
border-radius: var(--op-radius-medium);
8+
border-radius: var(--_op-card-radius);
89
background-color: var(--op-color-background);
910
box-shadow: var(--_op-card-box-shadow);
1011
color: var(--op-color-on-background);
11-
contain: paint;
1212
font-size: var(--op-font-medium);
1313
line-height: var(--op-line-height-base);
1414

@@ -50,6 +50,9 @@
5050
}
5151

5252
.card__header {
53+
border-top-left-radius: var(--_op-card-radius);
54+
border-top-right-radius: var(--_op-card-radius);
55+
5356
h1,
5457
h2,
5558
h3,
@@ -59,4 +62,9 @@
5962
margin: 0;
6063
}
6164
}
65+
66+
.card__footer {
67+
border-bottom-left-radius: var(--_op-card-radius);
68+
border-bottom-right-radius: var(--_op-card-radius);
69+
}
6270
}

src/stories/Components/Card/Card.mdx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ Card can be used as a standalone component, however, it does have a few dependen
6767

6868
<Canvas of={CardStories.Shadow} />
6969

70+
## Card API
71+
72+
Padding, Box Shadow (border), and Radius styles are built on css variables scoped to the card. They can ben overridden to customize the card.
73+
74+
```css
75+
--_op-card-padding
76+
--_op-card-box-shadow
77+
--_op-card-radius
78+
```
79+
7080
## Customizing Card styles
7181

7282
<div
@@ -117,7 +127,8 @@ Your application may need a variation. To add one, just follow this template. No
117127

118128
```css
119129
.card--purple {
120-
border-radius: var(--op-radius-large);
130+
--_op-card-radius: var(--op-radius-large);
131+
121132
font-size: var(--op-font-2x-large);
122133

123134
.card__header {

0 commit comments

Comments
 (0)