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

              
                <body onload='document.getElementById("vader-bid").play();'>
  <header>Vader's &nbsp; Laters</header>
    
  <div id='root'></div>

  <audio id='vader-bid' src='http://www.thesoundarchive.com/starwars/swvader04.wav' />
  <audio id='saber-on' src='http://soundbible.com/mp3/Lightsaber Turn On-SoundBible.com-1637663395.mp3' />
  <audio id='saber-hit' src='https://www.freesound.org/data/previews/78/78671_1083679-lq.mp3' />
  <audio id='saber-humm' src='https://www.freesound.org/data/previews/47/47123_383523-lq.mp3' />
  <audio id='saber-wave' src='https://www.freesound.org/data/previews/78/78681_1083679-lq.mp3' />
</body>
              
            
!

CSS

              
                html {
  height: 100%;
}

body {
  background:
    radial-gradient(black 15%, transparent 16%) 0 0,
    radial-gradient(black 15%, transparent 16%) 8px 8px,
    radial-gradient(rgba(255,255,255,.1) 15%, transparent 20%) 0 1px,
    radial-gradient(rgba(255,255,255,.1) 15%, transparent 20%) 8px 9px;
  background-color: #282828;
  background-size: 16px 16px;
  text-align: center;
  padding: 0;
  margin: 0;
}

section {
  flex: 1 0 auto;
}

header, footer {
  font: normal 30px "Monoton", Helvetica, sans-serif;
  color: #F1F1F1;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 30px 0 20px 0;
}

footer {
  font: normal 12px "Monoton", Helvetica, sans-serif;
}

.container {
  height: 80vh;
  display: flex;
  flex-direction: column;
}

input, button {
  font-size: 16px;
  background: #1A1A1A;
  height: 25px;
  width: 350px;
  border-radius: 12px;
  border: none;
  color: #A2A2A2;
  padding: 6px 6px 6px 12px;
  outline: none;
  box-shadow: 0 4px 6px -5px hsl(0, 0%, 40%), inset 0px 4px 6px -5px hsl(0, 0%, 2%);
}

button {
  height: 35px;
  width: 35px; 
  padding: 3px 3px 3px 5px;
  margin-left: 5px;
  cursor: pointer;
}

.editor {
  font-size: 24px;
  background: none;
  border-radius: 0;
  width: 300px;
  border: solid #f0f0f0;
  border-width: 0 0 2px 0;
  color: #A2A2A2;
  padding: 0 6px 6px;
  outline: none;
  box-shadow: none;
}

ul {
  text-align: center;
  width: 60%;
  margin: 30px auto;
}

li {
  display: block;
  cursor: pointer;
  box-sizing: content-box;
  padding-top: 25px;
  border: none;
  font: normal 24px/1 "Monoton", Helvetica, sans-serif;
  color: rgba(255,255,255,1);
  letter-spacing: 1px;
  text-align: left;
  text-shadow: 0 0 5px rgb(255,255,255), 0 0 10px rgb(255,255,255), 0 0 15px rgb(255,255,255), 0 0 20px rgb(255,17,119), 0 0 35px rgb(255,17,119), 0 0 40px rgb(255,17,119), 0 0 50px rgb(255,17,119), 0 0 75px rgb(255,17,119);
  transition: all 200ms cubic-bezier(0.42, 0, 0.58, 1) 10ms;
}

li:hover {
  text-shadow: 0 0 10px rgba(255,255,255,1), 0 0 20px rgba(255,255,255,1), 0 0 30px rgba(255,255,255,1), 0 0 40px #00ffff, 0 0 70px #00ffff, 0 0 80px #00ffff, 0 0 100px #00ffff !important;
}

a {
  color: #f0f0f0;
  background-color: #282828;
  border: solid 1px #f0f0f0;
  border-radius: 5px;
  text-decoration: none;
  padding: 3px 6px;
  margin: 6px;
}

.selected {
  color: #282828;
  background-color: #f0f0f0;
}

              
            
!

JS

              
                const todo = (state, action) => {
  switch (action.type) {
    case 'ADD_TODO':
      return {
        id: action.id,
        text: action.text,
        completed: false
      };
    case 'TOGGLE_TODO':
      if (state.id !== action.id) {
        return state;
      }
      
      return {
        ...state,
        completed: !state.completed
      };
    case 'EDIT_TODO':
      if (state.id !== action.id) {
        return state;
      }
      
      return {
        ...state,
        text: action.text
      };
    default:
      return state;
  }
};

const todos = (state = [], action) => {
  switch (action.type) {
    case 'ADD_TODO':
      return [
        ...state,
        todo(undefined, action)
      ];
    case 'TOGGLE_TODO':
      return state.map(t =>
        todo(t, action)                
      );
    case 'EDIT_TODO':
      return state.map(t =>
        todo(t, action)                
      );
    default:
      return state;
  }
};

const visibilityFilter = (
  state = 'SHOW_ALL',
  action
) => {
  switch (action.type) {
    case 'SET_VISIBILITY':
      return action.filter;
    default:
      return state;
  }
};

const { combineReducers, createStore } = Redux;
const todoApp = combineReducers({ todos, visibilityFilter });
const store = createStore(todoApp);

const { Component } = React;
let nextTodoId = 0;

class TodoApp extends Component {
  render() {
    const {todos, visibilityFilter} = this.props.store.getState();
    const filteredTodos = todos.filter(todo => {
      if (visibilityFilter === 'SHOW_ACTIVE') {
        return !todo.completed;
      }
      if (visibilityFilter === 'SHOW_COMPLETED') {
        return todo.completed;
      }
      return true;
    })
    
    return (
      <div className='container'>
        <section>
          <input placeholder='Add Task' ref={node => {
          this.input = node;
          }} />

          <button onClick={() => {
            this.props.store.dispatch({
              type: 'ADD_TODO',
              text: this.input.value,
              id: nextTodoId++
            });
            this.input.value = '';
            document.getElementById('saber-humm').play();
          }}>
          &#x26A1;
          </button>

          <ul>
            {filteredTodos.map(todo =>
            <li key={todo.id}
                onMouseOver={() => {
                  document.getElementById(todo.completed ? 'saber-wave' : 'saber-on').play();
                }}
                style={{textShadow: todo.completed ? 'none' : '0 0 10px rgb(255,255,255), 0 0 20px rgb(255,255,255), 0 0 30px rgb(255,255,255), 0 0 40px rgb(255,17,119), 0 0 70px rgb(255,17,119), 0 0 80px rgb(255,17,119), 0 0 100px rgb(255,17,119), 0 0 150px rgb(255,17,119)'}}>

              <span style={{margin: '3px 20px 0 0'}}
                    onClick={() => {
                      this.props.store.dispatch({
                      type: 'TOGGLE_TODO',
                      id: todo.id
                    });
                    document.getElementById(todo.completed ? 'saber-humm' : 'saber-hit').play();
              }}>
                {todo.completed ? <span>&#x2620;</span> : <span>&#x2639;</span>}
              </span>

              <ContentEditable 
                html={todo.text}
                editTodo={text => {
                  this.props.store.dispatch({
                  type: 'EDIT_TODO',
                  id: todo.id,
                  text
                });
              }} />
            </li>
            )}
          </ul>
        </section>
          
        <footer>
          <a id='vis1' href='#' onClick={e => this.setVisibility(e, 'SHOW_ALL')}>All</a>
          <a id='vis2' href='#' onClick={e => this.setVisibility(e, 'SHOW_ACTIVE')}>Active</a>
          <a id='vis3' href='#' onClick={e => this.setVisibility(e, 'SHOW_COMPLETED')}>Completed</a>
        </footer>
      </div>
    )
  }
  
  setVisibility(e, filter) {
    this.props.store.dispatch({
      type: 'SET_VISIBILITY',
      filter
    });
    
    const links = document.querySelectorAll('a');

    for (var i = 0; i < links.length; i++) {
      links[i].classList.remove('selected');
    }
    
    e.target.classList.add('selected');
  }
}

class ContentEditable extends Component {
  constructor(props) {
    super(props);
    this.state = {editing: false}
  }
  render() {
    return (
      this.state.editing ?
        <input className='editor' ref='todoText' onBlur={e => this.handleChange(e)} defaultValue={this.props.html} />
        :
        <span onDoubleClick={e => this.handleDoubleClick()}>{this.props.html}</span>
      );
    }
    handleDoubleClick() {
      this.setState({
        editing: true
      });
    }
    handleChange(e) {
      const text = this.refs.todoText.value;
      this.props.editTodo(text);
      this.setState({
        editing: false
      });
    }
}

const render = () => {
  ReactDOM.render(
    <TodoApp 
      store={store}
    />,
    document.getElementById('root')
  )
};

store.subscribe(render);
render();
              
            
!
999px

Console