|
9 | 9 | include 'error.php'; |
10 | 10 | exit; |
11 | 11 | } |
12 | | -$langs = $stats['languages']; |
13 | 12 |
|
14 | | -list($bar, $height, $header, $background) = extracted($stats['languages'], $dark); |
| 13 | +list($langs, $bar, $height, $header, $background) = extracted($stats['languages'], $dark); |
15 | 14 | ?> |
16 | 15 | <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"> |
17 | 16 | <title id="titleId"><?php echo $username ?>'s Code Stats</title> |
|
132 | 131 | </g> |
133 | 132 | </svg> |
134 | 133 | </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> |
136 | 135 | <g xmlns="http://www.w3.org/2000/svg" transform="translate(300, 55)" data-testid="main-card-progress"> |
137 | 136 | <svg data-testid="lang-items" x="25"> |
138 | 137 | <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 } ?> |
140 | 150 | <g transform="translate(0, 25)"> |
141 | 151 | <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> |
147 | 158 | </g> |
148 | | - </g> |
149 | | - <% });%> |
| 159 | + <?php } ?> |
150 | 160 | </g> |
151 | 161 | <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> |
157 | 168 | </g> |
158 | | - </g> |
159 | | - <% });%> |
| 169 | + <?php } ?> |
160 | 170 | </g> |
161 | 171 | </g> |
162 | 172 | </svg> |
|
0 commit comments