Skip to content

Commit 68a4e2f

Browse files
feat(frontend): user component
1 parent a9902de commit 68a4e2f

File tree

6 files changed

+51
-0
lines changed

6 files changed

+51
-0
lines changed

helpers/frontend/views/frontend-components.njk

+11
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,17 @@
505505
items: ["fee", "fi", "fo", "fum"]
506506
}) }}
507507

508+
<h2><code>user</code></h2>
509+
510+
{{ user({
511+
avatar: {
512+
src: "/assets/app-icon-180-any.png"
513+
},
514+
name: "Indiekit",
515+
url: "https://getindiekit.com",
516+
meta: "A Node.js server"
517+
}) }}
518+
508519
<h2><code>warningText</code></h2>
509520

510521
{{ warningText({
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% macro user(opts) %}
2+
{%- include "./template.njk" -%}
3+
{% endmacro %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.user {
2+
align-items: center;
3+
display: flex;
4+
gap: var(--space-xs);
5+
}
6+
7+
.user__body {
8+
display: flex;
9+
flex-direction: column;
10+
gap: var(--space-2xs);
11+
}
12+
13+
.user__name {
14+
font: var(--user-name-font, var(--font-label));
15+
}
16+
17+
.user__meta {
18+
color: var(--color-on-offset);
19+
font: var(--font-caption);
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% from "../avatar/macro.njk" import avatar with context %}
2+
<div class="{{ classes("user", opts) }}">
3+
{{ avatar(opts.avatar) if opts.avatar }}
4+
5+
<div class="user__body">
6+
{% if opts.url %}
7+
<a class="user__name" href="{{ opts.url }}">{{- opts.name | safe -}}</a>
8+
{% else %}
9+
<span class="user__name">{{- opts.name | safe -}}</span>
10+
{% endif %}
11+
{% if opts.meta %}
12+
<span class="user__meta">{{ opts.meta | safe }}</span>
13+
{% endif %}
14+
</div>
15+
</div>

packages/frontend/layouts/default.njk

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
{% from "tag/macro.njk" import tag with context %}
2929
{% from "tag-input/macro.njk" import tagInput with context %}
3030
{% from "textarea/macro.njk" import textarea with context %}
31+
{% from "user/macro.njk" import user with context %}
3132
{% from "warning-text/macro.njk" import warningText with context %}
3233
{% from "widget/macro.njk" import widget with context %}
3334
{% set appClasses = "app" + (" " + appClasses if appClasses) + (" app--minimalui" if minimalui) %}

packages/frontend/styles/app.css

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
@import url("../components/tag/styles.css");
5959
@import url("../components/tag-input/styles.css");
6060
@import url("../components/textarea/styles.css");
61+
@import url("../components/user/styles.css");
6162
@import url("../components/warning-text/styles.css");
6263
@import url("../components/widget/styles.css");
6364

0 commit comments

Comments
 (0)