Skip to content
This repository was archived by the owner on May 11, 2025. It is now read-only.

Commit 04e1de9

Browse files
committed
update user view
1 parent 7213f57 commit 04e1de9

3 files changed

Lines changed: 31 additions & 20 deletions

File tree

app/repo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
$langs = $stats['languages'];
1414
$name = "$username/$repo";
1515

16-
list($bar, $height, $header, $background) = extracted($stats['languages'], $dark);
16+
list($langs, $bar, $height, $header, $background) = extracted($stats['languages'], $dark);
1717
?>
1818
<svg width="540" viewBox="0 0 660 <?php echo $height + 1 ?>" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="descId">
1919
<title id="titleId"><?php echo $name ?>'s Code Stats</title>

app/user.php

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
include 'error.php';
1010
exit;
1111
}
12-
$langs = $stats['languages'];
1312

14-
list($bar, $height, $header, $background) = extracted($stats['languages'], $dark);
13+
list($langs, $bar, $height, $header, $background) = extracted($stats['languages'], $dark);
1514
?>
1615
<svg width="540" viewBox="0 0 660 <?php echo $height + 1 ?>" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="descId">
1716
<title id="titleId"><?php echo $username ?>'s Code Stats</title>
@@ -132,31 +131,42 @@
132131
</g>
133132
</svg>
134133
</g>
135-
<line x1="290" y1="40" x2="290" y2="<%- height - 40 %>" stroke="#eeecec"></line>
134+
<line x1="290" y1="40" x2="290" y2="<?php echo $height - 40 ?>" stroke="#eeecec"></line>
136135
<g xmlns="http://www.w3.org/2000/svg" transform="translate(300, 55)" data-testid="main-card-progress">
137136
<svg data-testid="lang-items" x="25">
138137
<mask id="rect-mask"><rect x="0" y="0" width="300" height="8" fill="white" rx="5"/></mask>
139-
<% langs.forEach(function(lang){ %><rect mask="url(#rect-mask)" data-testid="lang-progress" x="<%- lang.cursor * 300 %>" y="0" width="<%- lang.ratio * 300 %>" height="8" fill="<%- lang.color %>"/><% }); %>
138+
<?php $cursor = 0. ?>
139+
<?php foreach ($langs as $lang) { ?>
140+
<rect
141+
mask="url(#rect-mask)"
142+
data-testid="lang-progress"
143+
x="<?php echo $cursor * 3 ?>"
144+
y="0" width="<?php echo $lang['percent'] * 3 ?>"
145+
height="8"
146+
fill="<?php echo $lang['color'] ?>"
147+
/>
148+
<?php $cursor += $lang['percent'] ?>
149+
<?php } ?>
140150
<g transform="translate(0, 25)">
141151
<g transform="translate(0, 0)">
142-
<% langs.splice(0, left).forEach(function (lang, idx) { %>
143-
<g transform="translate(0, <%- idx * 25 %>)">
144-
<g class="stagger" style="animation-delay: <%- 450 + (idx * 150) %>ms">
145-
<circle cx="5" cy="6" r="5" fill="<%- lang.color %>"/>
146-
<text data-testid="lang-name" x="15" y="10" class="lang"><%- lang.text %></text>
152+
<?php foreach (array_splice($langs, 0, $bar) as $idx => $lang) { ?>
153+
<g transform="translate(0, <?php echo $idx * 25 ?>)">
154+
<g class="stagger" style="animation-delay: <?php echo 450 + ($idx * 150) ?>ms">
155+
<circle cx="5" cy="6" r="5" fill="<?php echo $lang['color'] ?>"/>
156+
<text data-testid="lang-name" x="15" y="10" class="lang"><?php echo $lang['text'] ?></text>
157+
</g>
147158
</g>
148-
</g>
149-
<% });%>
159+
<?php } ?>
150160
</g>
151161
<g transform="translate(150, 0)">
152-
<% langs.splice(0, left).forEach(function (lang, idx) { %>
153-
<g transform="translate(0, <%- idx * 25 %>)">
154-
<g class="stagger" style="animation-delay: <%- 450 + (idx * 150) %>ms">
155-
<circle cx="5" cy="6" r="5" fill="<%- lang.color %>"/>
156-
<text data-testid="lang-name" x="15" y="10" class="lang"><%- lang.text %></text>
162+
<?php foreach (array_splice($langs, 0, $bar) as $idx => $lang) { ?>
163+
<g transform="translate(0, <?php echo $idx * 25 ?>)">
164+
<g class="stagger" style="animation-delay: <?php echo 450 + ($idx * 150) ?>ms">
165+
<circle cx="5" cy="6" r="5" fill="<?php echo $lang['color'] ?>"/>
166+
<text data-testid="lang-name" x="15" y="10" class="lang"><?php echo $lang['text'] ?></text>
167+
</g>
157168
</g>
158-
</g>
159-
<% });%>
169+
<?php } ?>
160170
</g>
161171
</g>
162172
</svg>

app/utils.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ function get($param, $default = null)
3636
*/
3737
function extracted($languages, $dark)
3838
{
39+
$languages = $languages ? $languages : array();
3940
$bar = ceil(count($languages) / 2);
4041
$height = 215 + ($bar > 4 ? ($bar - 4) * 20 : 0);
4142

4243
$header = $dark ? "#fff" : "#434d58";
4344
$background = $dark ? "#000" : "#fffefe";
4445
ob_start('compress');
45-
return array($bar, $height, $header, $background);
46+
return array($languages, $bar, $height, $header, $background);
4647
}

0 commit comments

Comments
 (0)