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

Use LeafyGreen Code component #162

Merged
merged 14 commits into from
Mar 18, 2020
Merged

Conversation

tahiya-mongo
Copy link
Contributor

@tahiya-mongo tahiya-mongo commented Mar 13, 2020

Copy link
Member

@sophstad sophstad left a comment

Choose a reason for hiding this comment

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

Nice work! Please merge in Snooty's master branch in order to run our test suite on this PR. I also noticed a problem in the staging link. Code blocks are getting cut off! I think this is because the LeafyGreen component is set to display: inline-block.
image
To see the whole code block, the user must scroll the entire container over.
image
I think wrapping the component in a display: block container may fix this!

import ReactDOMServer from 'react-dom/server';
import PropTypes from 'prop-types';
import Highlight from 'react-highlight';
Copy link
Member

Choose a reason for hiding this comment

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

Since we're no longer using react-highlight, it can be removed from our dependencies in package.json.

import { isBrowser } from '../utils/is-browser';
import { useContext } from 'react';
Copy link
Member

Choose a reason for hiding this comment

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

[nit] You can import useContext on line 1:

import React, { useContext } from 'react';

import Highlight from 'react-highlight';
import { reportAnalytics } from '../utils/report-analytics';
import 'highlight.js/styles/a11y-light.css';
import codeStyle from '../styles/code.module.css';
Copy link
Member

@sophstad sophstad Mar 16, 2020

Choose a reason for hiding this comment

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

code.module.css can also be deleted since we're not using it anymore.

const doc = new DOMParser().parseFromString(input, 'text/html');
return doc.documentElement.textContent;
};
let supported_langs = [
Copy link
Member

@sophstad sophstad Mar 16, 2020

Choose a reason for hiding this comment

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

[nit] Let's call this const leafyGreenSupportedLangs to 1) adhere to JS camelCase conventions, 2) clarify exactly which entity supports these languages, and 3) use a const.

@tahiya-mongo tahiya-mongo merged commit e8af775 into mongodb:master Mar 18, 2020
graysonhicks pushed a commit that referenced this pull request Jan 20, 2023
* Use LeafyGreen Code component

* Removed unnecessary dependencies

* Enabled horizontsl scrolling of the codeblock

* Updated to include the new added copy button

* Use LeafyGreen Code component

* Removed unnecessary dependencies

* Enabled horizontsl scrolling of the codeblock

* Updated to include the new added copy button

* Updated code test snapshot

* Switched from mount() to shallow() in Code.test.js

* Removed src/styles/code.module.css

* Added TODO comment to Code.js

Co-authored-by: tahiya-mongo <tahiya.chowdhury@mongodb.com>
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.

2 participants