Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Hello React!</title>
  </head>

  <body>
    <div id="root"></div>
  </body>
</html>
              
            
!

CSS

              
                #root {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #726a95;
  border-radius: 10px;
  align-self: center;
}

.stepNumberBar {
  min-width: 30vw;
  background: #f4ebc1;
  text-align: center;
  margin-top: 20px;
}

.explanation {
  text-align: left;
  background: #f4ebc1;
  width: 390px;
  margin: 10px 5px 0 5px;
  padding: 0 5px 0 5px;
  height: 60vh;
  font-family: Arial, Helvetica, sans-serif;
  border-radius: 10%;
}
h2 {
  text-align: center;
}

ul {
  list-style: circle;
}

button {
  background-color: #f6f4e6;
}

@import url(//fonts.googleapis.com/css?family=Pacifico);
span {
  font: 400 5vh "Pacifico";
  color: #fee;
  text-shadow: 0 0px 1px, 0 0 1em #fee;
  color:black;
}

span.active {
  color:grey;
  animation: flicker linear infinite 2s;
}

@keyframes flicker {
  75% {
    color: inherit;
    text-shadow: inherit;
  }
  76% {
    color: #222;
  }
  77% {
    color: inherit;
    text-shadow: none;
  }
  78% {
    color: inherit;
    text-shadow: inherit;
  }
  79% {
    color: #222;
    text-shadow: none;
  }
  80% {
    color: inherit;
    text-shadow: inherit;
  }
  90% {
    color: #222;
    text-shadow: none;
  }
  90.5% {
    color: inherit;
    text-shadow: inherit;
  }
}

              
            
!

JS

              
                function StepNumberBar({ total, current }) {
  return (
    <div className="stepNumberBar">
      {Array(total)
        .fill(null)
        .map((value, index) => (
          <span
            id={index}
            key={index}
            className={current === index ? "active" : "inactive"}
          >
            {index}
          </span>
        ))}
    </div>
  );
}

function KeyList({ content }) {
  var itemsArr = content.split(".");
  return (
    <ul>
      {itemsArr.map((item, index) => (
        <li key={index}>{item}</li>
      ))}
    </ul>
  );
}

function Explanation({ heading, content }) {
  return (
    <div className="explanation">
      <h2>{heading}</h2>
      <KeyList content={content} />
    </div>
  );
}
function NavigationRow({ updatePage }) {
  return (
    <div className="buttons">
      <MoveStepButton updatePage={updatePage} direction="prev" />
      <MoveStepButton updatePage={updatePage} direction="next" />
    </div>
  );
}

function MoveStepButton({ updatePage, direction }) {
  return direction === "prev" ? (
    <button onClick={() => updatePage((curr) => (curr === 0 ? 5 : curr - 1))}>
      PREV
    </button>
  ) : (
    <button onClick={() => updatePage((curr) => (curr === 5 ? 0 : curr + 1))}>
      NEXT
    </button>
  );
}

function ReferenceTable({ detail }) {
  const [currPage, updatePage] = React.useState(0);
  return (
    <>
      <StepNumberBar total={detail.length} current={currPage} />
      <Explanation
        heading={detail[currPage].heading}
        content={detail[currPage].content}
      />
      <NavigationRow updatePage={updatePage} />
    </>
  );
}

function App(props) {
  return <ReferenceTable detail={props.detail} />;
}

const data = [
  {
    heading: "Start With A Mock",
    content: "Front end in its plain form",
  },
  {
    heading: "Break The UI Into A Component Hierarchy",
    content:
      "Draw boxes.Identify components (Single Responsibility Principle).Arrange into hierarchy",
  },
  {
    heading: "Build A Static Version",
    content:
      "Don't use state at all, only use props.Reuse components.Top down/Bottom up to you.Pass sample\
      data to the top of the hierarchy",
  },
  {
    heading: "Identify The Minimal Representation of UI State",
    content:
      "Keep only the absolute minimal and compute everything else on-demand.Is it passed in from a parent via props?If so, it probably isn't state.\
      Does it remain unchanged over time? If so, it probably isn’t state.Can you compute it based on any other state or props in your component? If so, it isn’t state",
  },
  {
    heading: "Identify Where Your State Should Live",
    content:
      "Identify every component that renders something based on that state.Find a common owner component (above all other components).\
      Create a wrapper component above components if necessary",
  },
  {
    heading: "Add Inverse Data Flow",
    content:
      "Pass state changing callbacks from state owner to relevant child component",
  },
];

ReactDOM.render(
  <React.StrictMode>
    <App detail={data} />
  </React.StrictMode>,
  document.getElementById("root")
);
              
            
!
999px

Console