Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

Save Automatically?

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

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

CSS

              
                * {
  margin: 0;
  padding: 0;
}

*:focus {
 outline: 3px solid red;
}


// variables
$col-primary-text: #4c4c4c;
$col-link: #0088ff;
$col-border-separator: #cccccc;
$col-icon-grey: #929292;
$font-family-default: "Courier", sans-serif;
body {
  font-family: $font-family-default;
  color: $col-primary-text;
}

.tab-left-control {
    width: 220px;
    min-height: 100vh; // default 480px
    background: white;
    box-sizing: border-box;
    border-right: 1px solid $col-border-separator;
    overflow-y: scroll;
}

button.tab-control {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  text-align: left;
  font-family: $font-family-default;
}

.tab-control-child {
  font-size: 0.875rem;
  color: #919191;
  background: #f2f2f2;
}

.tab-control-parent {
  font-size: 1.3rem;
}

.tab-control {
    letter-spacing: 1px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
    padding-left: 1rem;
    box-sizing: border-box;
    cursor: pointer;

    &.selected {
        background: $col-link;
        color: white;
    } 
}

.tab-left-main {
    position: relative;
    display: flex;
}

.tab-left__content-wrapper {
    width: calc(100% - 220px);
    height: 100%;
}

.tab-content {
  width: 100%;
  min-height: 100vh;
  background: orange;
  padding: 1rem;
  box-sizing: border-box;
}

p.large {
  font-size: 6rem;
}
              
            
!

JS

              
                console.clear();

/**********************************/
// Main Tab
/**********************************/
class TabLeftMain extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      active: this.props.defaultActive
    };
    this.updateActive = this.updateActive.bind(this);
  }
  updateActive = id => {
    this.setState(
      {
        active: id
      },
      () => {
        // call back that can be triggered on Tab Change
        this.props.onSelectedTabChange(this.state.active);
      }
    );
  };
  getTabContentChildrenForRender = () => {
    return React.Children.toArray(this.props.children).find(
      child => child.props.id === this.state.active
    );
  };
  render() {
    const tabContentChildren = this.getTabContentChildrenForRender();
    return (
      <div className="tab-left-main">
        <TabLeftControl
          updateActive={this.updateActive}
          navData={this.props.navData}
          active={this.state.active}
          tabContentWrapperHeight={this.state.tabContentWrapperHeight}
        />
        <div
          className="tab-left__content-wrapper"
          ref={tabContentWrapperRef =>
            (this.tabContentWrapperRef = tabContentWrapperRef)
          }
        >
          {tabContentChildren}
        </div>
      </div>
    );
  }
}

/**********************************/
// Tab Content Wrapper
/**********************************/
const TabContent = ({ id, active, children }) => {
  const activeClass = id === active ? "selected" : "";
  return <div className={`tab-content ${activeClass}`}>{children}</div>;
};

/**********************************/
// Tab Controls
/**********************************/
const TabControlUnitMain = ({ mainItem, updateActive, children, active }) => {
  if (mainItem.defaultActive === active && !children) {
    if (!children) {
      return (
        <button className="tab-control tab-control-parent selected">
          {mainItem.title}
        </button>
      );
    }
  } else {
    return (
      <div className="tab-control-parent-wrapper">
        <button
          className="tab-control tab-control-parent"
          onClick={() => {
            updateActive(mainItem.defaultActive);
          }}
        >
          {mainItem.title}
        </button>
        {children}
      </div>
    );
  }
};

const TabControlUnitChild = ({ childItem, updateActive, active }) => {
  if (active === childItem.id) {
    return (
      <button
        className="selected tab-control tab-control-child"
        onClick={() => {
          updateActive(childItem.id);
        }}
      >
        {childItem.title}
      </button>
    );
  } else {
    return (
      <button
        className="tab-control tab-control-child"
        onClick={() => {
          updateActive(childItem.id);
        }}
      >
        {childItem.title}
      </button>
    );
  }
};

class TabLeftControl extends React.Component {
  render() {
    const { updateActive, navData, active } = this.props;
    return (
      <div className="tab-left-control">
        {navData.map(mainItem => {
          if (mainItem.children.length === 0) {
            return (
              <TabControlUnitMain
                active={active}
                mainItem={mainItem}
                key={mainItem.id}
                updateActive={updateActive}
              />
            );
          } else {
            return (
              <TabControlUnitMain
                mainItem={mainItem}
                key={mainItem.id}
                updateActive={updateActive}
              >
                {mainItem.children.map(childItem => (
                  <TabControlUnitChild
                    key={childItem.id}
                    childItem={childItem}
                    updateActive={updateActive}
                    active={active}
                  />
                ))}
              </TabControlUnitMain>
            );
          }
        })}
      </div>
    );
  }
}

const navData = [
  {
    id: "0.0",
    title: "Metal",
    defaultActive: "0.1",
    children: [
      {
        id: "0.1",
        title: "Seasons in the Abyss"
      },
      {
        id: "0.2",
        title: "There's Something. ."
      }
    ]
  },
  {
    id: "1.0",
    title: "Food",
    defaultActive: "1.1",
    children: [
      {
        id: "1.1",
        title: "Mango"
      }
    ]
  },
  {
    id: "2.0",
    title: "Something Big",
    defaultActive: "2.0",
    children: []
  }
];

class App extends React.Component {
  render() {
    return (
      <TabLeftMain
        onSelectedTabChange={selectedTabId => {
          // triggering callback
          console.log("updated tabID: ", selectedTabId);
        }}
        navData={navData}
        defaultActive="0.1"
      >
        <SeasonsInTheAbyss id="0.1" />
        <TheresSomething id="0.2" />
        <Mango id="1.1" />
        <Something id="2.0" />
      </TabLeftMain>
    );
  }
}

// Tab Content Components
const SeasonsInTheAbyss = ({ id, active }) => (
  <TabContent id={id} active={active}>
    <h2>Seasons in the Abyss - Slayer</h2>
    <p>
      Razors edge<br /> Outlines the dead<br /> Incisions in my head<br />{" "}
      Anticipation the stimulation<br /> To kill the exhilaration<br /> Close
      your eyes<br />Look deep in your soul<br /> Step outside yourself<br />And
      let your mind go<br /> Frozen eyes stare deep in your mind as you die<br />{" "}
      Close your eyes<br /> And forget your name<br /> Step outside yourself<br />{" "}
      And let your thoughts drain<br /> As you go insane, insane<br /> Inert
      flesh<br />
      A bloody tomb<br /> A decorated splatter brightens the room<br /> An
      execution a sadist ritual <br />Mad intervals of mind residuals<br />{" "}
      Close your eyes<br /> Look deep in your soul <br />Step outside yourself{" "}
      <br />And let your mind go <br />Frozen eyes stare deep in your mind as
      you die <br />Close your eyes and forget your name <br />Step outside
      yourself and let your thoughts drain <br />As you go insane, insane<br />
      Innate seed <br />To watch you bleed <br />A demanding physical need<br />{" "}
      Desecrated eviscerated <br />Times prostrated
    </p>
  </TabContent>
);
const TheresSomething = ({ id, active }) => (
  <TabContent id={id} active={active}>
    <h2>There's Something on My Side - Down</h2>
    <p className="large">
      It took a lot to sell my soul The same thing happened yesterday I paid my
      price, then felt alive But no pulse is within my veins Never will I lie
      and say I'm still alive Come what may to me, there's something on my side
      I'm left with heart, 'cause inside me's gone Compulsion drives me anyway I
      play my part and my part is large Makes me stronger every day Never will I
      lie and say I'm still alive Come what may to me, there's something on my
      side One year and it ain't so bad I'm trying to see things clearly The
      clearer it gets, the more I'm confused I'm thinking more about blindness
      Thinking hard about blindness Thinking purely of blindness There's
      something on my side There's something on my side There's something on my
      side There's something on my side
    </p>
  </TabContent>
);
const Mango = ({ id, active }) => (
  <TabContent id={id} active={active}>
    <h2>Mango</h2>
  </TabContent>
);
const Something = ({ id, active }) => (
  <TabContent id={id} active={active}>
    <h1>Something</h1>
  </TabContent>
);

ReactDOM.render(<App />, document.getElementById("root"));

              
            
!
999px

Console