Skip to content
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

feat(AlertLayout): render markdown content #93

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ashmortar
Copy link
Contributor

@ashmortar ashmortar commented Sep 10, 2024

Why

Alerts are unable to render markdown style content like links, simple code blocks or other elements that may be in use in our doc strings or would be helfpful for users (links to documentation).

  • adds react-markdown as a peer dependency v6 due to change to esm in v7
  • updates the styling of alert renderer to match alert styling in mercury
  • styles links with underline and inherit text color
  • replaces p tags with span for converted regular text

@ashmortar ashmortar force-pushed the f/lak-59/render-markdown-in-alerts branch from 424b8c9 to 1728aed Compare September 10, 2024 21:08
Copy link

codecov bot commented Sep 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.04%. Comparing base (77af92c) to head (22df851).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #93      +/-   ##
==========================================
+ Coverage   74.85%   75.04%   +0.19%     
==========================================
  Files          38       38              
  Lines         505      509       +4     
  Branches       96       97       +1     
==========================================
+ Hits          378      382       +4     
  Misses         90       90              
  Partials       37       37              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ashmortar ashmortar force-pushed the f/lak-59/render-markdown-in-alerts branch from 1728aed to b056797 Compare September 10, 2024 21:30
Copy link
Contributor

@NathanFarmer NathanFarmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to add a basic storybook story here so people know this is possible?

Also you will want to change your PR title to adhere to conventional commit syntax so it auto-releases a new version of the library.

package.json Outdated Show resolved Hide resolved
@ashmortar ashmortar force-pushed the f/lak-59/render-markdown-in-alerts branch from b056797 to db950ae Compare September 10, 2024 21:47
@ashmortar ashmortar changed the title use react-markdown in alerts to render markdown content as html feat(AlertLayout): render markdown content Sep 10, 2024
@ashmortar ashmortar force-pushed the f/lak-59/render-markdown-in-alerts branch from db950ae to 4293c34 Compare September 17, 2024 17:24
junit.xml Outdated Show resolved Hide resolved
ashmortar and others added 4 commits September 18, 2024 12:06
* use react-markdown in alerts to render markdown content as html

* try changing module resolution and module settings to fix compat issue in react-markdown

---------

Co-authored-by: Aaron Ross <[email protected]>
Co-authored-by: Aaron Ross <[email protected]>
@ashmortar ashmortar force-pushed the f/lak-59/render-markdown-in-alerts branch 2 times, most recently from a98807c to 699d0ba Compare September 18, 2024 19:11
@ashmortar ashmortar requested a review from DrewHoo September 18, 2024 19:11
@ashmortar ashmortar force-pushed the f/lak-59/render-markdown-in-alerts branch from 699d0ba to 22df851 Compare September 18, 2024 19:12

export function AlertLayout({ text, uischema }: LabelProps & RendererProps) {
const options = uischema.options as AlertLayoutOptions
const options = (uischema?.options ?? { style: {} }) as AlertLayoutOptions
Copy link
Contributor

@DrewHoo DrewHoo Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'd make this more runtime safe if you were to cast uischema instead:
const options = (uischema as LabelLayoutUISchema<unknown>).options

ie if AlertLayoutOptions gets a required property, the current cast would still steamroll it, allowing the code to later do something like

options.newRequiredProperty.OopsThisWillBeATypeError

@@ -98,3 +98,46 @@ export const Success: Story = {
} satisfies UISchema<typeof schema>,
},
}

export const Mardown: Story = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

style={{ marginBottom: "24px" }}
type={options?.type}
message={text}
showIcon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change--you could add it to AlertLayoutOptions's pick of AlertProps if you want it to be configurable

return (
<Alert
style={{ marginBottom: "24px" }}
type={options?.type}
message={text}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the effect of using message vs description here? would this be a breaking change?

@NathanFarmer NathanFarmer removed their request for review December 2, 2024 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants