From 87c92e42b72d24946b53790fa15b235ea4e6d936 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Wed, 14 Oct 2020 23:13:23 -0700 Subject: [PATCH] refactor: move shell ui into shell component --- src/components/Terminal/Shell.js | 60 +++++++++++++++++++++++++++++ src/components/Terminal/Terminal.js | 52 ++----------------------- 2 files changed, 64 insertions(+), 48 deletions(-) create mode 100644 src/components/Terminal/Shell.js diff --git a/src/components/Terminal/Shell.js b/src/components/Terminal/Shell.js new file mode 100644 index 000000000..1f2e14864 --- /dev/null +++ b/src/components/Terminal/Shell.js @@ -0,0 +1,60 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { css } from '@emotion/core'; +import Command from './Command'; +import theme from './theme'; +import rollupIntoCommands from './rollupIntoCommands'; + +const Shell = ({ highlight, code }) => { + return ( +
 code {
+          background: none;
+          padding: 0;
+          width: 100%;
+        }
+
+        .token-line {
+          display: grid;
+          grid-template-columns: 1ch 1fr;
+          grid-gap: 1rem;
+        }
+      `}
+    >
+      
+        {rollupIntoCommands(highlight.tokens, code).map((command, idx) => (
+          
+        ))}
+      
+    
+ ); +}; + +Shell.propTypes = { + code: PropTypes.string.isRequired, + highlight: PropTypes.object, +}; + +export default Shell; diff --git a/src/components/Terminal/Terminal.js b/src/components/Terminal/Terminal.js index d33cb9bdd..9427dda62 100644 --- a/src/components/Terminal/Terminal.js +++ b/src/components/Terminal/Terminal.js @@ -4,9 +4,8 @@ import { css } from '@emotion/core'; import { Button, useClipboard } from '@newrelic/gatsby-theme-newrelic'; import Highlight from 'prism-react-renderer'; import Prism from 'prismjs'; -import Command from './Command'; +import Shell from './Shell'; import theme from './theme'; -import rollupIntoCommands from './rollupIntoCommands'; const Terminal = ({ children }) => { const code = children.trim(); @@ -61,52 +60,9 @@ const Terminal = ({ children }) => { {copied ? 'Copied' : 'Copy'} -
 code {
-            background: none;
-            padding: 0;
-            width: 100%;
-          }
-
-          .token-line {
-            display: grid;
-            grid-template-columns: 1ch 1fr;
-            grid-gap: 1rem;
-          }
-        `}
-      >
-        
-          
-            {({ tokens, getTokenProps }) =>
-              rollupIntoCommands(tokens, code).map((command, idx) => (
-                
-              ))
-            }
-          
-        
-      
+ + {(highlight) => } + ); };