@@ -3,7 +3,6 @@ import { UUICardElement } from '@umbraco-ui/uui-card/lib';
3
3
import { css , html , nothing } from 'lit' ;
4
4
import { property } from 'lit/decorators.js' ;
5
5
import { ifDefined } from 'lit/directives/if-defined.js' ;
6
- import { styleMap } from 'lit/directives/style-map.js' ;
7
6
8
7
export type BlockTypeIcon = {
9
8
name ?: string ;
@@ -37,16 +36,19 @@ export class UUICardBlockTypeElement extends UUICardElement {
37
36
description ?: string ;
38
37
39
38
@property ( { type : String , attribute : 'background' } )
40
- background ?: string ;
39
+ public get background ( ) : string | undefined {
40
+ return undefined ;
41
+ }
42
+ public set background ( value : string | undefined ) {
43
+ this . style . backgroundColor = value ?? '' ;
44
+ }
41
45
42
46
render ( ) {
43
47
return html `
44
- <div
45
- id= "portrait"
46
- style = ${ styleMap ( { backgroundColor : this . background } ) } >
47
- <slot> </ slot>
48
- </ div>
48
+ ${ this . #renderMedia( ) }
49
49
${ this . href ? this . #renderLink( ) : this . #renderButton( ) }
50
+ <!- - Select bor der must be right after # open-part -- >
51
+ <div id= "select-border" > </ div>
50
52
51
53
<slot name= "tag" > </ slot>
52
54
<slot name= "actions" > </ slot>
@@ -61,8 +63,7 @@ export class UUICardBlockTypeElement extends UUICardElement {
61
63
tabindex = ${ this . disabled ? ( nothing as any ) : '0' }
62
64
@click = ${ this . handleOpenClick }
63
65
@keydown = ${ this . handleOpenKeydown } >
64
- <span id= "name" > ${ this . name } </ span>
65
- <small> ${ this . description } </ small>
66
+ ${ this . #renderContent( ) }
66
67
</ butto n>
67
68
` ;
68
69
}
@@ -81,55 +82,86 @@ export class UUICardBlockTypeElement extends UUICardElement {
81
82
this . target === '_blank' ? 'noopener noreferrer' : undefined ,
82
83
) ,
83
84
) } >
84
- <span id= "name" > ${ this . name } </ span>
85
- <small> ${ this . description } </ small>
85
+ ${ this . #renderContent( ) }
86
86
</ a>
87
87
` ;
88
88
}
89
89
90
+ #renderMedia( ) {
91
+ return html `<div id= "portrait" >
92
+ <slot> </ slot>
93
+ </ div> ` ;
94
+ }
95
+
96
+ #renderContent( ) {
97
+ return html `
98
+ <div id= "content" >
99
+ <span id= "name" > ${ this . name } </ span>
100
+ <small> ${ this . description } <slot name= "description" > </ slot> </ small>
101
+ </ div> </ div>
102
+ ` ;
103
+ }
104
+
90
105
static styles = [
91
106
...UUICardElement . styles ,
92
107
css `
93
108
: host {
94
- flex-direction : column;
95
- justify-content : flex-start;
109
+ background-color : var (--uui-color-surface-alt );
96
110
}
97
111
98
- : host (: hover ) # info {
99
- color : var (--uui-color-interactive-emphasis );
112
+ slot [name = 'tag' ] {
113
+ position : absolute;
114
+ top : var (--uui-size-4 );
115
+ right : var (--uui-size-4 );
116
+ display : flex;
117
+ justify-content : right;
118
+ z-index : 2 ;
119
+ }
120
+
121
+ slot [name = 'actions' ] {
122
+ position : absolute;
123
+ top : var (--uui-size-4 );
124
+ right : var (--uui-size-4 );
125
+ display : flex;
126
+ justify-content : right;
127
+ z-index : 2 ;
128
+ opacity : 0 ;
129
+ transition : opacity 120ms ;
130
+ }
131
+ : host (: focus) slot[name = 'actions' ],
132
+ : host (: focus- within) slot[name = 'actions' ],
133
+ : host (: hover) slot[name = 'actions' ] {
134
+ opacity : 1 ;
100
135
}
101
136
102
137
# portrait {
103
- background-color : var (--uui-color-surface-alt );
104
138
display : flex;
105
139
justify-content : center;
106
140
min-height : 150px ;
107
141
max-height : 150px ;
142
+ width : 100% ;
143
+ margin-bottom : var (--uui-size-layout-2 );
108
144
}
109
145
110
146
slot : not ([name ])::slotted (* ) {
111
147
align-self : center;
112
- font-size : var (--uui-size-8 );
113
148
border-radius : var (--uui-border-radius );
114
149
object-fit : cover;
115
150
max-width : 100% ;
116
151
max-height : 100% ;
152
+ font-size : var (--uui-size-8 );
117
153
}
118
154
119
155
# open-part {
120
- text-align : left ;
121
- background-color : var ( --uui-color-surface ) ;
122
- cursor : pointer ;
156
+ position : absolute ;
157
+ z-index : 1 ;
158
+ inset : 0 ;
123
159
color : var (--uui-color-interactive );
124
160
border : none;
125
- border-top : 1px solid var (--uui-color-divider );
126
- border-radius : 0 0 var (--uui-border-radius ) var (--uui-border-radius );
127
- font-family : inherit;
128
- box-sizing : border-box;
129
- padding : var (--uui-size-2 ) var (--uui-size-4 );
161
+ cursor : pointer;
130
162
display : flex;
131
163
flex-direction : column;
132
- line-height : normal ;
164
+ justify-content : flex-end ;
133
165
}
134
166
135
167
: host ([disabled ]) # open-part {
@@ -138,35 +170,43 @@ export class UUICardBlockTypeElement extends UUICardElement {
138
170
color : var (--uui-color-contrast-disabled );
139
171
}
140
172
141
- # open-part : hover strong {
142
- text-decoration : underline;
143
- }
144
173
# open-part : hover {
145
174
color : var (--uui-color-interactive-emphasis );
146
175
}
176
+ # open-part : hover # name {
177
+ text-decoration : underline;
178
+ }
147
179
148
180
: host ([image ]: not ([image = '' ])) # open-part {
149
181
transition : opacity 0.5s 0.5s ;
150
182
opacity : 0 ;
151
183
}
152
- slot [name = 'tag' ] {
153
- position : absolute;
154
- top : var (--uui-size-4 );
155
- right : var (--uui-size-4 );
184
+
185
+ # content {
186
+ position : relative;
156
187
display : flex;
157
- justify-content : right;
188
+ flex-direction : column;
189
+ width : 100% ;
190
+ font-family : inherit;
191
+ font-size : var (--uui-type-small-size );
192
+ box-sizing : border-box;
193
+ text-align : left;
194
+ word-break : break-word;
195
+ padding-top : var (--uui-size-space-3 );
158
196
}
159
197
160
- slot [name = 'actions' ] {
198
+ # content ::before {
199
+ content : '' ;
161
200
position : absolute;
162
- top : var ( --uui-size-4 ) ;
163
- right : var ( --uui-size-4 ) ;
164
- display : flex ;
165
- justify-content : right ;
166
-
167
- opacity : 0 ;
168
- transition : opacity 120 ms ;
201
+ inset : 0 ;
202
+ z-index : -1 ;
203
+ border-top : 1 px solid var ( --uui-color-divider ) ;
204
+ border-radius : 0 0 var ( --uui-border-radius ) var ( --uui-border-radius ) ;
205
+ background-color : var ( --uui-color-surface );
206
+ pointer-events : none ;
207
+ opacity : 0.96 ;
169
208
}
209
+
170
210
: host (: focus) slot[name = 'actions' ],
171
211
: host (: focus- within) slot[name = 'actions' ],
172
212
: host (: hover) slot[name = 'actions' ] {
@@ -185,6 +225,18 @@ export class UUICardBlockTypeElement extends UUICardElement {
185
225
transition-duration : 120ms ;
186
226
transition-delay : 0s ;
187
227
}
228
+
229
+ : host ([selectable ]) # open-part {
230
+ inset : var (--uui-size-space-3 ) var (--uui-size-space-4 );
231
+ }
232
+ : host (: not ([selectable ])) # content {
233
+ padding : var (--uui-size-space-3 ) var (--uui-size-space-4 );
234
+ }
235
+ : host ([selectable ]) # content ::before {
236
+ inset : calc (var (--uui-size-space-3 ) * -1 )
237
+ calc (var (--uui-size-space-4 ) * -1 );
238
+ top : 0 ;
239
+ }
188
240
` ,
189
241
] ;
190
242
}
0 commit comments