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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

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



              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Audiowide|Bungee+Inline|Bungee+Shade|Plaster|Righteous|VT323");

.wrapper {
  height: 100vh;
  min-width: 750px;
  min-width: 600px;
  background-image: url("https://images.unsplash.com/photo-1505562130589-9879683e72da?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=94f59c798cc667c7966bf41e7f5144d3&auto=format&fit=crop&w=2250&q=80");
  background-size: cover;
  backdrop-filter: blur(5px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  box-shadow: inset 0 0 1000px 10px rgba(0, 0, 0, 0.719);
}
.top {
  height: 30px;
  width: 10%;
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-bottom: -12px;
  max-width: 900px;
  min-width: 750px;
  overflow: hidden;
}
#top-Middle {
  margin-top: 5px;
  background-color: rgb(26, 26, 26);
  width: 100%;
  height: 20px;
}

#top-Left {
  width: 45px;
  border-radius: 5px 5px 0 0px;
  transform: skewX(-30deg);
}

#top-Right {
  width: 45px;
  border-radius: 5px 5px 0 0;
  transform: skewX(30deg);
}

#drum-machine {
  display: flex;
  justify-content: stretch;
  background-color: rgb(26, 26, 26);
  height: 50%;
  width: 100%;
  max-width: 900px;
  min-width: 815px;
  min-height: 420px;
  max-height: 450px;
  border-radius: 5px;
  z-index: 1;
  box-shadow: 10px 10px 100px 5px black, 0px -10px 10px -7px rgba(0, 0, 0, 0.8);
}
.woodSide {
  background-color: #5d3a00;
  width: 40px;
  border-radius: 5px;
  background-image: url("https://images.unsplash.com/photo-1520932222620-1ca4a3635637?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=50b5aa54356831ba99ac5f6a62d0b22d&auto=format&fit=crop&w=1650&q=80");
  background-size: cover;
  margin-bottom: -4px;
}

#drum-machine .woodSide:last-child {
  border-radius: 5px 0px 5px 5px;
  box-shadow: -10px 0px 15px -1px #000;
}

#drum-machine .woodSide:first-child {
  border-radius: 0px 5px 5px 5px;
  box-shadow: 10px 0 15px -1px #000;
}
.drumWrapper {
  background-image: url("https://images.unsplash.com/photo-1515387784663-e2e29a23f69e?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=2318a6f6c34bfe268eff6dd28ed4321f&auto=format&fit=crop&w=1234&q=80");
  background-size: cover;
  width: 45%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin: 20px 5px 20px 5px;
  border-radius: 5px;
  border: solid 1px #777;
  box-shadow: inset 0px 0px 0px 1000px rgba(15, 1, 1, 0.377), 0px 0px 10px #000;
}
.drum-set {
 display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 25px;
  grid-gap: 5px;
  max-height: 340px;
}

.drum-pad {
  background-size: cover;
  background-color: #e5d330;
  border-radius: 5px;
  box-shadow: inset 15px 5px 75px 0px rgba(0, 0, 0, 0.651),
    0px 0px 10px 4px rgb(21, 30, 32);
  border-left: solid 1px #555;
  border-bottom: solid 1px #555;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  font-family: "Audiowide", cursive;
}

 .active {
  transform: translateY(2px);
   box-shadow: 0 0 13px #e3e3e3;
}

.buttonLetter {
  padding: 10px 0;
}
.buttonLetter,
.keyMsg {
  color: transparent;
  background: antiquewhite;
  text-shadow: 1px 1px 1px rgba(150, 149, 148, 0.4);
  -webkit-background-clip: text;
  -moz-background-clip: text;
  background-clip: text;
  margin: 0;
 
}

.keyMsg {
  font-family: "Audiowide", cursive;
   font-size: 0.8rem;
   padding-bottom: 15px;
}

@media  (max-width: 950px) {
  .keyMsg {
    font-size: 0.5em;
  }
} 

.drum-pad:nth-child(1),
.drum-pad:nth-child(2),
.drum-pad:nth-child(3) {
  background-color: rgb(177, 75, 49);
  background-color: #f55d3e;
}
.drum-pad:nth-child(4),
.drum-pad:nth-child(5),
.drum-pad:nth-child(6) {
  background-color: rgb(177, 126, 49);
  background-color: #faa916;
}

#display-Side {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 20px 5px 20px 5px;
  box-shadow: inset 0px 0px 25px rgb(0, 0, 0), 0px 0px 10px rgb(19, 44, 19);
  width: 45%;
  border-radius: 5px;
  border: double 1px #777;
}

.label {
  text-align: center;
  width: 80%;
  /* margin-top: 45px; */
  background: linear-gradient(
    135deg,
    rgb(177, 75, 49) 0%,
    #b5b5b5 33%,
    antiquewhite 47%,
    #ffffff57 70%,
    rgba(250, 235, 215, 0.651) 77%
  );
  font-style: italic;
  box-shadow: 0 0 0 5px hsl(0, 0%, 0%), 0 0px 0px 7px rgba(250, 235, 215, 0.829),
    2px 1px 0px 8px rgb(177, 75, 49);
  border-radius: 10px;
  font-family: "Bungee Shade", cursive;
}

#display {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 20%;
  background-color: rgb(76, 90, 73);
  background: linear-gradient(
    135deg,
    rgb(76, 90, 73) 0%,
    rgb(76, 90, 73) 33%,
    rgb(88, 100, 85) 47%,
    rgb(76, 90, 73) 70%,
    rgb(71, 87, 68) 77%
  );
  width: 70%;
  text-align: center;
  margin: auto;
  color: rgb(200, 211, 200);
  box-shadow: inset 0px 0px 25px rgb(2, 53, 2), 0px 0px 1px 10px rgb(0, 0, 0),
    0 0 0 11px antiquewhite, 0 0 0 14px black, 0 0 0 15px antiquewhite,
    0 0 10px 20px black;
  border-radius: 5px;
  border: solid 2px black;
  font-size: 2.5em;
  font-family: "VT323", monospace;
}

.screwWrapper {
  align-self: flex-start;
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin: 5px 0px;
}
.screw {
  height: 20px;
  width: 20px;
  border-radius: 50%;
  border-left: solid 1px white;
  border-top: solid 1px #777;
  border-right: solid 2px white;
  box-shadow: inset 2px 0 5px black, 0 1px 5px 1px black;
  background-color: #333;
  z-index: 1;
}

.drumWrapper .screwWrapper:nth-child(1) {
  flex-direction: row-reverse;
}
.drumWrapper .screwWrapper:nth-child(1) #screw1 {
  margin-right: 5px;
}
.drumWrapper .screwWrapper:nth-child(1) #screw2 {
  margin-left: 5px;
  transform: rotate(-5deg);
}

.screw::before {
  content: "+";
  padding: 6px;
  color: #000;
}

#screw1 {
  transform: rotate(10deg);
  margin-left: 5px;
}
#screw2 {
  margin-right: 5px;
}
#display #screw2 {
  transform: rotate(39deg);
}

.footer {
  font-family: "Audiowide", cursive;
  width: 100%;
  font-size: 1.75em;
  margin-top: 40px;
  color: rgb(76, 90, 73);
  text-align: center;
  text-shadow: 0 2px 20px rgba(51, 51, 51, 0.514);
}
.socialLinks i {
  font-size: 1.25em;
  margin: 0px 10px;
  color: rgb(76, 90, 73);
}

.photoCredits {
  font-size: 0.5em;
  line-height: 5px;
  margin-top: 40px;
}
.photoCredits a {
  color: #f55d3e;
  text-decoration: none;
}
@media screen and (min-width: 958px) {
  .label {
    font-size: 1.25em;
  }
}

@media screen and (max-width: 700px) {
  .label {
    font-size: 0.9em;
  }
}

              
            
!

JS

              
                class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      keyPressed: "",
      message: "",
      sound: "",
      showMessage: true,
      keyDown: false,
      drumKeys: [
        {
          keyPressed: "Q",
          message: "Kick-Drum",
          sound:
            "http://sampleswap.org/samples-ghost/%20MAY%202014%20LATEST%20ADDITIONS/DRUMS%20(FULL%20KITS)/Choosy%20House%20Kit/67[kb]choosy-house-Kick17.wav.mp3"
        },
        {
          keyPressed: "W",
          message: "Space-Kick",
          sound:
            "http://sampleswap.org/samples-ghost/DRUMS%20(FULL%20KITS)/Hip%20Hop%20Specialty%20Kit/296[kb]say-bow-beep.wav.mp3"
        },
        {
          keyPressed: "E",
          message: "Clap",
          sound:
            "http://sampleswap.org/samples-ghost/DRUMS%20and%20SINGLE%20HITS/claps/13[kb]707_HCP.WAV.mp3"
        },
        {
          keyPressed: "A",
          message: "Rim-Shot",
          sound: "http://s1download-universal-soundbank.com/wav/4392.wav"
        },
        {
          keyPressed: "S",
          message: "High-Hat",
          sound:
            "http://dight310.byu.edu/media/audio/FreeLoops.com/2/2/Dirty%20South%20Hihat%2001-3615-Free-Loops.com.mp3"
        },
        {
          keyPressed: "D",
          message: "Crash",
          sound:
            "http://sampleswap.org/samples-ghost/DRUMS%20and%20SINGLE%20HITS/crashes/92[kb]909-bright-crash.aif.mp3"
        },
        {
          keyPressed: "Z",
          message: "Laser",
          sound:
            "http://sampleswap.org/samples-ghost/DRUMS%20(FULL%20KITS)/R2D2-droid/41[kb]R2D2-disappointment.aif.mp3"
        },
        {
          keyPressed: "X",
          message: "R2D2",
          sound:
            "http://sampleswap.org/samples-ghost/DRUMS%20(FULL%20KITS)/R2D2-droid/52[kb]R2D2-datapath.aif.mp3"
        },
        {
          keyPressed: "C",
          message: "Scratch",
          sound:
            "http://sampleswap.org/samples-ghost/DRUM%20LOOPS%20and%20BREAKS/turntables%20and%20scratching/48[kb]basic-scratch.aif.mp3"
        }
      ]
    };

    this.onKeyDown = this.onKeyDown.bind(this);
    this.handleClick = this.handleClick.bind(this);
    this.playAudio = this.playAudio.bind(this);
  }
  playAudio(key) {
    const audio = document.getElementById(key);
    audio.currentTime = 0;
    audio.play();
    const msg = this.state.drumKeys[this.findInDrumKeys(key)].message;
    this.setState({ message: msg });
  }

  findInDrumKeys(keyID) {
    let ind = "";
    this.state.drumKeys.map((key, index) => {
      if (key.keyPressed === keyID) {
        ind = index;
      }
    });
    return ind;
  }

  handleClick(event) {
    console.log(event.currentTarget.value, event.currentTarget);
    const keyID = event.currentTarget.value;
    this.setState({ showMessage: true });
    this.playAudio(keyID);
  }

  onKeyUp() {
    this.setState({ keyDown: false });
    setTimeout(() => {
      !this.state.keyDown && this.setState({ showMessage: false, message: "" });
    }, 750);
     switch (event.keyCode) {
      case 81:
        return document.getElementById("Kick-Drum").classList.remove("active"); //this.playAudio("Q")
      case 87:
        return document.getElementById("Space-Kick").classList.remove("active");
      case 69:
        return document.getElementById("Clap").classList.remove("active");
      case 65:
        return document.getElementById("Rim-Shot").classList.remove("active");
      case 83:
        return document.getElementById("High-Hat").classList.remove("active");
      case 68:
        return document.getElementById("Crash").classList.remove("active");
      case 90:
        return document.getElementById("Laser").classList.remove("active");
      case 88:
        return document.getElementById("R2D2").classList.remove("active");
      case 67:
        return document.getElementById("Scratch").classList.remove("active");
      default:
        return null;
    }
  }

  onMouseUp() {
    this.setState({ keyDown: false });
    setTimeout(() => {
      !this.state.keyDown && this.setState({ showMessage: false, message: "" });
    }, 750);
  }

  onKeyDown(event) {
    this.setState({
      showMessage: true,
      keyDown: false
    });

   
    switch (event.keyCode) {
      case 81:
        return (
          document.getElementById("Kick-Drum").classList.add("active"),
          this.playAudio("Q")
        );
      case 87:
        return (
          document.getElementById("Space-Kick").classList.add("active"),
          this.playAudio("W")
        );
      case 69:
        return (
          document.getElementById("Clap").classList.add("active"),
          this.playAudio("E")
        );
      case 65:
        return (
          document.getElementById("Rim-Shot").classList.add("active"),
          this.playAudio("A")
        );
      case 83:
        return (
          document.getElementById("High-Hat").classList.add("active"),
          this.playAudio("S")
        );
      case 68:
        return (
          document.getElementById("Crash").classList.add("active"),
          this.playAudio("D")
        );
      case 90:
        return (
          document.getElementById("Laser").classList.add("active"),
          this.playAudio("Z")
        );
      case 88:
        return (
          document.getElementById("R2D2").classList.add("active"),
          this.playAudio("X")
        );
      case 67:
        return (
          document.getElementById("Scratch").classList.add("active"),
          this.playAudio("C")
        );
      default:
        return null;
    }
  }

  componentDidMount() {
    window.addEventListener("keydown", event => {
      this.onKeyDown(event);
    });
    window.addEventListener("keyup", event => {
      this.onKeyUp(event);
    });
    window.addEventListener("mouseup", event => {
      this.onMouseUp(event);
    });
  }

  componentWillUnmount() {
    window.removeEventListener("keydown");
    window.removeEventListener("keyup");
    window.removeEventListener("mouseup");
  }
  render() {
    return (
      <div className="wrapper">
        <div className="top">
          <div className="woodSide" id="top-Left" />
          <div id="top-Middle" />
          <div className="woodSide" id="top-Right" />
        </div>
        <div className="App" id="drum-machine">
          <div className="woodSide" />
          <DrumSet
            drumKeys={this.state.drumKeys}
            message={this.state.message}
            handleClick={this.handleClick}
          />
          <Display
            keyPressed={this.state.keyPressed}
            showMessage={this.state.showMessage}
            message={this.state.message}
            sound={this.state.sound}
          />
          <div className="woodSide" />
        </div>
        <Footer />
      </div>
    );
  }
}


class Screws extends React.Component {
  render() {
    return (
      <div className="screwWrapper">
        <div className="screw" id="screw1" />
        <div className="screw" id="screw2" />
      </div>
    );
  }
}

class DrumSet extends React.Component {
 render() {
    const drumKeys = this.props.drumKeys;

    return (
      <div className="drumWrapper">
        <Screws />
        <div className="drum-set">
          {drumKeys.map(drum => (
            
              <button
                className="drum-pad"
                key={drum.keyPressed}
                id={drum.message}
                onClick={this.props.handleClick}
                value={drum.keyPressed}
              >
                
                  <p className="buttonLetter">{drum.keyPressed}</p>
                   <p className="keyMsg">{drum.message}</p>
                  <audio
                    id={drum.keyPressed}
                    className="clip"
                    src={drum.sound}
                    preload="true"
                  />
               
              </button>
             
          
          ))}
        </div>
        <Screws />
      </div>
    );
  }
}

class Display extends React.Component {
 render() {
    let showMessage = this.props.showMessage;
    const soundPressed = this.props.message;

    return (
      <div id="display-Side">
        <Screws />
        <p className="label">FCC :|: DrumMachine :|:</p>
        <div id="display">
          {{ showMessage } && (
            <div className="display-text">{soundPressed}</div>
          )}
        </div>
        <Screws />
      </div>
    );
  }
}

class Footer extends React.Component {
  render() {
    return (
      <div className="footer">
        <div className="socialLinks">
          <a href="https://github.com/REAOrlando" target="_blank">
            <i className="fab fa-github" />
          </a>
         
          <a href="https://twitter.com/albanesechris" target="_blank">
            <i className="fab fa-twitter" />
          </a>
        </div>

        <p>© Christopher Albanese 2018</p>
        
        <div className="photoCredits">
          <p>
            Woodgrain photo by{" "}
            <a
              href="https://unsplash.com/photos/8mDJ31rIg08?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText"
              target="_blank"
            >
              rawpixel
            </a>{" "}
            on{" "}
            <a
              href="https://unsplash.com/search/photos/woodgrain?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText"
              target="_blank"
            >
              Unsplash
            </a>.
          </p>

          <p>
            Background photo by{" "}
            <a
              href="https://unsplash.com/photos/oBb-Y26PJgg?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText"
              target="_blank"
            >
              Samuel Zeller
            </a>{" "}
            on{" "}
            <a
              href="https://unsplash.com/search/photos/texture?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText"
              target="_blank"
            >
              Unsplash
            </a>.
          </p>

          <p>
            Pad texture photo by{" "}
            <a
              href="https://unsplash.com/photos/fcZIyU-nbFE?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText"
              target="_blank"
            >
              Nathan Anderson
            </a>{" "}
            on{" "}
            <a
              href="https://unsplash.com/search/photos/texture?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText"
              target="_blank"
            >
              Unsplash
            </a>.
          </p>
        </div>
      </div>
    );
  }
}


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


              
            
!
999px

Console