Skip to content

Conversation

dctalbot
Copy link
Contributor

@dctalbot dctalbot commented Mar 1, 2021

  • Identified the issue which this PR solves.
  • Read the CONTRIBUTING document.
  • Code builds clean without any errors or warnings.
  • Added appropriate tests for any new functionality.
  • All new and existing tests passed.
  • Added comments in the code, where necessary.
  • Ran make check to catch common errors. Fixed any that came up.

Description:
This PR removes and refactors the css for the markdown component. Converting those styles to be "CSS in JS", we scope that css to the component which will prevent it from being left behind if and when we remove the in-app documentation.

Describe any introduced user-facing changes:
Markdown text elements will have less vertical space between each other

Note
This PR previously contained changes to the bundling configuration. In order to limit scope, those changes were reverted.

@dctalbot dctalbot marked this pull request as ready for review March 1, 2021 22:46
@dctalbot dctalbot mentioned this pull request Mar 2, 2021
7 tasks
@Forfold Forfold assigned Forfold and unassigned Forfold Mar 3, 2021
@pnengchu pnengchu requested a review from m17ch March 8, 2021 16:57
m17ch
m17ch previously approved these changes Mar 10, 2021
Copy link
Contributor

@m17ch m17ch left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@Forfold Forfold left a comment

Choose a reason for hiding this comment

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

Comparing with dev, it looks like we're losing some styling on the code snippets. I verified that headers are rendering properly. Tables look weird, but they look weird in Prod/Dev too so that can be a separate issue w/ an isolated fix. Can we avoid using this CSS altogether in favor of something more maintainable?

Dev as of today:
Screen Shot 2021-03-12 at 10 51 42 AM

PR Screenshot:
Screen Shot 2021-03-12 at 10 51 52 AM

@dctalbot
Copy link
Contributor Author

Ah good catch, I didn't think to look there. I wonder what's getting in the way there 🤔. This looks like the most promising alternative: https://github.com/react-syntax-highlighter/react-syntax-highlighter

@dctalbot
Copy link
Contributor Author

@Forfold after reviewing, I don't think that library suits our needs. I'm quite happy with this as is, but let me know if you have any other suggestions

@dctalbot dctalbot requested review from Forfold and m17ch March 15, 2021 15:03
Comment on lines 9 to 35
'& h1, h2, h3, h4, h5, h6, p': {
marginTop: 0,
marginBottom: '0.5rem',
},
'& hr': {
margin: '1.5rem 0',
},
'& th': {
textAlign: 'left',
paddingRight: '8px',
},
'& td': {
paddingRight: '8px',
},
'& pre': {
display: 'block',
padding: '9.5px',
margin: '0 0 10px',
fontSize: '13px',
lineHeight: '1.42857143',
color: '#333',
wordBreak: 'break-all',
wordWrap: 'break-word',
backgroundColor: '#f5f5f5',
border: '1px solid #ccc',
borderRadius: '4px',
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Everything is rendering as expected now, though imho I think we should be using the defaults from this library instead of this here and just focus on getting the code block elements rendered with the proper colors. To be blunt, I'm not really in favor of maintaining things like lineHeight: '1.42857143' if we can avoid it

Copy link
Contributor

Choose a reason for hiding this comment

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

Doing some functional testing to see the differences, outside of the code elements I'm only seeing the CSS here compact the lines together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm guessing that lineheight was ripped from some computed source a while back along with the fontsize and padding, maybe others. Probably best to open an issue for touching up all markdown styles so we don't bikeshed on this too much

Copy link
Contributor

Choose a reason for hiding this comment

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

Since this PR is for removing the dead CSS but also refactoring, I'd be fine with making those changes here. We should be able to do away with everything except the color bits for pre/code and be in a good state. I went ahead and double-checked what we'll need to keep (also adjusting one px value to rem). Will comment with the commit suggestion

Copy link
Contributor

Choose a reason for hiding this comment

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

I did some further digging, and this code is a remnant from when we were using a completely different markdown library altogether (way back at the beginning of 2018)- so I definitely think we're good here to remove

Comment on lines 8 to 51
markdown: {
'& h1, h2, h3, h4, h5, h6, p': {
marginTop: 0,
marginBottom: '0.5rem',
},
'& hr': {
margin: '1.5rem 0',
},
'& th': {
textAlign: 'left',
paddingRight: '8px',
},
'& td': {
paddingRight: '8px',
},
'& pre': {
display: 'block',
padding: '9.5px',
margin: '0 0 10px',
fontSize: '13px',
lineHeight: '1.42857143',
color: '#333',
wordBreak: 'break-all',
wordWrap: 'break-word',
backgroundColor: '#f5f5f5',
border: '1px solid #ccc',
borderRadius: '4px',
},
'& code': {
padding: '2px 4px',
fontSize: '90%',
color: '#c7254e',
backgroundColor: '#f9f2f4',
borderRadius: '4px',
},
'& pre code': {
padding: 0,
fontSize: 'inherit',
color: 'inherit',
whiteSpace: 'pre-wrap',
backgroundColor: 'inherit',
borderRadius: 0,
},
},
Copy link
Contributor

@Forfold Forfold Mar 15, 2021

Choose a reason for hiding this comment

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

Suggested change
markdown: {
'& h1, h2, h3, h4, h5, h6, p': {
marginTop: 0,
marginBottom: '0.5rem',
},
'& hr': {
margin: '1.5rem 0',
},
'& th': {
textAlign: 'left',
paddingRight: '8px',
},
'& td': {
paddingRight: '8px',
},
'& pre': {
display: 'block',
padding: '9.5px',
margin: '0 0 10px',
fontSize: '13px',
lineHeight: '1.42857143',
color: '#333',
wordBreak: 'break-all',
wordWrap: 'break-word',
backgroundColor: '#f5f5f5',
border: '1px solid #ccc',
borderRadius: '4px',
},
'& code': {
padding: '2px 4px',
fontSize: '90%',
color: '#c7254e',
backgroundColor: '#f9f2f4',
borderRadius: '4px',
},
'& pre code': {
padding: 0,
fontSize: 'inherit',
color: 'inherit',
whiteSpace: 'pre-wrap',
backgroundColor: 'inherit',
borderRadius: 0,
},
},
markdown: {
'& pre': {
padding: '0.375rem',
color: '#333',
backgroundColor: '#f5f5f5',
border: '1px solid #ccc',
borderRadius: '4px',
},
'& code': {
color: '#c7254e',
backgroundColor: '#f9f2f4',
},
'& pre code': {
color: 'inherit',
whiteSpace: 'pre-wrap',
backgroundColor: 'inherit',
},
},

@dctalbot
Copy link
Contributor Author

@Forfold I realized the weird line heights were coming from the <Typography> subtitle variant, so I switched that to the default body type. Stripped out a bunch of css, and also added table styles while we're at it. Ended up keeping some of the inline code styles since I felt the UX was cheapened w/o it. Lmk what you think!

@dctalbot dctalbot requested a review from Forfold March 16, 2021 14:56
m17ch
m17ch previously approved these changes Mar 30, 2021
Copy link
Contributor

@Forfold Forfold left a comment

Choose a reason for hiding this comment

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

It appears that none of the css defined in Markdown.js gets applied within AlertDetails

@dctalbot dctalbot requested review from Forfold and m17ch April 5, 2021 16:46
Copy link
Contributor

@Forfold Forfold left a comment

Choose a reason for hiding this comment

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

lgtm!

@dctalbot dctalbot merged commit 59d9ff6 into master Apr 5, 2021
@dctalbot dctalbot deleted the css-fixes branch April 5, 2021 18:32
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