fix(insights): render acronym sources uppercase (AI, SNMP)
The CSS `capitalize` class only capitalises the first letter, so the source filter pills and per-card badges showed "Ai" and "Snmp". Switch to a `source_label/1` helper that returns "AI" / "SNMP" verbatim and falls back to `String.capitalize/1` for the rest (Preseem, Gaiia, System).
This commit is contained in:
parent
c545672efe
commit
d051968ae6
2 changed files with 15 additions and 4 deletions
|
|
@ -144,6 +144,17 @@ defmodule ToweropsWeb.InsightsLive.Index do
|
|||
def source_classes("system"), do: "bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"
|
||||
def source_classes(_), do: "bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"
|
||||
|
||||
@doc """
|
||||
Display label for a source. Acronyms render uppercase; everything else
|
||||
capitalises the first letter so the badge reads "Preseem" rather than
|
||||
"preseem". Picked over CSS `capitalize` because that produces "Snmp"
|
||||
and "Ai" instead of "SNMP" and "AI".
|
||||
"""
|
||||
def source_label("ai"), do: "AI"
|
||||
def source_label("snmp"), do: "SNMP"
|
||||
def source_label(other) when is_binary(other), do: String.capitalize(other)
|
||||
def source_label(other), do: other
|
||||
|
||||
@doc false
|
||||
def build_filter_params(base, overrides) do
|
||||
base
|
||||
|
|
|
|||
|
|
@ -75,14 +75,14 @@
|
|||
~p"/insights?#{build_filter_params(%{status: @filter_status, urgency: @filter_urgency}, %{source: source})}"
|
||||
}
|
||||
class={[
|
||||
"rounded-md px-2 py-1 text-xs font-medium capitalize",
|
||||
"rounded-md px-2 py-1 text-xs font-medium",
|
||||
if(@filter_source == source,
|
||||
do: "bg-gray-200 text-gray-800 dark:bg-white/20 dark:text-white",
|
||||
else: "text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-white/10"
|
||||
)
|
||||
]}
|
||||
>
|
||||
{source}
|
||||
{source_label(source)}
|
||||
</.link>
|
||||
</div>
|
||||
|
||||
|
|
@ -252,10 +252,10 @@
|
|||
|
||||
<%!-- Source badge --%>
|
||||
<span class={[
|
||||
"inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium capitalize",
|
||||
"inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium",
|
||||
source_classes(insight.source)
|
||||
]}>
|
||||
{insight.source}
|
||||
{source_label(insight.source)}
|
||||
</span>
|
||||
|
||||
<%!-- AI badge — present on any LLM-enriched insight --%>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue