Skip to content

Commit 7a88928

Browse files
committed
Improve colors on DinoChart
1 parent 52dc225 commit 7a88928

File tree

4 files changed

+71
-4
lines changed

4 files changed

+71
-4
lines changed

ux.symfony.com/assets/styles/app/_html.scss

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ body {
1010

1111
a, a.page-link, a.page-link:hover {
1212
text-decoration: none;
13-
color: var(--color-primary);
13+
color: inherit;
1414
}
1515

1616
::selection {
@@ -27,6 +27,7 @@ a, a.page-link, a.page-link:hover {
2727
min-width: 320px;
2828
overflow-x: clip;
2929
}
30+
3031
main {
3132
flex-grow: 1;
3233
}
@@ -35,3 +36,28 @@ main,
3536
footer {
3637
flex-shrink: 0;
3738
}
39+
40+
a.link {
41+
--color: #d9438e;
42+
color: var(--color);
43+
position: relative;
44+
&:after {
45+
position: absolute;
46+
content:"";
47+
bottom: -2px;
48+
left: 0;
49+
right: 0;
50+
height: 1px;
51+
display: block;
52+
transition: all .2s ease-in-out;
53+
background: var(--color);
54+
transform: scaleX(0);
55+
transform-origin: center left;
56+
}
57+
&:hover {
58+
&:after {
59+
transform: scaleX(1);
60+
transition: transform .15s ease-in-out revert;
61+
}
62+
}
63+
}

ux.symfony.com/src/Service/DinoStatsService.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ class DinoStatsService
1717

1818
private const ALL_DINOS = 'all';
1919

20+
private const COLORS = [
21+
'de3232',
22+
'de6732',
23+
'dede32',
24+
'67de32',
25+
'32de32',
26+
'32de67',
27+
'32dede',
28+
'3267de',
29+
'3232de',
30+
'6732de',
31+
'de32de',
32+
'de3267',
33+
];
34+
2035
public static function getAllTypes(): array
2136
{
2237
return [
@@ -48,8 +63,11 @@ public function fetchData(int $start, int $end, array $types): array
4863

4964
$datasets = [];
5065

66+
$colors = self::COLORS;
67+
shuffle($colors);
68+
5169
foreach ($types as $type) {
52-
$color = sprintf('rgb(%d, %d, %d, .4)', mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
70+
$color = '#'.(next($colors) ?: reset($colors));
5371

5472
$datasets[] = [
5573
'label' => ucwords($type),

ux.symfony.com/src/Twig/DinoChart.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class DinoChart
2929

3030
#[LiveProp(writable: true)]
3131
public int $fromYear = -200;
32+
3233
#[LiveProp(writable: true)]
3334
public int $toYear = -65;
3435

@@ -59,6 +60,24 @@ public function getChart(): Chart
5960
abs($this->toYear)
6061
),
6162
],
63+
'legend' => [
64+
'labels' => [
65+
'boxHeight' => 20,
66+
'boxWidth' => 50,
67+
'padding' => 20,
68+
'font' => [
69+
'size' => 14,
70+
],
71+
],
72+
],
73+
],
74+
'elements' => [
75+
'line' => [
76+
'borderWidth' => 5,
77+
'tension' => 0.25,
78+
'borderCapStyle' => 'round',
79+
'borderJoinStyle' => 'round',
80+
],
6281
],
6382
'maintainAspectRatio' => false,
6483
]);

ux.symfony.com/templates/components/DinoChart.html.twig

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@
4545

4646
<hr>
4747

48-
<div style="min-height: 400px;">
48+
<div style="min-height: 480px; margin-bottom: 1.5rem;">
4949
{{ render_chart(chart) }}
5050
</div>
5151

52-
<small>Source: <a href="https://www.nhm.ac.uk/">National History Museum</a> courtesy of https://github.com/kjanjua26/jurassic-park</small>
52+
<small>Source:
53+
<a href="https://www.nhm.ac.uk/" class="link">National History Museum</a> courtesy of
54+
<a href="https://github.com/kjanjua26/jurassic-park" class="link">https://github.com/kjanjua26/jurassic-park</a>
55+
</small>
56+
5357
</div>

0 commit comments

Comments
 (0)