feat: underline links in announcement banner for better visibility (#20166)

## Overview

Links in announcement banners are now underlined to make them visually
distinguishable without requiring users to hover over them.

Context:
[Slack](https://codercom.slack.com/archives/C0989BZU23T/p1759503061267819)

## Changes

- Added `text-decoration: underline` to links in the announcement banner
component

---------

Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: blink-so[bot] <157993532+blink-so[bot]@users.noreply.github.com>
Co-authored-by: Michael Smith <michaelsmith@coder.com>
This commit is contained in:
blink-so[bot]
2025-10-16 15:24:45 -04:00
committed by GitHub
co-authored by blink-so[bot] Michael Smith
parent 9f3b2cddb1
commit 5119db3cd2
3 changed files with 15 additions and 30 deletions
+3 -2
View File
@@ -83,6 +83,7 @@ test("set service banner", async ({ page }) => {
await page.goto("/workspaces", { waitUntil: "domcontentloaded" });
await expectUrl(page).toHavePathName("/workspaces");
const bar = page.locator("div.service-banner", { hasText: message });
await expect(bar).toBeVisible();
const banner = page.getByTestId("service-banner");
await expect(banner).toBeVisible();
await expect(banner).toHaveText(message);
});
@@ -1,29 +1,24 @@
import { css, type Interpolation, type Theme } from "@emotion/react";
import { InlineMarkdown } from "components/Markdown/Markdown";
import type { FC } from "react";
import { readableForegroundColor } from "utils/colors";
interface AnnouncementBannerViewProps {
message?: string;
backgroundColor?: string;
message: string;
backgroundColor: string;
}
export const AnnouncementBannerView: FC<AnnouncementBannerViewProps> = ({
message,
backgroundColor,
}) => {
if (!message || !backgroundColor) {
return null;
}
return (
<div
css={styles.banner}
className="p-3 flex items-center"
style={{ backgroundColor }}
className="service-banner"
data-test-id="service-banner"
>
<div
css={styles.wrapper}
className="mx-auto font-normal [&_a]:text-inherit [&_a]:underline"
style={{ color: readableForegroundColor(backgroundColor) }}
>
<InlineMarkdown>{message}</InlineMarkdown>
@@ -31,20 +26,3 @@ export const AnnouncementBannerView: FC<AnnouncementBannerViewProps> = ({
</div>
);
};
const styles = {
banner: css`
padding: 12px;
display: flex;
align-items: center;
`,
wrapper: css`
margin-right: auto;
margin-left: auto;
font-weight: 400;
& a {
color: inherit;
}
`,
} satisfies Record<string, Interpolation<Theme>>;
@@ -1,3 +1,4 @@
import type { BannerConfig } from "api/typesGenerated";
import { useDashboard } from "modules/dashboard/useDashboard";
import type { FC } from "react";
import { AnnouncementBannerView } from "./AnnouncementBannerView";
@@ -15,7 +16,12 @@ export const AnnouncementBanners: FC = () => {
return (
<>
{announcementBanners
.filter((banner) => banner.enabled)
.filter(
(banner): banner is Required<BannerConfig> =>
banner.enabled &&
Boolean(banner.message) &&
Boolean(banner.background_color),
)
.map((banner) => (
<AnnouncementBannerView
key={banner.message}