Skip to content

Commit

Permalink
Merge pull request #855 from newrelic/jerel/apple-style-tutorial
Browse files Browse the repository at this point in the history
Innovation week: Updated tutorial experience
  • Loading branch information
jerelmiller authored Oct 23, 2020
2 parents ead1eca + a4f2d70 commit 7ed88ae
Show file tree
Hide file tree
Showing 31 changed files with 2,329 additions and 1,709 deletions.
10 changes: 6 additions & 4 deletions amplify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ frontend:
phases:
preBuild:
commands:
- nvm use $VERSION_NODE_12
- npm ci
build:
commands:
- nvm use $VERSION_NODE_12
- |
if [ "${AWS_BRANCH}" = "main" ]; then
npm run build:production;
else
npm run build:staging;
if [ "${AWS_BRANCH}" = "main" ]; then
npm run build:production;
else
npm run build:staging;
fi
artifacts:
baseDirectory: public
Expand Down
1,761 changes: 262 additions & 1,499 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
"@emotion/styled": "^10.0.27",
"@mdx-js/mdx": "^1.6.17",
"@mdx-js/react": "^1.6.18",
"@newrelic/gatsby-theme-newrelic": "^1.9.5",
"@newrelic/gatsby-theme-newrelic": "^1.10.3",
"@splitsoftware/splitio-react": "^1.2.0",
"@xstate/react": "^1.0.0-rc.6",
"@xstate/react": "^1.0.1",
"classnames": "^2.2.6",
"date-fns": "^2.16.1",
"diff": "^4.0.2",
"eslint-plugin-react-hooks": "^4.1.2",
"gatsby": "^2.24.2",
"gatsby-image": "^2.4.14",
Expand Down Expand Up @@ -50,9 +51,12 @@
"react-middle-ellipsis": "^1.1.0",
"react-shadow": "^18.4.2",
"react-simple-code-editor": "^0.11.0",
"react-typist": "^2.0.5",
"react-use": "^15.3.4",
"snyk": "^1.405.1",
"use-dark-mode": "^2.3.1",
"use-media": "^1.4.0",
"snyk": "^1.405.1",
"warning": "^4.0.3",
"xstate": "^4.13.0"
},
"devDependencies": {
Expand All @@ -70,6 +74,7 @@
"identity-obj-proxy": "^3.0.0",
"jest": "^26.0.1",
"jest-emotion": "^10.0.32",
"patch-package": "^6.2.2",
"prettier": "2.0.4",
"react-test-renderer": "^16.13.1"
},
Expand All @@ -92,7 +97,8 @@
"test": "jest",
"test:watch": "npm test -- --watch",
"snyk-protect": "snyk protect",
"prepare": "npm run snyk-protect"
"prepare": "npm run snyk-protect",
"postinstall": "patch-package"
},
"husky": {
"hooks": {
Expand Down
26 changes: 26 additions & 0 deletions src/@newrelic/gatsby-theme-newrelic/components/CodeBlock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import CodeBlock from '@newrelic/gatsby-theme-newrelic/src/components/CodeBlock';
import Terminal from '../../../components/Terminal';
import { isShellLanguage } from '../../../utils/codeBlock';

const CustomCodeBlock = ({
language,
children,
animate,
copyable,
...props
}) => {
return isShellLanguage(language) ? (
<Terminal animate={animate} copyable={copyable}>
{children}
</Terminal>
) : (
<CodeBlock language={language} copyable={copyable} {...props}>
{children}
</CodeBlock>
);
};

CustomCodeBlock.propTypes = CodeBlock.propTypes;

export default CustomCodeBlock;
16 changes: 12 additions & 4 deletions src/components/MDXContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,29 @@ import cx from 'classnames';
import { MDXRenderer } from 'gatsby-plugin-mdx';
import { MDXProvider } from '@mdx-js/react';

import Step from './Step';
import Steps from './Steps';
import Caution from './Caution';
import Important from './Important';
import Tip from './Tip';
import Intro from './Intro';
import Iframe from './Iframe';
import Tutorial from './Tutorial';
import TutorialStep from './TutorialStep';
import TutorialSection from './TutorialSection';
import Project from './Project';
import { MDXCodeBlock, Video } from '@newrelic/gatsby-theme-newrelic';

import styles from './MDXContainer.module.scss';

const components = {
Video,
Step,
Steps,
// Remove these when all step/steps components have been updated to the new
// name
Step: TutorialStep,
Steps: TutorialSection,
Project,
Tutorial,
TutorialStep,
TutorialSection,
Caution,
Important,
Tip,
Expand Down
27 changes: 23 additions & 4 deletions src/components/MDXContainer.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,28 @@
background: var(--tertiary-background-color);
}

p:last-child {
margin-bottom: 0;
p,
ol,
ul {
margin-bottom: 1.5rem;

&:last-child {
margin-bottom: 0;
}
}

ol,
ul {
margin-top: 0;
padding-left: 1rem;
}

h1,
h2,
h3 {
margin-bottom: 1rem;
}

h1,
h2 {
font-weight: bold;
Expand All @@ -30,8 +49,8 @@
font-weight: bold;
}

li {
margin-bottom: 1rem;
li:not(:last-child) {
margin-bottom: 0.75rem;
}

ul li ul {
Expand Down
6 changes: 6 additions & 0 deletions src/components/Project.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Does not render. Will be used by the `Tutorial` component
const Project = () => {
return null;
};

export default Project;
22 changes: 0 additions & 22 deletions src/components/Step.js

This file was deleted.

26 changes: 0 additions & 26 deletions src/components/Step.module.scss

This file was deleted.

19 changes: 0 additions & 19 deletions src/components/Steps.js

This file was deleted.

102 changes: 102 additions & 0 deletions src/components/Terminal/CommandLine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import React from 'react';
import PropTypes from 'prop-types';
import { css, keyframes } from '@emotion/core';
import Prompt from './Prompt';
import Typist from 'react-typist';

const blink = keyframes`
0%, 49% {
background: #c0c5ce;
}
50%, 100% {
background: none;
}
`;

const CommandLine = ({
animate,
avgTypingDelay,
cursor,
children,
prompt,
typingDelay,
onFinishedTyping,
}) => {
const element = animate ? (
<Typist
startDelay={typingDelay}
avgTypingDelay={avgTypingDelay}
cursor={{ show: false }}
onTypingDone={onFinishedTyping}
css={css`
&:empty {
display: inline-block;
}
`}
>
{children}
</Typist>
) : (
children
);

return (
<div
css={css`
display: grid;
grid-template-columns: 1ch auto;
grid-gap: 1ch;
justify-content: start;
align-items: baseline;
`}
>
<Prompt character={prompt} />
<div
css={css`
position: relative;
color: #fafafa;
white-space: pre;
&:empty {
height: 100%;
}
${cursor &&
css`
&:after {
content: '';
display: block;
width: 1ch;
height: 1.25em;
animation: ${blink} 1.25s infinite;
position: absolute;
top: 1px;
right: -1ch;
}
`};
`}
>
{element}
</div>
</div>
);
};

CommandLine.propTypes = {
animate: PropTypes.bool,
avgTypingDelay: PropTypes.number,
children: PropTypes.node,
cursor: PropTypes.bool,
prompt: PropTypes.oneOf(['$', '>']),
typingDelay: PropTypes.number,
onFinishedTyping: PropTypes.func,
};

CommandLine.defaultProps = {
animate: false,
avgTypingDelay: 40,
typingDelay: 0,
};

export default CommandLine;
Loading

0 comments on commit 7ed88ae

Please sign in to comment.