Skip to content

Commit 29855fa

Browse files
authored
Feature: correct open size of block type card + media card adjustments (#994)
* correction block type card * correction media card symbols and detail text
1 parent 9ef7f28 commit 29855fa

File tree

7 files changed

+110
-55
lines changed

7 files changed

+110
-55
lines changed

packages/uui-card-block-type/lib/uui-card-block-type.element.ts

+94-42
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { UUICardElement } from '@umbraco-ui/uui-card/lib';
33
import { css, html, nothing } from 'lit';
44
import { property } from 'lit/decorators.js';
55
import { ifDefined } from 'lit/directives/if-defined.js';
6-
import { styleMap } from 'lit/directives/style-map.js';
76

87
export 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 border 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
</button>
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 120ms;
201+
inset: 0;
202+
z-index: -1;
203+
border-top: 1px 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
}

packages/uui-card-media/lib/uui-card-media.element.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ export class UUICardMediaElement extends UUICardElement {
6262
if (this.hasPreview === true) return '';
6363

6464
if (this.fileExt === '') {
65-
return html`<uui-symbol-folder id="folder-symbol"></uui-symbol-folder>`;
65+
return html`<uui-symbol-folder id="entity-symbol"></uui-symbol-folder>`;
6666
}
6767

6868
return html`<uui-symbol-file
69-
id="file-symbol"
69+
id="entity-symbol"
7070
type="${this.fileExt}"></uui-symbol-file>`;
7171
}
7272

@@ -126,11 +126,11 @@ export class UUICardMediaElement extends UUICardElement {
126126
static styles = [
127127
...UUICardElement.styles,
128128
css`
129-
#file-symbol,
130-
#folder-symbol {
129+
#entity-symbol {
131130
align-self: center;
132-
margin: var(--uui-size-14);
133-
width: 80%;
131+
width: 60%;
132+
margin-bottom: var(--uui-size-layout-1);
133+
padding: var(--uui-size-space-6);
134134
}
135135
136136
slot[name='tag'] {
@@ -185,9 +185,11 @@ export class UUICardMediaElement extends UUICardElement {
185185
}
186186
187187
#open-part:hover {
188-
text-decoration: underline;
189188
color: var(--uui-color-interactive-emphasis);
190189
}
190+
#open-part:hover #name {
191+
text-decoration: underline;
192+
}
191193
192194
:host([image]:not([image=''])) #open-part {
193195
transition: opacity 0.5s 0.5s;

packages/uui-card/lib/uui-card.element.ts

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ export class UUICardElement extends SelectOnlyMixin(
142142
a {
143143
text-decoration: none;
144144
color: inherit;
145+
line-height: initial;
145146
}
146147
147148
button:focus,

packages/uui-symbol-file/lib/uui-symbol-file.element.ts

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export class UUISymbolFileElement extends LitElement {
4545
:host {
4646
position: relative;
4747
display: block;
48+
box-sizing: border-box;
4849
}
4950
5051
#file-type {

packages/uui-symbol-folder/lib/uui-symbol-folder.element.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ export class UUISymbolFolderElement extends LitElement {
2626
css`
2727
:host {
2828
display: block;
29-
box-sizing: border-box;
3029
position: relative;
31-
max-width: 100px;
30+
box-sizing: border-box;
3231
}
3332
3433
#icon {

packages/uui-symbol-folder/lib/uui-symbol-folder.story.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const meta: Meta = {
77
id: 'uui-symbol-folder',
88
component: 'uui-symbol-folder',
99
title: 'Symbols/Folder',
10-
render: () => html`<uui-symbol-folder></uui-symbol-folder>`,
10+
render: () =>
11+
html`<uui-symbol-folder style="width: 240px"></uui-symbol-folder>`,
1112
parameters: {
1213
readme: {
1314
markdown: readme,

packages/uui-tag/lib/uui-tag.element.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ export class UUITagElement extends LitElement {
5959
}
6060
6161
slot {
62-
display: flex;
63-
align-items: center;
64-
justify-content: center;
62+
display: block;
63+
align-content: center;
6564
margin: 2px;
6665
}
6766

0 commit comments

Comments
 (0)