@@ -9,19 +9,21 @@ import StringField from 'https://cardstack.com/base/string';
9
9
import { BlogApp as BlogAppCard } from ' ./blog-app' ;
10
10
import { htmlSafe } from ' @ember/template' ;
11
11
import { ColorField } from ' ./fields/color' ;
12
-
13
- function htmlSafeColor(color ? : string ) {
14
- return htmlSafe (` background-color: ${color || ' ' } ` );
15
- }
12
+ import { cssVar , getContrastColor } from ' @cardstack/boxel-ui/helpers' ;
16
13
17
14
export const categoryStyle = (category : Partial <BlogCategory >) => {
18
15
if (! category ) {
19
16
return ;
20
17
}
18
+ const pillColor = category .pillColor ?? ' #e8e8e8' ; // var(--boxel-200)
19
+ const borderColor = category .pillColor ?? ' #d3d3d3' ; // var(--boxel-border-color)
21
20
return htmlSafe (`
22
- background-color: ${category .backgroundColor ?.hexValue || ' #000000' };
23
- color: ${category .textColor ?.hexValue || ' #ffffff' };
24
- ` );
21
+ background-color: ${pillColor };
22
+ color: ${getContrastColor (pillColor , undefined , undefined , {
23
+ isSmallText: true ,
24
+ })};
25
+ border: 1px solid ${borderColor }
26
+ ` );
25
27
};
26
28
27
29
let BlogCategoryTemplate = class Embedded extends Component <
@@ -34,27 +36,29 @@ let BlogCategoryTemplate = class Embedded extends Component<
34
36
padding : var (--boxel-sp );
35
37
}
36
38
.category-name {
37
- padding : var (--boxel-sp-xxs );
38
- color : white ;
39
+ padding : var (--boxel-sp-xxxs ) var (--boxel-sp-xs );
39
40
border-radius : var (--boxel-border-radius-sm );
40
- font-weight : bold ;
41
+ font : 600 var (--boxel-font-xs );
42
+ letter-spacing : var (--boxel-lsp-sm );
41
43
display : inline-block ;
42
44
}
43
45
.category-label {
44
- color : var (--boxel-400 );
45
- margin-top : var (--boxel-sp-sm );
46
+ color : var (--boxel-450 );
47
+ font : 500 var (--boxel-font-xs );
48
+ letter-spacing : var (--boxel-lsp-sm );
49
+ margin-top : var (--boxel-sp );
46
50
}
47
51
.category-full-name {
48
52
font-size : var (--boxel-font-size );
49
53
font-weight : bold ;
50
54
}
51
55
.category-description {
52
56
margin-top : var (--boxel-sp-sm );
53
- color : var (--boxel-400 );
57
+ font : 400 var (--boxel-font-xs );
58
+ letter-spacing : var (--boxel-lsp-sm );
54
59
}
55
60
< /style >
56
61
<div class =' blog-category' >
57
- {{! template-lint-disable no-inline-styles }}
58
62
<div class =' category-name' style ={{categoryStyle @ model}} >
59
63
<@ fields.shortName />
60
64
</div >
@@ -75,8 +79,7 @@ export class BlogCategory extends CardDef {
75
79
@field longName = contains (StringField );
76
80
@field shortName = contains (StringField );
77
81
@field slug = contains (StringField );
78
- @field backgroundColor = contains (ColorField );
79
- @field textColor = contains (ColorField );
82
+ @field pillColor = contains (ColorField );
80
83
@field description = contains (StringField );
81
84
@field blog = linksTo (BlogAppCard , { isUsed: true });
82
85
@@ -91,18 +94,16 @@ export class BlogCategory extends CardDef {
91
94
border-radius : 50% ;
92
95
display : inline-block ;
93
96
margin-right : var (--boxel-sp-xxs );
97
+ background-color : var (--category-swatch );
94
98
}
95
99
.category-atom {
96
100
display : inline-flex ;
97
101
align-items : center ;
102
+ font-weight : 600 ;
98
103
}
99
104
< /style >
100
105
<div class =' category-atom' >
101
- {{! template-lint-disable no-inline-styles }}
102
- <div
103
- class =' circle'
104
- style ={{htmlSafeColor @ model.backgroundColor.hexValue}}
105
- />
106
+ <div class =' circle' style ={{cssVar category-swatch =@ model.pillColor}} />
106
107
<@ fields.longName />
107
108
</div >
108
109
</template >
@@ -116,14 +117,16 @@ export class BlogCategory extends CardDef {
116
117
padding : var (--boxel-sp-xs );
117
118
}
118
119
.category-name {
119
- padding : var (--boxel-sp-xxs );
120
- color : white ;
120
+ padding : var (--boxel-sp-xxxs ) var (--boxel-sp-xs );
121
121
border-radius : var (--boxel-border-radius-sm );
122
- font-weight : bold ;
122
+ font : 600 var (--boxel-font-xs );
123
+ letter-spacing : var (--boxel-lsp-sm );
123
124
display : inline-block ;
124
125
}
125
126
.category-label {
126
- color : var (--boxel-400 );
127
+ color : var (--boxel-450 );
128
+ font : 500 var (--boxel-font-xs );
129
+ letter-spacing : var (--boxel-lsp-sm );
127
130
margin-top : var (--boxel-sp-sm );
128
131
}
129
132
.category-full-name {
@@ -136,12 +139,13 @@ export class BlogCategory extends CardDef {
136
139
}
137
140
.category-description {
138
141
margin-top : var (--boxel-sp-sm );
139
- color : var (--boxel-400 );
140
142
display : -webkit-box ;
141
143
-webkit-box-orient : vertical ;
142
144
-webkit-line-clamp : 3 ;
143
145
overflow : hidden ;
144
146
text-overflow : ellipsis ;
147
+ font : 400 var (--boxel-font-sm );
148
+ letter-spacing : var (--boxel-lsp );
145
149
}
146
150
@container fitted-card ((aspect-ratio <= 0.92) and (height <= 182px)) {
147
151
.category-description {
@@ -201,7 +205,6 @@ export class BlogCategory extends CardDef {
201
205
}
202
206
< /style >
203
207
<div class =' blog-category' >
204
- {{! template-lint-disable no-inline-styles }}
205
208
<div class =' category-name' style ={{categoryStyle @ model}} >
206
209
<@ fields.shortName />
207
210
</div >
0 commit comments