Skip to content

Commit db1803d

Browse files
committed
update media card
1 parent 03350f4 commit db1803d

File tree

1 file changed

+66
-31
lines changed

1 file changed

+66
-31
lines changed

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

Lines changed: 66 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ export class UUICardMediaElement extends UUICardElement {
2323
@property({ type: String })
2424
name = '';
2525

26+
/**
27+
* Media detail
28+
* @type {string}
29+
* @attr detail
30+
* @default ''
31+
*/
32+
@property({ type: String })
33+
detail?: string;
34+
2635
/**
2736
* Media file extension, without "."
2837
* @type {string}
@@ -68,15 +77,7 @@ export class UUICardMediaElement extends UUICardElement {
6877
tabindex=${this.disabled ? (nothing as any) : '0'}
6978
@click=${this.handleOpenClick}
7079
@keydown=${this.handleOpenKeydown}>
71-
<!--
72-
TODO: Implement when pop-out is ready
73-
<uui-icon
74-
id="info-icon"
75-
name="info"
76-
style="color: currentColor">
77-
</uui-icon>
78-
-->
79-
<span>${this.name}</span>
80+
${this.#renderContent()}
8081
</button>
8182
`;
8283
}
@@ -94,16 +95,20 @@ export class UUICardMediaElement extends UUICardElement {
9495
this.target === '_blank' ? 'noopener noreferrer' : undefined,
9596
),
9697
)}>
98+
${this.#renderContent()}
99+
</a>
100+
`;
101+
}
102+
103+
#renderContent() {
104+
return html`
105+
<div id="content">
97106
<!--
98-
TODO: Implement when pop-out is ready
99-
<uui-icon
100-
id="info-icon"
101-
name="info"
102-
style="color: currentColor">
103-
</uui-icon>
107+
TODO: Implement info box when pop-out is ready
104108
-->
105-
<span>${this.name}</span>
106-
</a>
109+
<span id="name">${this.name}</span>
110+
${this.detail}<slot name="detail"></slot>
111+
</div>
107112
`;
108113
}
109114

@@ -162,28 +167,18 @@ export class UUICardMediaElement extends UUICardElement {
162167
163168
#open-part {
164169
position: absolute;
165-
bottom: 0;
166-
width: 100%;
167-
background-color: var(--uui-color-surface);
170+
z-index: 1;
171+
inset: 0;
168172
color: var(--uui-color-interactive);
169173
border: none;
170174
cursor: pointer;
171-
border-top: 1px solid var(--uui-color-divider);
172-
border-radius: 0 0 var(--uui-border-radius) var(--uui-border-radius);
173175
display: flex;
174-
justify-content: flex-start;
175-
align-items: center;
176-
font-family: inherit;
177-
font-size: var(--uui-type-small-size);
178-
box-sizing: border-box;
179-
padding: var(--uui-size-2) var(--uui-size-4);
180-
text-align: left;
181-
word-break: break-word;
176+
flex-direction: column;
177+
justify-content: flex-end;
182178
}
183179
184180
:host([disabled]) #open-part {
185181
pointer-events: none;
186-
background: var(--uui-color-disabled);
187182
color: var(--uui-color-contrast-disabled);
188183
}
189184
@@ -197,6 +192,34 @@ export class UUICardMediaElement extends UUICardElement {
197192
opacity: 0;
198193
}
199194
195+
#content {
196+
position: relative;
197+
display: flex;
198+
width: 100%;
199+
align-items: center;
200+
font-family: inherit;
201+
font-size: var(--uui-type-small-size);
202+
box-sizing: border-box;
203+
text-align: left;
204+
word-break: break-word;
205+
padding-top: var(--uui-size-space-3);
206+
}
207+
208+
#content::before {
209+
content: '';
210+
position: absolute;
211+
inset: 0;
212+
z-index: -1;
213+
border-radius: 0 0 var(--uui-border-radius) var(--uui-border-radius);
214+
background-color: var(--uui-color-surface);
215+
pointer-events: none;
216+
opacity: 0.96;
217+
}
218+
219+
#name {
220+
font-weight: 700;
221+
}
222+
200223
:host(
201224
[image]:not([image='']):hover,
202225
[image]:not([image='']):focus,
@@ -210,6 +233,18 @@ export class UUICardMediaElement extends UUICardElement {
210233
transition-delay: 0s;
211234
}
212235
236+
:host([selectable]) #open-part {
237+
inset: var(--uui-size-space-3) var(--uui-size-space-4);
238+
}
239+
:host(:not([selectable])) #content {
240+
padding: var(--uui-size-space-3) var(--uui-size-space-4);
241+
}
242+
:host([selectable]) #content::before {
243+
inset: calc(var(--uui-size-space-3) * -1)
244+
calc(var(--uui-size-space-4) * -1);
245+
top: 0;
246+
}
247+
213248
/*
214249
#info-icon {
215250
margin-right: var(--uui-size-2);

0 commit comments

Comments
 (0)