Feat: add new Markdown parser (#39800)

and change all the challenges to new `md` format.
This commit is contained in:
Oliver Eyton-Williams
2020-11-27 19:02:05 +01:00
committed by GitHub
parent a07f84c8ec
commit 0bd52f8bd1
2580 changed files with 113436 additions and 111979 deletions

View File

@@ -5,47 +5,79 @@ challengeType: 6
forumTopicId: 301378
---
## Description
<section id='description'>
You may have noticed in the last challenge that there were several other syntax differences from HTML inline styles in addition to the <code>style</code> attribute set to a JavaScript object. First, the names of certain CSS style properties use camel case. For example, the last challenge set the size of the font with <code>fontSize</code> instead of <code>font-size</code>. Hyphenated words like <code>font-size</code> are invalid syntax for JavaScript object properties, so React uses camel case. As a rule, any hyphenated style properties are written using camel case in JSX.
All property value length units (like <code>height</code>, <code>width</code>, and <code>fontSize</code>) are assumed to be in <code>px</code> unless otherwise specified. If you want to use <code>em</code>, for example, you wrap the value and the units in quotes, like <code>{fontSize: "4em"}</code>. Other than the length values that default to <code>px</code>, all other property values should be wrapped in quotes.
</section>
# --description--
## Instructions
<section id='instructions'>
If you have a large set of styles, you can assign a style <code>object</code> to a constant to keep your code organized. Initialize a <code>styles</code> constant and assign an <code>object</code> with three style properties and their values to it. Give the <code>div</code> a color of <code>"purple"</code>, a font-size of <code>40</code>, and a border of <code>"2px solid purple"</code>. Then set the <code>style</code> attribute equal to the <code>styles</code> constant.
</section>
You may have noticed in the last challenge that there were several other syntax differences from HTML inline styles in addition to the `style` attribute set to a JavaScript object. First, the names of certain CSS style properties use camel case. For example, the last challenge set the size of the font with `fontSize` instead of `font-size`. Hyphenated words like `font-size` are invalid syntax for JavaScript object properties, so React uses camel case. As a rule, any hyphenated style properties are written using camel case in JSX.
## Tests
<section id='tests'>
All property value length units (like `height`, `width`, and `fontSize`) are assumed to be in `px` unless otherwise specified. If you want to use `em`, for example, you wrap the value and the units in quotes, like `{fontSize: "4em"}`. Other than the length values that default to `px`, all other property values should be wrapped in quotes.
```yml
tests:
- text: The <code>styles</code> variable should be an <code>object</code> with three properties.
testString: assert(Object.keys(styles).length === 3);
- text: The <code>styles</code> variable should have a <code>color</code> property set to a value of <code>purple</code>.
testString: assert(styles.color === 'purple');
- text: The <code>styles</code> variable should have a <code>fontSize</code> property set to a value of <code>40</code>.
testString: assert(styles.fontSize === 40);
- text: The <code>styles</code> variable should have a <code>border</code> property set to a value of <code>2px solid purple</code>.
testString: assert(styles.border === "2px solid purple");
- text: The component should render a <code>div</code> element.
testString: assert((function() { const mockedComponent = Enzyme.shallow(React.createElement(Colorful)); return mockedComponent.type() === 'div'; })());
- text: The <code>div</code> element should have its styles defined by the <code>styles</code> object.
testString: assert((function() { const mockedComponent = Enzyme.shallow(React.createElement(Colorful)); return (mockedComponent.props().style.color === "purple" && mockedComponent.props().style.fontSize === 40 && mockedComponent.props().style.border === "2px solid purple"); })());
# --instructions--
If you have a large set of styles, you can assign a style `object` to a constant to keep your code organized. Initialize a `styles` constant and assign an `object` with three style properties and their values to it. Give the `div` a color of `"purple"`, a font-size of `40`, and a border of `"2px solid purple"`. Then set the `style` attribute equal to the `styles` constant.
# --hints--
The `styles` variable should be an `object` with three properties.
```js
assert(Object.keys(styles).length === 3);
```
</section>
The `styles` variable should have a `color` property set to a value of `purple`.
## Challenge Seed
<section id='challengeSeed'>
```js
assert(styles.color === 'purple');
```
<div id='jsx-seed'>
The `styles` variable should have a `fontSize` property set to a value of `40`.
```js
assert(styles.fontSize === 40);
```
The `styles` variable should have a `border` property set to a value of `2px solid purple`.
```js
assert(styles.border === '2px solid purple');
```
The component should render a `div` element.
```js
assert(
(function () {
const mockedComponent = Enzyme.shallow(React.createElement(Colorful));
return mockedComponent.type() === 'div';
})()
);
```
The `div` element should have its styles defined by the `styles` object.
```js
assert(
(function () {
const mockedComponent = Enzyme.shallow(React.createElement(Colorful));
return (
mockedComponent.props().style.color === 'purple' &&
mockedComponent.props().style.fontSize === 40 &&
mockedComponent.props().style.border === '2px solid purple'
);
})()
);
```
# --seed--
## --after-user-code--
```jsx
ReactDOM.render(<Colorful />, document.getElementById('root'))
```
## --seed-contents--
```jsx
// Change code above this line
class Colorful extends React.Component {
render() {
@@ -56,26 +88,9 @@ class Colorful extends React.Component {
// Change code above this line
}
};
```
</div>
### After Test
<div id='jsx-teardown'>
```jsx
ReactDOM.render(<Colorful />, document.getElementById('root'))
```
</div>
</section>
## Solution
<section id='solution'>
# --solutions--
```jsx
const styles = {
@@ -93,7 +108,4 @@ class Colorful extends React.Component {
// Change code above this line
}
};
```
</section>