Skip to content

Commit

Permalink
refactor: Normalize theme names and colors (#464)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
DenverCoder1 and github-actions[bot] authored Feb 27, 2023
1 parent 7aa4f9c commit 5359b0e
Show file tree
Hide file tree
Showing 4 changed files with 776 additions and 758 deletions.
34 changes: 16 additions & 18 deletions docs/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ You can also try out and customize these themes on the [Demo Site](https://strea
| `radical` | ![image](https://user-images.githubusercontent.com/20955511/183303809-eb8fea2f-d56b-4ad3-9f6d-ef55f8812ed2.png) |
| `merko` | ![image](https://user-images.githubusercontent.com/20955511/183303806-4ce9e5bb-6bd7-4914-a4ff-47edee01bde3.png) |
| `gruvbox` | ![image](https://user-images.githubusercontent.com/20955511/183303804-95ff960f-ad52-4026-8627-a67f1599cee3.png) |
| `gruvbox_duo` | ![image](https://user-images.githubusercontent.com/20955511/183303801-eb1d8dea-7f89-4075-b334-542bb546dfcd.png) |
| `gruvbox-duo` | ![image](https://user-images.githubusercontent.com/20955511/183303801-eb1d8dea-7f89-4075-b334-542bb546dfcd.png) |
| `tokyonight` | ![image](https://user-images.githubusercontent.com/20955511/183303799-e039b635-5424-437b-9f87-7ed9dca8aea6.png) |
| `tokyonight_duo` | ![image](https://user-images.githubusercontent.com/20955511/183303796-03bb6eb2-667f-492b-8397-efd2ad93edeb.png) |
| `tokyonight-duo` | ![image](https://user-images.githubusercontent.com/20955511/183303796-03bb6eb2-667f-492b-8397-efd2ad93edeb.png) |
| `onedark` | ![image](https://user-images.githubusercontent.com/20955511/183303794-54389af4-24f3-41e6-9d70-2e949d19227e.png) |
| `onedark_duo` | ![image](https://user-images.githubusercontent.com/20955511/183303791-a4a6d5f0-ab3a-4f6e-b4cc-a87bb24fd135.png) |
| `onedark-duo` | ![image](https://user-images.githubusercontent.com/20955511/183303791-a4a6d5f0-ab3a-4f6e-b4cc-a87bb24fd135.png) |
| `cobalt` | ![image](https://user-images.githubusercontent.com/20955511/183303787-eaa77366-6f13-4dc8-a0fa-637ac5333612.png) |
| `synthwave` | ![image](https://user-images.githubusercontent.com/20955511/183303784-6257055f-d206-4d1a-bdb9-95e9dd7052fb.png) |
| `dracula` | ![image](https://user-images.githubusercontent.com/20955511/183303782-2231d9eb-9b65-4cf9-9e26-f4cfb773abf6.png) |
Expand Down Expand Up @@ -52,23 +52,23 @@ You can also try out and customize these themes on the [Demo Site](https://strea
| `maroongold` | ![image](https://user-images.githubusercontent.com/20955511/183303731-08ca9109-551d-4052-a17f-630cbb0cf323.png) |
| `yeblu` | ![image](https://user-images.githubusercontent.com/20955511/183303730-5ffad264-362d-4ee6-82b2-15b8a8669462.png) |
| `blueberry` | ![image](https://user-images.githubusercontent.com/20955511/183303729-f3c89ba7-efef-437e-9a05-fa5feebb9d72.png) |
| `blueberry_duo` | ![image](https://user-images.githubusercontent.com/20955511/183303728-4d209b8c-536f-4921-aa43-6371f1e313fe.png) |
| `blueberry-duo` | ![image](https://user-images.githubusercontent.com/20955511/183303728-4d209b8c-536f-4921-aa43-6371f1e313fe.png) |
| `slateorange` | ![image](https://user-images.githubusercontent.com/20955511/183303727-7ffec3ef-1303-4096-bd0f-f8fc1e4949e6.png) |
| `kacho_ga` | ![image](https://user-images.githubusercontent.com/20955511/183303726-9adaaf73-2ea8-4b78-a3f4-7382ce299511.png) |
| `kacho-ga` | ![image](https://user-images.githubusercontent.com/20955511/183303726-9adaaf73-2ea8-4b78-a3f4-7382ce299511.png) |
| `ads-juicy-fresh` | ![image](https://user-images.githubusercontent.com/20955511/183303725-25851d72-963a-4532-a5ca-1eaae6c4c224.png) |
| `black-ice` | ![image](https://user-images.githubusercontent.com/20955511/183303724-de45e18a-d4f8-48ae-88c1-d54a35d2ecea.png) |
| `soft-green` | ![image](https://user-images.githubusercontent.com/20955511/183303722-3ae70df8-87ff-4b3b-a941-f84cef5dddf4.png) |
| `blood` | ![image](https://user-images.githubusercontent.com/20955511/183303721-a22ea310-ebab-4ef5-bab9-2f1d7e7c566d.png) |
| `blood-dark` | ![image](https://user-images.githubusercontent.com/20955511/183303720-487819af-3c20-4854-8ae1-85d70115cf80.png) |
| `green_nur` | ![image](https://user-images.githubusercontent.com/20955511/183303719-dc5ad223-cdd6-4830-9ffb-0ae965ec0159.png) |
| `green-nur` | ![image](https://user-images.githubusercontent.com/20955511/183303719-dc5ad223-cdd6-4830-9ffb-0ae965ec0159.png) |
| `neon-dark` | ![image](https://user-images.githubusercontent.com/20955511/183303718-8b043f5f-8d87-4370-ac42-38032e230d6e.png) |
| `neon-palenight` | ![image](https://user-images.githubusercontent.com/20955511/183303716-bf924275-320f-44b6-8ad7-6a5f786ee9e6.png) |
| `dark-smoky` | ![image](https://user-images.githubusercontent.com/20955511/183303715-baad8600-943a-4ad6-85d9-f7c2a46eab41.png) |
| `monokai-metallian` | ![image](https://user-images.githubusercontent.com/20955511/183303713-2bf8ee11-a251-4d39-8aa5-ed1fd4c545ce.png) |
| `city-lights` | ![image](https://user-images.githubusercontent.com/20955511/183303712-c9aa7429-eece-4d03-8c10-fbf28c77d495.png) |
| `blux` | ![image](https://user-images.githubusercontent.com/20955511/183303711-ed60bb0e-9392-468b-a344-22debb20613a.png) |
| `earth` | ![image](https://user-images.githubusercontent.com/20955511/183303710-b3c336ad-df6d-4529-aa95-6808bfe907dc.png) |
| `deepBlue` | ![image](https://user-images.githubusercontent.com/20955511/183303709-823b626b-d9c6-4e12-a146-e641a0345a2f.png) |
| `deepblue` | ![image](https://user-images.githubusercontent.com/20955511/183303709-823b626b-d9c6-4e12-a146-e641a0345a2f.png) |
| `holi-theme` | ![image](https://user-images.githubusercontent.com/20955511/183303708-83f5f757-5692-4e24-8e66-daaa8bca6b5b.png) |
| `ayu-light` | ![image](https://user-images.githubusercontent.com/20955511/183303707-fb381b09-9963-48c8-90b9-f6b5bc67c85a.png) |
| `javascript` | ![image](https://user-images.githubusercontent.com/20955511/183303706-4b4e34ef-6d43-4255-9a58-1d35c3127ff7.png) |
Expand All @@ -84,7 +84,7 @@ You can also try out and customize these themes on the [Demo Site](https://strea
| `garden` | ![image](https://user-images.githubusercontent.com/20955511/183303692-ea99a78d-be75-43fa-80ca-83f3ae454a35.png) |
| `github-green-purple` | ![image](https://user-images.githubusercontent.com/20955511/183303691-278ec85a-197d-4a6b-abf3-593e4cc8492b.png) |
| `icegray` | ![image](https://user-images.githubusercontent.com/20955511/183303690-7d798870-dd80-4d71-b5c2-775cc3555e14.png) |
| `neon_blurange` | ![image](https://user-images.githubusercontent.com/20955511/183303688-7a4ceb50-84e8-47ca-8cf0-14f212227ce6.png) |
| `neon-blurange` | ![image](https://user-images.githubusercontent.com/20955511/183303688-7a4ceb50-84e8-47ca-8cf0-14f212227ce6.png) |
| `yellowdark` | ![image](https://user-images.githubusercontent.com/20955511/183303687-49da2ffe-5fc9-4a0b-9ca9-c46bc394ec03.png) |
| `java-dark` | ![image](https://user-images.githubusercontent.com/20955511/183303686-a652b2fb-daae-4390-b245-71610aa54ef7.png) |
| `android-dark` | ![image](https://user-images.githubusercontent.com/20955511/183303685-fed30ead-2660-48bc-b724-04fe3c394c7f.png) |
Expand All @@ -103,23 +103,21 @@ You can also try out and customize these themes on the [Demo Site](https://strea
| `violet-punch` | ![image](https://user-images.githubusercontent.com/20955511/199313653-d678d969-facd-4f8d-b36e-2d0ee2ce61a5.png) |
| `submarine-flowers` | ![image](https://user-images.githubusercontent.com/20955511/201519290-14d69c90-ce17-4c63-9020-7b244ebc6fab.png) |
| `rising-sun` | ![image](https://user-images.githubusercontent.com/20955511/221126697-2c47639d-23c5-4c23-b545-d883063deebf.png) |
| `gruvbox_light` | ![image](https://user-images.githubusercontent.com/20955511/221585454-f9474df6-bbf4-4e3a-91e4-5e9e090e90c0.png) |
| `gruvbox-light` | ![image](https://user-images.githubusercontent.com/20955511/221585454-f9474df6-bbf4-4e3a-91e4-5e9e090e90c0.png) |
| `outrun` | ![image](https://user-images.githubusercontent.com/20955511/221585435-d39df945-6387-4e3e-abdf-0af7dd0dabef.png) |
| `ocean_dark` | ![image](https://user-images.githubusercontent.com/20955511/221585476-3eb2d25c-346b-4562-808e-bf09a59b17cd.png) |
| `city_lights` | ![image](https://user-images.githubusercontent.com/20955511/221585508-80d934de-ef46-4c12-9ff4-27c4a6d16846.png) |
| `discord_old_blurple` | ![image](https://user-images.githubusercontent.com/20955511/221585526-e191cb4c-9957-4ec9-85ec-8916ac691b40.png) |
| `aura_dark` | ![image](https://user-images.githubusercontent.com/20955511/221585541-88c2a657-dbe7-47a2-b6f9-9e3cdf1fbbfe.png) |
| `ocean-dark` | ![image](https://user-images.githubusercontent.com/20955511/221585476-3eb2d25c-346b-4562-808e-bf09a59b17cd.png) |
| `discord-old-blurple` | ![image](https://user-images.githubusercontent.com/20955511/221585526-e191cb4c-9957-4ec9-85ec-8916ac691b40.png) |
| `aura-dark` | ![image](https://user-images.githubusercontent.com/20955511/221585541-88c2a657-dbe7-47a2-b6f9-9e3cdf1fbbfe.png) |
| `panda` | ![image](https://user-images.githubusercontent.com/20955511/221585562-1f7edc63-41c7-43c6-ac33-fd0ecb32ec5f.png) |
| `noctis_minimus` | ![image](https://user-images.githubusercontent.com/20955511/221585589-e53f7e7b-fe26-4174-aab5-bda45a6e95a2.png) |
| `cobalt2` | ![image](https://user-images.githubusercontent.com/20955511/221585614-256d590d-9c45-43a8-be15-48231e418bf2.png) |
| `swift` | ![image](https://user-images.githubusercontent.com/20955511/221585640-666641b9-cc29-435c-948f-f50e58a6b330.png) |
| `aura` | ![image](https://user-images.githubusercontent.com/20955511/221585659-f4e8a547-7f98-4438-aba9-8f13ffbcc657.png) |
| `apprentice` | ![image](https://user-images.githubusercontent.com/20955511/221585690-155c5b01-988e-4e1c-a588-94edb0913800.png) |
| `moltack` | ![image](https://user-images.githubusercontent.com/20955511/221585716-9e9a9bb6-17cf-458d-826c-1d9a659cdcec.png) |
| `codeSTACKr` | ![image](https://user-images.githubusercontent.com/20955511/221585743-c836e303-9b9a-4caf-bd12-ef83bf39bf54.png) |
| `rose_pine` | ![image](https://user-images.githubusercontent.com/20955511/221585761-b7df70e8-b2c4-446a-a6fc-4fd13aa18117.png) |
| `date_night` | ![image](https://user-images.githubusercontent.com/20955511/221585779-db7f394d-b3c6-49e4-ad75-bbba97530765.png) |
| `one_dark_pro` | ![image](https://user-images.githubusercontent.com/20955511/221585805-1d10928a-286c-4945-95ed-a7317e56692f.png) |
| `codestackr` | ![image](https://user-images.githubusercontent.com/20955511/221585743-c836e303-9b9a-4caf-bd12-ef83bf39bf54.png) |
| `rose-pine` | ![image](https://user-images.githubusercontent.com/20955511/221585761-b7df70e8-b2c4-446a-a6fc-4fd13aa18117.png) |
| `date-night` | ![image](https://user-images.githubusercontent.com/20955511/221585779-db7f394d-b3c6-49e4-ad75-bbba97530765.png) |
| `one-dark-pro` | ![image](https://user-images.githubusercontent.com/20955511/221585805-1d10928a-286c-4945-95ed-a7317e56692f.png) |
| `rose` | ![image](https://user-images.githubusercontent.com/20955511/221585827-e566b73a-e0c0-4711-b48c-667e6500d44e.png) |

### Can't find the theme you like?
Expand Down
24 changes: 16 additions & 8 deletions src/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ function formatDate(string $dateString, string|null $format, string $locale): st
return htmlspecialchars($formatted);
}

/**
* Normalize a theme name
*
* @param string $theme Theme name
* @return string Normalized theme name
*/
function normalizeThemeName(string $theme): string
{
return strtolower(str_replace("_", "-", $theme));
}

/**
* Check theme and color customization parameters to generate a theme mapping
*
Expand All @@ -73,14 +84,11 @@ function getRequestedTheme(array $params): array
*/
$CSS_COLORS = include "colors.php";

// get theme colors
if (isset($params["theme"]) && array_key_exists($params["theme"], $THEMES)) {
$theme = $THEMES[$params["theme"]];
}
// no theme specified, get default
else {
$theme = $THEMES["default"];
}
// normalize theme name
$selectedTheme = normalizeThemeName($params["theme"] ?? "default");

// get theme colors, or default colors if theme not found
$theme = $THEMES[$selectedTheme] ?? $THEMES["default"];

// personal theme customizations
$properties = array_keys($theme);
Expand Down
Loading

0 comments on commit 5359b0e

Please sign in to comment.