-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move all inline style to dedicated endpoint #2877
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,14 @@ | |
return $this->dj->getScoreboardZip($request, $requestStack, $contest, $this->scoreboardService); | ||
} | ||
|
||
#[Route(path: '/dynamic-css', name: 'get_dynamic_css')] | ||
public function dynamicCSS(): Response { | ||
$response = new Response(); | ||
$response->headers->set('Content-Type', 'text/css'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should maybe set some expire headers? Otherwise browsers won't cache it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We discussed and I'll try to implement a cache and keep the etag there. |
||
$response->setContent($this->renderView('public/dynamic.css.twig', $this->dj->getDynamicCSS())); | ||
return $response; | ||
Check failure on line 108 in webapp/src/Controller/PublicController.php GitHub Actions / phpcs
|
||
} | ||
|
||
/** | ||
* Get the contest from the request, if any | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{% autoescape false %} | ||
{% for i,color in backgroundColors %} | ||
{% set colorClass = color | replace({"#": "_"}) %} | ||
|
||
.cl{{ colorClass }} { | ||
background-color: {{ color }}; | ||
} | ||
|
||
{% set cMin = color|hexColorToRGBA(0) %} | ||
{% set cMax = color|hexColorToRGBA(1) %} | ||
|
||
.cl{{ colorClass }} .forceWidth.toolong:after { | ||
background: linear-gradient(to right, | ||
{{ cMin }} 0%, | ||
{{ cMax }} 96%); | ||
} | ||
{% endfor %} | ||
{% endautoescape %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is too broad. It should be something like
scoreboardCategoryColorCss
or something.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And rename if there are more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More dynamic CSS? I would put them in separate actions, since otherwise you get one big if here, which doesn't make sense IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change it for now, not sure if we have more pages like this so if the discussion will actually ever be non-theoretical.