@@ -3,7 +3,6 @@ import { UUICardElement } from '@umbraco-ui/uui-card/lib';
33import { css , html , nothing } from 'lit' ;
44import { property } from 'lit/decorators.js' ;
55import { ifDefined } from 'lit/directives/if-defined.js' ;
6- import { styleMap } from 'lit/directives/style-map.js' ;
76
87export type BlockTypeIcon = {
98 name ?: string ;
@@ -37,16 +36,19 @@ export class UUICardBlockTypeElement extends UUICardElement {
3736 description ?: string ;
3837
3938 @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+ }
4145
4246 render ( ) {
4347 return html `
44- <div
45- id= "portrait"
46- style = ${ styleMap ( { backgroundColor : this . background } ) } >
47- <slot> </ slot>
48- </ div>
48+ ${ this . #renderMedia( ) }
4949 ${ this . href ? this . #renderLink( ) : this . #renderButton( ) }
50+ <!- - Select bor der must be right after # open-part -- >
51+ <div id= "select-border" > </ div>
5052
5153 <slot name= "tag" > </ slot>
5254 <slot name= "actions" > </ slot>
@@ -61,8 +63,7 @@ export class UUICardBlockTypeElement extends UUICardElement {
6163 tabindex = ${ this . disabled ? ( nothing as any ) : '0' }
6264 @click = ${ this . handleOpenClick }
6365 @keydown = ${ this . handleOpenKeydown } >
64- <span id= "name" > ${ this . name } </ span>
65- <small> ${ this . description } </ small>
66+ ${ this . #renderContent( ) }
6667 </ butto n>
6768 ` ;
6869 }
@@ -81,55 +82,86 @@ export class UUICardBlockTypeElement extends UUICardElement {
8182 this . target === '_blank' ? 'noopener noreferrer' : undefined ,
8283 ) ,
8384 ) } >
84- <span id= "name" > ${ this . name } </ span>
85- <small> ${ this . description } </ small>
85+ ${ this . #renderContent( ) }
8686 </ a>
8787 ` ;
8888 }
8989
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+
90105 static styles = [
91106 ...UUICardElement . styles ,
92107 css `
93108 : host {
94- flex-direction : column;
95- justify-content : flex-start;
109+ background-color : var (--uui-color-surface-alt );
96110 }
97111
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 ;
100135 }
101136
102137 # portrait {
103- background-color : var (--uui-color-surface-alt );
104138 display : flex;
105139 justify-content : center;
106140 min-height : 150px ;
107141 max-height : 150px ;
142+ width : 100% ;
143+ margin-bottom : var (--uui-size-layout-2 );
108144 }
109145
110146 slot : not ([name ])::slotted (* ) {
111147 align-self : center;
112- font-size : var (--uui-size-8 );
113148 border-radius : var (--uui-border-radius );
114149 object-fit : cover;
115150 max-width : 100% ;
116151 max-height : 100% ;
152+ font-size : var (--uui-size-8 );
117153 }
118154
119155 # 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 ;
123159 color : var (--uui-color-interactive );
124160 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;
130162 display : flex;
131163 flex-direction : column;
132- line-height : normal ;
164+ justify-content : flex-end ;
133165 }
134166
135167 : host ([disabled ]) # open-part {
@@ -138,35 +170,43 @@ export class UUICardBlockTypeElement extends UUICardElement {
138170 color : var (--uui-color-contrast-disabled );
139171 }
140172
141- # open-part : hover strong {
142- text-decoration : underline;
143- }
144173 # open-part : hover {
145174 color : var (--uui-color-interactive-emphasis );
146175 }
176+ # open-part : hover # name {
177+ text-decoration : underline;
178+ }
147179
148180 : host ([image ]: not ([image = '' ])) # open-part {
149181 transition : opacity 0.5s 0.5s ;
150182 opacity : 0 ;
151183 }
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;
156187 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 );
158196 }
159197
160- slot [name = 'actions' ] {
198+ # content ::before {
199+ content : '' ;
161200 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 ;
169208 }
209+
170210 : host (: focus) slot[name = 'actions' ],
171211 : host (: focus- within) slot[name = 'actions' ],
172212 : host (: hover) slot[name = 'actions' ] {
@@ -185,6 +225,18 @@ export class UUICardBlockTypeElement extends UUICardElement {
185225 transition-duration : 120ms ;
186226 transition-delay : 0s ;
187227 }
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+ }
188240 ` ,
189241 ] ;
190242}
0 commit comments