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

              
                :root{
    --color-white: #fff;
    --color-green: #34FF3C;
    --color-gray-100: #1b1b1b;
    --color-gray-200: #222222;
    --color-gray-300: #333333;
    --color-gray-400: #444444;
    --color-gray-800: #888888;

    --color-bg: #8E898C;
    --color-bg-white: var(--color-white);
    --color-bg-dark: var(--color-gray-100);
    --color-bg-primary: var(--color-green);

    --color-text: var(--color-white);
    --color-link: var(--color-green);

    --color-text-secondary: var(--color-gray-100);
    --color-text-secondary-aside: var(--color-gray-800);
    --color-text-highlight: var(--color-green);

    --color-btn-primary-bg: var(--color-green);
    --color-btn-primary-text: var(--color-gray-100);
    --color-btn-dark-bg: var(--color-bg-dark);
    --color-btn-dark-bg-hover: var(--color-gray-400);
    --color-btn-dark-text: var(--color-text);

    // Typography
    --font: 'Lexend', sans-serif;

    --font-size-50: 12px;
    --font-size-75: 14px;
    --font-size-100: 17px;

    --line-height-sm: 1.25;

    --letter-spacing-200: .025em;

    // Spacing
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 32px;

    --border-radius-base: 8px;

    --z-index-mask: 10001;
    --z-index-modal: 10002;
}

* {
  box-sizing: border-box;
}

.cta {
    max-width: 24em;
    position: relative;
    font-family: var(--font);
    summary {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: var(--space-4);
        line-height: var(--line-height-sm);
        background: var(--color-btn-primary-bg);
        font-size: var(--font-size-75);
        color: var(--color-btn-primary-text);
        letter-spacing: var(--letter-spacing-200);
        text-transform: uppercase;
        text-decoration: none;
        text-align: center;
        border: 0;
        font-weight: bold;
        cursor: pointer;
        &::-webkit-details-marker {
            display: none;
        }
        &:hover {
            background: linear-gradient(-55deg, #07e419 0%, #dcffcc 50%, #07e419 100%);
            background-size: 300% 300%;
            animation: gradient 2s ease infinite;
        }
    }
    &[open] .dropdown {
        animation: fadeIn 0.25s ease;
    }
}

@keyframes gradient {
    0% {
        background-position: -50% 50%;
    }
    100% {
        background-position: 100% 50%;
    }
}

.dropdown {
    background: var(--color-bg-white);
    color: var(--color-text-secondary);
    max-width: 24em;
    width: 100%;
    padding: var(--space-3);
    position: absolute;
    z-index: var(--z-index-modal);
    top: 110%;
    border-radius: var(--border-radius-base);
    box-shadow: 0 var(--space-2) var(--space-5) rgba(0,0,0,.16);
}
@keyframes fadeIn {
    0% {
        opacity: 0; /* 透明 */
        transform: translateY(-10px); /* 上から表示 */
    }
    100% {
        opacity: 1;
        transform: none;
    }
}
.shareHeading {
    text-align: center;
    color: var(--color-text-secondary-aside);
    font-size: var(--font-size-50);
    letter-spacing: var(--letter-spacing-200);
    margin-bottom: var(--space-3);
}
.share {
    margin: 0;
    padding: 0;
    list-style: none;
    li {
        a {
            display: flex;
            gap: var(--space-2);
            align-items: center;
            justify-content: center;
            color: var(--color-btn-primary-text);
            text-decoration: none;
            &:hover {
                .icon {
                    background: var(--color-bg-primary);
                }
                .label {
                    border-bottom: 1px solid var(--color-text-highlight);
                }
            }
        }
        & + li {
            margin-top: var(--space-3);
        }
    }
}
.icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-text-secondary);
    transition: all .25s;
    img {
        display: block;
    }
}
.skip {
    text-align: right;
    button {
        margin: auto;
        background: transparent;
        border: none;
        color: var(--color-text-secondary-aside);
        font-size: var(--font-size-50);
        letter-spacing: var(--letter-spacing-200);
        &:hover {
            text-decoration: underline;
            cursor: pointer;
        }
    }
}
.thanksHeading {
    text-align: center;
    font-size: var(--font-size-75);
    letter-spacing: var(--letter-spacing-200);
    margin: var(--space-4) 0;
}
.docsLink {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    line-height: var(--line-height-sm);
    background: var(--color-btn-dark-bg);
    font-size: var(--font-size-75);
    color: var(--color-btn-dark-text);
    letter-spacing: var(--letter-spacing-200);
    text-transform: uppercase;
    text-decoration: none;
    text-align: center;
    border: 0;
    font-weight: bold;
    cursor: pointer;
    &:hover {
        background: var(--color-btn-dark-bg-hover);
    }
}
.back {
    text-align: right;
    margin-top: var(--space-3);
    button {
        margin: auto;
        background: transparent;
        border: none;
        color: var(--color-text-secondary-aside);
        font-size: var(--font-size-50);
        letter-spacing: var(--letter-spacing-200);
        &:hover {
            text-decoration: underline;
            cursor: pointer;
        }
    }
}

              
            
!

JS

              
                class Cta extends React.Component {
  // シェアボタン押したかどうかの状態を持つ
  // ref. https://reactjs.org/docs/conditional-rendering.html
  constructor(props) {
    super(props);
    this.shareClick = this.shareClick.bind(this);
    this.backClick = this.backClick.bind(this);
    this.state = {isShared: false};
  }

  shareClick() {
    this.setState({isShared: true});
  }

  backClick() {
    this.setState({isShared: false});
  }

  render() {
    // シェアボタン押したらコンポーネント出し分け
    const isShared = this.state.isShared;
    let dropdownContent;
    if (isShared) {
      dropdownContent = <Thankyou onClick={this.backClick} />;
    } else {
      dropdownContent = <ShareButtons onClick={this.shareClick} />;
    }

    // CTAボタン
    return (
      <>
        <details className="cta">
          <summary>FREE DOWNLOAD</summary>
          <div className="dropdown">
            {dropdownContent}
          </div>
        </details>
      </>
    );
  }
}

function ShareButtons(props) {
  return (
    <>
      <div className="shareHeading">Select one to continue</div>
      <ul className="share">
        <li>
          <a
            href="https://twitter.com/share"
            target="_blank"
            rel="noreferrer"
            onClick={props.onClick}
          >
            <span className="label">
              Pay with tweet
            </span>
          </a>
        </li>
        <li>
          <a
            href="http://www.facebook.com/sharer.php"
            target="_blank"
            rel="noreferrer"
            onClick={props.onClick}
          >
            <span className="label">
              Pay with share
            </span>
          </a>
        </li>
        <li className="skip">
          <button
            onClick={props.onClick}
          >
            ...Or skip for now
          </button>
        </li>
      </ul>
    </>
  );
}

function Thankyou(props) {
  return (
    <>
      <div className="thanksHeading">Thanks for your support!</div>
      <a
        href="https://example.com"
        className="docsLink"
        target="_blank"
        rel="noopener noreferrer"
      >
        Get Started
      </a>
      <div className="back">
        <button
          onClick={props.onClick}
        >
          ← Share again
        </button>
      </div>
    </>
  );
}


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

              
            
!
999px

Console