cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Helvetica Neue, sans-serif;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: #111;

}
.container {
  width: 75vw;
}
.overflow {
  background-color: #222;
  color: #ddd;
  margin-top: 20px;
  padding: 40px;
  font-size: 1.2em;
  font-weight: 100;
  
  h1 {
    margin: 0 0 20px 0;
    font-weight: 100;
    color: white;
  }
}
.overflow-text {
  background-color: OrangeRed;
  color: white;
  letter-spacing: 1px;
}
.overflow-count {
  color: #00ccff;
  font-size: 1.4em;
  font-weight: 100;
}
.overflow-count-alert {
  color: OrangeRed;
  font-size: 1.4em;
  font-weight: 100;
}
.flex-inner {
  display: flex;
  justify-content: flex-end;
}
.flex-outer li {
  align-items: center;
  display: flex;
}
.flex-outer > li:not(:last-child) {
  margin-bottom: 20px;
}
.flex-outer li textarea {
  border: 1px solid #555;
  font-weight: 100;
  font-size: 1.5em;
  width: 100%;
  min-height: 145px;
  padding: 20px;
  resize: none;
  outline: none;
  background: #1a1a1a;
  color: #ddd;
  
  &:hover, &:focus {
    border: 1px solid #00ccff;
  }
}
.flex-outer li button {
  background: #111;
  border-radius: 0px;
  border: 1px solid #00ccff;
  outline: 0;
  color: #00ccff;
  margin-left: 20px;
  padding: 10px 28px;
  font-weight: 100;
  font-size: 1.5em;
  
  &:active, &:hover {
    background: #00ccff;
    color: black;
    border: 1px solid #00ccff;
  }
  &:active {
    outline: 1px solid #00ccff;
  }
  &:focus {
    border: 1px solid #00ccff;
  }
  &:disabled {
    color: #555;
    background-color: #222;
    border: 1px solid #111;
  }
}
            
          
!
            
              const { h, app } = hyperapp
/** @jsx h */

const MAX_LENGTH = 140
const OFFSET = 10

const OverflowWidget = ({ text, offset, count }) =>
  <div class="overflow">
    <h1>Whoops! Too long.</h1>
    <p>
      ...{text.slice(0, offset)}
      <span class="overflow-text">
        {text.slice(count)}
      </span>
    </p>
  </div>

const Tweetbox = ({ count, text, update }) =>
  <main>
    <div class="container">
      <ul class="flex-outer">
        <li>
          <textarea
            placeholder="What's up?"
            value={text}
            oninput={update}
          />
        </li>

        <li class="flex-inner">
          <span class={count > OFFSET ? "overflow-count" : "overflow-count-alert"}>
            {count}
          </span>

          <button
            onclick={() => alert(text)}
            disabled={count >= MAX_LENGTH || count < 0}
          >
            Tweet
          </button>
        </li>
      </ul>

      {count < 0 &&
        <OverflowWidget
          text={text.slice(count - OFFSET)}
          offset={OFFSET}
          count={count}
        />}

    </div>
  </main>

const state = {
  text: "",
  count: MAX_LENGTH
}

const view = (state, actions) =>
  <Tweetbox
    text={state.text}
    count={state.count}
    update={e => actions.update(e.target.value)}
  />

const actions = {
  update: text => state => ({
    text,
    count: state.count + state.text.length - text.length
  })
}

app(state, actions, view, document.body)

            
          
!
999px
Loading ..................

Console