Skip to content

refactor: improve markdown rendering on notifications #17112

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

Merged
merged 1 commit into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"@storybook/test": "8.4.6",
"@swc/core": "1.3.38",
"@swc/jest": "0.2.37",
"@tailwindcss/typography": "0.5.16",
"@testing-library/jest-dom": "6.6.3",
"@testing-library/react": "14.3.1",
"@testing-library/react-hooks": "8.0.1",
Expand Down
39 changes: 36 additions & 3 deletions site/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ export const Markdown: Story = {
notification: {
...MockNotification,
read_at: null,
content: "Hello **world**!",
content:
"Template **Write Coder on Coder with AI** has failed to build 1/33 times over the last week.\n\n**Report:**\n\n**sweet_cannon7** failed 1 time:\n\n* [edward / coder-on-coder-claude / #34](https://dev.coder.com/@edward/coder-on-coder-claude/builds/34)\n\nWe recommend reviewing these issues to ensure future builds are successful.",
actions: [
{
label: "View workspaces",
url: "https://dev.coder.com/workspaces?filter=template%3Acoder-with-ai",
},
],
},
},
};
Expand Down
17 changes: 10 additions & 7 deletions site/src/modules/notifications/NotificationsInbox/InboxItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { InboxNotification } from "api/typesGenerated";
import { Avatar } from "components/Avatar/Avatar";
import { Button } from "components/Button/Button";
import { Link } from "components/Link/Link";
import { SquareCheckBig } from "lucide-react";
import type { FC } from "react";
import Markdown from "react-markdown";
Expand Down Expand Up @@ -28,14 +29,16 @@ export const InboxItem: FC<InboxItemProps> = ({
</div>

<div className="flex flex-col gap-3 flex-1">
<span
className={cn([
"text-content-secondary text-sm font-medium whitespace-break-spaces [overflow-wrap:anywhere]",
"[&_p]:m-0",
])}
<Markdown
className="text-content-secondary prose-sm font-medium [overflow-wrap:anywhere]"
components={{
a: ({ node, ...props }) => {
return <Link {...props} />;
},
}}
>
<Markdown>{notification.content}</Markdown>
</span>
{notification.content}
</Markdown>
<div className="flex items-center gap-1">
{notification.actions.map((action) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion site/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ module.exports = {
},
},
},
plugins: [require("tailwindcss-animate")],
plugins: [require("tailwindcss-animate"), require("@tailwindcss/typography")],
};
Loading