Skip to content

Commit 87cfb2a

Browse files
Add avatar component
1 parent 4ef66e4 commit 87cfb2a

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22
1+
23

apps/docs/docs.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,28 @@ <h2>Form elements</h2>
300300
</button>
301301
</form>
302302
</section>
303+
<section id="avatar">
304+
<h2>Avatar</h2>
305+
<p>
306+
Avatar images are styled automatically when alt text contains
307+
"avatar" or "profile":
308+
</p>
309+
<div>
310+
<img src="https://picsum.photos/id/237/150" alt="User avatar" />
311+
<img src="https://picsum.photos/id/238/150" alt="Profile picture" />
312+
<img src="https://picsum.photos/id/239/150" alt="John's avatar" />
313+
<img
314+
src="https://picsum.photos/id/236/150"
315+
alt="Team member profile"
316+
/>
317+
</div>
318+
<p>Avatars work in different contexts like navigation and content:</p>
319+
<p>
320+
<img src="https://picsum.photos/id/235/150" alt="Author avatar" />
321+
Written by <strong>Alex Johnson</strong> - This article was written
322+
by our lead developer.
323+
</p>
324+
</section>
303325
<section id="modal">
304326
<h2>Modal</h2>
305327
<button class="contrast" onclick="modalExample.showModal()">
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
img[alt*="avatar" i],
2+
img[alt*="profile" i] {
3+
border: 1px solid var(--border);
4+
border-radius: 50%;
5+
width: 2.5rem;
6+
height: 2.5rem;
7+
object-fit: cover;
8+
}
9+
10+
/* Fallback for missing images */
11+
img[alt*="avatar" i]:not([src]),
12+
img[alt*="profile" i]:not([src]) {
13+
display: inline-flex;
14+
justify-content: center;
15+
align-items: center;
16+
background: var(--background-secondary);
17+
color: var(--color-muted);
18+
font-weight: 500;
19+
font-size: 0.875rem;
20+
}
21+
22+
/* Style for broken/loading images */
23+
img[alt*="avatar" i]::after,
24+
img[alt*="profile" i]::after {
25+
display: flex;
26+
justify-content: center;
27+
align-items: center;
28+
background: var(--background-secondary);
29+
width: 100%;
30+
height: 100%;
31+
content: attr(alt);
32+
color: var(--color-muted);
33+
font-weight: 500;
34+
font-size: 0.75rem;
35+
line-height: 1;
36+
text-align: center;
37+
}

packages/main/src/compoments/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
@use "form";
1515
@use "blog";
1616
@use "tabs";
17+
@use "avatar";

0 commit comments

Comments
 (0)