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

Innovation week: Updated tutorial experience #855

Merged
merged 134 commits into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
ded7ed2
chore: add helpers for determining if element is a code block
jerelmiller Oct 14, 2020
211d8c9
chore: add warning package
jerelmiller Oct 14, 2020
5d0fdc6
feat: Add a Tutorial component that will flip between files and their…
jerelmiller Oct 14, 2020
1095bd1
feat: add ability to specify project. Update MDX to use code
jerelmiller Oct 14, 2020
ed33c14
chore: more robust handling of finding previous step
jerelmiller Oct 14, 2020
c484371
feat: highlight lines that are new
jerelmiller Oct 14, 2020
ed3444c
feat: handle proper diffing on each step
jerelmiller Oct 14, 2020
6499557
chore: add tutorial section
jerelmiller Oct 14, 2020
71992f2
chore: handle parsing code blocks inside sections
jerelmiller Oct 14, 2020
13df919
chore: update prop types on tutorial step
jerelmiller Oct 14, 2020
f96033c
feat: gather steps inside tutorial sections
jerelmiller Oct 14, 2020
ce1c9a2
chore: check if file name is present in project config
jerelmiller Oct 14, 2020
b29e34a
chore: update guide to use sections
jerelmiller Oct 14, 2020
2617b55
chore: update spacing on section/step elements
jerelmiller Oct 14, 2020
d86a8cd
chore: dont highlight empty lines when they start a change
jerelmiller Oct 14, 2020
14b24fd
chore: update tutorial to use correct code
jerelmiller Oct 14, 2020
9ac661c
chore: add validation on children
jerelmiller Oct 14, 2020
82334ac
chore: handle pure tutorial steps
jerelmiller Oct 14, 2020
9cc58b1
feat: create a Terminal component
jerelmiller Oct 14, 2020
ca27f28
feat: create custom code block that renders a terminal for shell lang…
jerelmiller Oct 14, 2020
08afb77
chore: move Terminal into subfolder
jerelmiller Oct 14, 2020
d71b44d
feat: add syntax highlighting to terminal commands
jerelmiller Oct 14, 2020
ecbf261
chore: create a cursor
jerelmiller Oct 14, 2020
1fa4ff4
chore: reorg some components in the terminal
jerelmiller Oct 15, 2020
c5241bb
chore: roll up lines into commands
jerelmiller Oct 15, 2020
0ed5a72
feat: add output coloring for each output line
jerelmiller Oct 15, 2020
abd2666
chore: handle blank output lines
jerelmiller Oct 15, 2020
4ed4867
fix: only copy non-output lines
jerelmiller Oct 15, 2020
180b456
chore: remove empty lines
jerelmiller Oct 15, 2020
6965354
chore: use implicit return
jerelmiller Oct 15, 2020
9482d11
refactor: move syntax highlighter inline
jerelmiller Oct 15, 2020
1b1fa11
refactor: aggregate command into own component
jerelmiller Oct 15, 2020
87c92e4
refactor: move shell ui into shell component
jerelmiller Oct 15, 2020
3782543
feat: show cursor on terminal prompts
jerelmiller Oct 15, 2020
87c406f
chore: install react-typist
jerelmiller Oct 15, 2020
67e1243
chore: show staggered output and commands
jerelmiller Oct 15, 2020
9261284
chore: add ability to turn off animations
jerelmiller Oct 15, 2020
2ac0849
chore: install patch-package
jerelmiller Oct 15, 2020
1c45144
chore: add patch to allow custom cursor
jerelmiller Oct 15, 2020
5ff7d9d
chore: add support for hiding cursor when done
jerelmiller Oct 15, 2020
64fc3df
chore: partway there for typed commands
jerelmiller Oct 15, 2020
832ea67
chore: only show output when finished typing
jerelmiller Oct 15, 2020
06aeed5
chore: fix done early. dont type when not animating
jerelmiller Oct 15, 2020
0d248f9
chore: refactor to use xstate to simplify state logic
jerelmiller Oct 15, 2020
5d66db4
chore: better typing delay for commands that aren't the first
jerelmiller Oct 15, 2020
458ca8a
feat: animate output for nerdpack create command
jerelmiller Oct 15, 2020
bb859ef
chore: augmented output timing. handle static terminal output
jerelmiller Oct 15, 2020
645920c
chore: add output for nerdpack serve command
jerelmiller Oct 15, 2020
29452de
chore: measure height of the shell before animating it
jerelmiller Oct 15, 2020
14926a3
chore: better cursor sizing to avoid lines from resizing
jerelmiller Oct 15, 2020
90d315a
chore: ensure cursor is shown on empty state
jerelmiller Oct 15, 2020
83a2a7b
chore: dont show cursor for non-animated terminals
jerelmiller Oct 15, 2020
8a767a7
chore: tokenize in shell output component
jerelmiller Oct 15, 2020
e13c8fe
feat: start animation when user scrolls the terminal into view
jerelmiller Oct 15, 2020
d0d5e44
chore: allow text to wrap
jerelmiller Oct 15, 2020
cb9db73
chore: create tutorial editor in tutorial instead of step component
jerelmiller Oct 15, 2020
1d52bca
refactor: update props that are received by the tutorial editor
jerelmiller Oct 15, 2020
34584b5
refactor: rename functions for clarity
jerelmiller Oct 15, 2020
a2adbbc
chore: get project config from all code blocks with file names
jerelmiller Oct 15, 2020
da4a75b
chore: remove warnings about missing file name and language
jerelmiller Oct 15, 2020
3291690
chore: move helper inline
jerelmiller Oct 15, 2020
2d25989
chore: remove warning about code block
jerelmiller Oct 15, 2020
2fa5b9e
chore: remove unneeded helpers
jerelmiller Oct 15, 2020
8ccd284
chore: pass parent when visiting
jerelmiller Oct 15, 2020
3beeeb8
refactor: replace deeply nested code blocks with tutorial editor
jerelmiller Oct 16, 2020
74b219e
refactor: move children utils to own file
jerelmiller Oct 16, 2020
ee58f46
fix: add back step counter within a tutorial section
jerelmiller Oct 16, 2020
c94fdec
fix: upgrade gatsby theme newrelic
jerelmiller Oct 16, 2020
5cba805
chore: rename function for clarity
jerelmiller Oct 16, 2020
e3e455e
chore: parse title from children instead of prop
jerelmiller Oct 16, 2020
afecfbb
chore: support light mode for the tutorial editor
jerelmiller Oct 16, 2020
49c9370
chore: use cloneElement on title
jerelmiller Oct 16, 2020
9503d72
chore: execute timeout immediately if the next line is empty
jerelmiller Oct 16, 2020
b88294a
chore: add a bottom dividier line on the last step
jerelmiller Oct 16, 2020
fc12370
chore: handle blank line differently
jerelmiller Oct 16, 2020
87e359a
chore: keep single child if there is an only child
jerelmiller Oct 16, 2020
611cc08
chore: add mdxType to tutorial editor
jerelmiller Oct 16, 2020
99d5433
chore: add spacing on tutorial editors
jerelmiller Oct 16, 2020
485f7fb
chore: rename function for clarity
jerelmiller Oct 16, 2020
ea59e64
chore: slight style update on step counter
jerelmiller Oct 16, 2020
044aad2
chore: update some styles for better spacing
jerelmiller Oct 16, 2020
2c4b971
chore: remove spacing for now
jerelmiller Oct 16, 2020
039b040
chore: remove top margin from lists
jerelmiller Oct 16, 2020
271969b
chore: show code blocks in right column
jerelmiller Oct 16, 2020
076b99a
chore: only associate previous element with code block
jerelmiller Oct 16, 2020
f46abd2
refactor: minor cleanup
jerelmiller Oct 16, 2020
d972366
chore: move helpers to bottom
jerelmiller Oct 16, 2020
f98ac49
chore: slight change in spacing
jerelmiller Oct 16, 2020
995d275
chore: add mobile breakpoint for tutorial step
jerelmiller Oct 16, 2020
963ad86
docs: move first step back into tutorial
jerelmiller Oct 16, 2020
1cbdb96
refactor: move children up
jerelmiller Oct 16, 2020
cea9ba4
chore: move typist up to command line
jerelmiller Oct 16, 2020
5420527
chore: fix empty line size
jerelmiller Oct 16, 2020
acf31bb
refactor: use xstate to determine shell state
jerelmiller Oct 16, 2020
4c067fa
chore: reduce typing delay for first command
jerelmiller Oct 16, 2020
b2479aa
chore: update guide to match prod
jerelmiller Oct 16, 2020
084bbdd
chore: add copy icon to copy button on terminal
jerelmiller Oct 16, 2020
4bf65fc
chore: tweak cursor speak and scroll point
jerelmiller Oct 16, 2020
582b6d8
chore: Steps/Step use tutorial components
jerelmiller Oct 16, 2020
9ca5120
chore: tell amplify to use node 12
jerelmiller Oct 16, 2020
ded3b3b
chore: comment out unused components
jerelmiller Oct 16, 2020
d6dc82f
chore: specify node 12
jerelmiller Oct 16, 2020
6eeff3f
Merge remote-tracking branch 'origin/develop' into jerel/apple-style-…
jerelmiller Oct 16, 2020
284b09e
chore: dont wrap terminal commands
jerelmiller Oct 19, 2020
47eae17
fix: upgrade @xstate/react
jerelmiller Oct 20, 2020
fd2460c
chore: allow several heading levels on tutorial step
jerelmiller Oct 20, 2020
51bd189
chore: remove commented import of step(s) components
jerelmiller Oct 20, 2020
470cae9
chore: remove step(s) components
jerelmiller Oct 20, 2020
384ec34
chore: use old naming on map pageviews by region
jerelmiller Oct 20, 2020
e23f339
chore: extract AnimatedCommand to own file
jerelmiller Oct 20, 2020
d2825a4
chore: extract StaticCommand to own file
jerelmiller Oct 20, 2020
7c01bb5
chore: remove unneeded comment
jerelmiller Oct 20, 2020
24d733f
chore: fix file path of StaticCommand
jerelmiller Oct 20, 2020
43bc6df
refactor: flatten lines and create new machine
jerelmiller Oct 21, 2020
7b4354f
chore: handle timeouts between shell output
jerelmiller Oct 21, 2020
0fb051d
chore: smaller timeout on output
jerelmiller Oct 21, 2020
c677638
chore: move timeout logic into spawned actor
jerelmiller Oct 21, 2020
6fbca75
chore: fix prompt. Better typing delay between commands. Fix multiple…
jerelmiller Oct 21, 2020
98eafe4
chore: smaller timeout on output
jerelmiller Oct 21, 2020
9eeaa3a
chore: get rid of old command components
jerelmiller Oct 21, 2020
4bcc012
refactor: extract menu bar into own component
jerelmiller Oct 21, 2020
ff738fc
chore: move most of the UI into the shell component
jerelmiller Oct 21, 2020
6056109
chore: add back copy button
jerelmiller Oct 21, 2020
d9c594e
chore: allow terminal to be configured as copyable
jerelmiller Oct 21, 2020
519bd5c
chore: filter out comments from copyable output
jerelmiller Oct 21, 2020
f6fe48e
chore: update comment
jerelmiller Oct 21, 2020
05d2c83
chore: remove frame button from the terminal component
jerelmiller Oct 21, 2020
ee8c5ea
chore: rename guard to test
jerelmiller Oct 21, 2020
ce4618b
chore: add the ability to wrap the terminal commands
jerelmiller Oct 21, 2020
cfedf24
Merge remote-tracking branch 'origin/develop' into jerel/apple-style-…
jerelmiller Oct 21, 2020
91f6a75
Revert "chore: add the ability to wrap the terminal commands"
jerelmiller Oct 21, 2020
231cfd3
Merge branch 'develop' into jerel/apple-style-tutorial
jerelmiller Oct 22, 2020
142dda9
fix: upgrade gatsby-theme-newrelic
jerelmiller Oct 23, 2020
a4f2d70
Merge branch 'develop' into jerel/apple-style-tutorial
jerelmiller Oct 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
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 not a huge fan of the new names. Would love to get some help on naming these components. We've received feedback that Steps and Step are too similar and hard to follow. The old names are aliased above, but I'd love to figure out a better name for this component.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have been really thinking about this and I still do not know what you could rename it to. I am terrible with names.

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
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 awesome

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