Skip to content

Commit 00b0e63

Browse files
committed
Update user cards with better-looking styles
Mainly optimizes for dark background, but makes light background nicer too
1 parent b4c2bd7 commit 00b0e63

3 files changed

Lines changed: 41 additions & 14 deletions

File tree

_includes/author-card.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
{% assign author_no_at_sign = include.author | strip_html | remove_first: "@" %}
44
{% assign at_sign = include.author | strip_html | replace: author_no_at_sign %}
5+
{% if include.theme %}
6+
{% assign extra_classes = "user-card-" | append: include.theme %}
7+
{% endif %}
58
<!-- first function does not work and truncate function returns trailing "..." -->
69
{% assign test_at_sign_is_first = include.author | truncate: 4 | replace: "@" | size %}
710
<!-- this looks weird, but it was the only way I could figure out how to test
811
that the first character of include.author is "@" -->
912
{% if at_sign.size > 0 and test_at_sign_is_first == 3 %}
10-
<div data-card-user="{{author_no_at_sign}}"></div><br/>
13+
<div data-card-user="{{author_no_at_sign}}" class="{{ extra_classes }}"></div><br/>
1114
{% else %}
12-
<div class="user-card"><div class="user-card-name">{{ include.author }}</div></div>
15+
<div class="user-card {{ extra_classes }}"><div class="user-card-name">{{ include.author }}</div></div>
1316
{% endif %}

_layouts/tutorial.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ <h2> Authors </h2>
2626
<h2> Author </h2>
2727
{% endif %}
2828
{% for author in page.author %}
29-
<div style="float: left; margin-right: 20px;">{% include author-card.html author = author %}</div>
29+
<div style="float: left; margin-right: 20px;">{% include author-card.html author=author theme='light' %}</div>
3030
{% endfor %}
3131
{% endif %}

stylesheets/user-cards.scss

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,50 @@
11
---
22
---
33

4+
@import "custom-variables";
5+
6+
@keyframes card-hover {
7+
from { border-left-width: 4px; }
8+
to { border-left-width: 8px; }
9+
}
10+
11+
@keyframes card-hover-out {
12+
from { border-left-width: 8px; }
13+
to { border-left-width: 4px; }
14+
}
15+
416
.user-card {
517
position: relative;
618
min-height: 40px;
719
min-width: 218px;
820
background-color: #252525;
921
font-family: "Helvetica", Arial, sans-serif;
1022
color: #fff;
11-
border-radius: 2px;
23+
border-radius: 3px;
1224
text-align: center;
1325
font-weight: 100;
14-
padding: 5px;
15-
-moz-box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.7);
16-
-webkit-box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.7);
17-
-o-box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.7);
18-
box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.7);
26+
padding: 5px 5px 5px 0;
27+
border-left: 4px solid $brand-primary;
28+
29+
animation: card-hover-out;
30+
animation-duration: 0.1s;
31+
32+
&:hover {
33+
border-left-color: darken($brand-primary, 10%);
34+
animation: card-hover;
35+
animation-duration: 0.1s;
36+
animation-fill-mode: forwards;
37+
}
38+
39+
a {
40+
color: #eeeeee;
41+
}
1942

2043
.user-card-avatar {
2144
position: absolute;
2245
float: left;
23-
max-height: 100%;
46+
height: 100%;
2447
width: auto;
25-
max-width: 20%;
2648
top: 50%;
2749
-webkit-transform: translateY(-50%);
2850
-ms-transform: translateY(-50%);
@@ -32,9 +54,7 @@
3254

3355
img {
3456
vertical-align: middle;
35-
border: 1px solid #aaa;
36-
border-radius: 2px;
37-
height: 40px;
57+
height: 100%;
3858
}
3959
}
4060

@@ -58,3 +78,7 @@
5878
vertical-align: middle;
5979
}
6080
}
81+
82+
.user-card-light {
83+
background-color: #303030;
84+
}

0 commit comments

Comments
 (0)