project Websites / Gitlab Issue Listing Script avatar

websites/Gitlab-Issue-Listing-Script#53: Make Label CSS DRY

Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Milestone: v0.5
Created: 27-Aug-22 14:13


When we display label lozenges we rely on CSS to dictate colouring etc.

That CSS is dynamically generated based on information returned by Gitlab's API (as users can change colours etc).

Currently, the underlying CSS is generated manually wherever it's required and is embedded into the page markup.

The result is that there are various methods in the model which do something like

        foreach($o["labels"] as $label){
            $o["label_css"][] = GILSUtils::buildLabelCSS($label);

And a number of views which do

<?php if (count($milestone["label_css"]) > 0): ?>
<style type="text/css">
<?php echo implode("",$milestone["label_css"]); ?>
<?php endif; ?>

This is not good, and I should know better...

We should create a routed call which can generate a CSS file containing the CSS for all labels within a project. A standardised anchor out to that can then be added to views.

It'll also mean that browsers can cache that CSS and won't need to load those bytes in the body of every page which references them.

Toggle State Changes


assigned to @btasker


mentioned in commit 9aa9a6cf137fffabb4551e1f7da51efff4609901

Commit: 9aa9a6cf137fffabb4551e1f7da51efff4609901 
Author: B Tasker                            
Date: 2022-08-27T15:31:12.000+01:00 


Make label CSS generation DRY for websites/Gitlab-Issue-Listing-Script#53

This removes various copies of the logic and creates a single routed path to a CSS file containing CSS information for all label IDs within a project

+47 -52 (99 lines changed)