Skip to content

Commit

Permalink
feat: avatar component (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelkeyzik authored Nov 3, 2023
1 parent b99742e commit e2de186
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/stories/components/Avatar.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Meta } from "@storybook/blocks";
import { UnstyledWithTheme } from "../../components/UnstyledWithTheme";

<Meta title="Components/Avatar" />

# Avatar

<UnstyledWithTheme>
<div style={{ display: "flex", flexDirection: 'column', gap: "16px" }}>
<div className="avatar">
<img src="https://picsum.photos/44" />
</div>
<div className="avatar">
pk
</div>
<button className="avatar">
<img src="https://picsum.photos/44" />
</button>
<a href="http://google.com" className="avatar">
pk
</a>
</div>
</UnstyledWithTheme>
41 changes: 41 additions & 0 deletions src/styles/components/avatar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
:root {
--avatar-background: var(--neutral-1);
--avatar-foreground: var(--neutral-9);
--avatar-border: var(--neutral-2);
}

.dark-theme {
--avatar-background: var(--neutral-9);
--avatar-foreground: var(--neutral-1);
--avatar-border: var(--neutral-8);
}

.avatar {
--font-scale: 1;

overflow: hidden;
display: flex;
align-items: center;
justify-content: center;

width: 44px;
height: 44px;
padding: 0;

font-size: calc(var(--font-scale) * var(--font-base-size));
font-weight: bold;
line-height: var(--line-height-scale);
color: var(--avatar-foreground);
text-decoration: none;
text-transform: uppercase;

background: var(--avatar-background);
border: 1px solid var(--avatar-border);
border-radius: var(--corner-5);
}

.avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}

0 comments on commit e2de186

Please sign in to comment.