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 class="container">
  <msn-messenger-window></msn-messenger-window>
</div>

<div class="created">
  <span>Created by</span>
  <a href="https://manz.dev/"><h2>Manz.dev</h2></a>
  <p>on <a href="https://twitch.tv/ManzDev">Twitch</a> / <a href="https://youtube.com/c/ManzDev/videos">Youtube</a></p>
</div>
              
            
!

CSS

              
                @use postcss-nested;

body {
  background: #2c2b5c;
}

.container {
  display: flex;
  justify-content: center;
  margin: 1em auto;
}

.created {
  background: 
    url(https://assets.codepen.io/154065/internal/avatars/users/default.png),
    linear-gradient(to bottom, #884ced, #ec1cce);
  background-size: 75px 75px, cover;
  background-repeat: no-repeat;
  position: absolute;
  top: 0;
  right: 0;
  width: 250px;
  height: 75px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-left: 2em;
  
  & span,
  & h2,
  & p,
  & a {
    font-family: Montserrat;
    margin: 0;
  }
  
  & a,
  & p,
  & span {
    color: #fff;    
  }
  
  & h2 {
    font-weight: 700;
    transform: translate(0, -4px);    
  }
  
  & a {
    text-decoration-color: rgba(255,255,255,0.4);
  }
  
  & a:hover {
    color: #e6e82a;
  }
}
              
            
!

JS

              
                /**
  Only visual demo (includes nudge!)
  
  GitHub (one component per file):
  https://github.com/ManzDev/twitch-msn-messenger
**/

const nudgeSound = new Audio("sounds/nudge.mp3");

class ImageButton extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: "open" });
  }

  static get styles() {
    return `
      .container {
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
      }
      .text {
        font-family: Verdana;
        font-size: 10.5px;
        letter-spacing: -0.25px;
        color: #434C4B;
      }
      .text span {
        text-decoration: underline;
      }
    `;
  }

  connectedCallback() {
    this.image = "toolbar/" + this.getAttribute("image") + ".png";
    this.text = this.getAttribute("text") ?? "Sin texto";
    this.bind = this.getAttribute("bind");
    this.label = this.text.replace(this.bind, `<span>${this.bind}</span>`);
    this.render();
  }

  render() {
    this.shadowRoot.innerHTML = `
    <style>${ImageButton.styles}</style>
    <div class="container">
      <img src="${this.image}" alt="${this.text}">
      <div class="text">${this.label}</div>
    </div>`;
  }
}

customElements.define("image-button", ImageButton);

class SimpleButton extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: "open" });
  }

  static get styles() {
    return `
      .container {
        display: flex;
        align-items: center;
        padding: 0 6px;
        height: 100%;
      }
      .container img {
        height: 16px;
      }
      .container span:not(:empty) {
        font-family: Verdana;
        font-size: 10px;
        color: #444;
        display: inline-block;
        width: 50px;
        padding-left: 3px;
      }
      .container button {
        border: 0;
        background: transparent;
        transform: scale(0.6);
        padding: 0;
      }
    `;
  }

  onClick() {
    if (this.text === "nudge") {
      this.dispatchEvent(new CustomEvent("nudge", { bubbles: true, composed: true }));
    }
  }

  connectedCallback() {
    this.image = "simple/" + this.getAttribute("image") + ".png";
    this.text = this.getAttribute("image");
    this.label = this.getAttribute("label") ?? "";
    this.arrowButton = this.hasAttribute("arrow") ? "<button>⯆</button>" : "";
    this.render();
    this.shadowRoot.querySelector(".container img").addEventListener("click", () => this.onClick());
  }

  render() {
    this.shadowRoot.innerHTML = `
    <style>${SimpleButton.styles}</style>
    <div class="container">
      <img src="${this.image}" alt="${this.text}">
      <span>${this.label}</span>
      ${this.arrowButton}
    </div>`;
  }
}

customElements.define("simple-button", SimpleButton);

class TabButton extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: "open" });
  }

  static get styles() {
    return /* css */`
      .container {
        min-width: 25px;
        height: 18px;
        border: 1px solid #ABB0C6;
        border-top: 0;
        border-radius: 0 0 6px 6px;
        display: flex;
        justify-content: center;
        background: #EDF2F8;
      }
      :host([focus]) .container {
        background: #fff;
        border-bottom: 3px solid #E2C47B;
        border-top: 0;
        transform: translateY(-1px);
      }
      img {
        width: 16px;
        height: 16px;
      }
    `;
  }

  connectedCallback() {
    this.image = "tabs/" + this.getAttribute("image") + ".png";
    this.text = this.getAttribute("image");
    this.render();
  }

  render() {
    this.shadowRoot.innerHTML = /* html */`
    <style>${TabButton.styles}</style>
    <div class="container">
      <img src="${this.image}" alt="${this.text}">
    </div>`;
  }
}

customElements.define("tab-button", TabButton);

class MSNMessengerAvatar extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: "open" });
  }

  static get styles() {
    return /* css */`
      .container {
        width: 114px;
        height: 114px;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
        border: 1px solid #586170;
        border-radius: 8px;
        position: relative;
      }
      .picture {
        width: 96px;
        height: 96px;
        border: 1px solid #586170;
        border-radius: 8px;
        transform: translateY(4px);
      }
      .down {
        border: 0;
        background: transparent;
        color: #4D5967;
        transform: scaleY(0.5);
        align-self: flex-end;
      }
      .expand {
        position: absolute;
        top: 4px;
        right: -9px;
      }
    `;
  }

  connectedCallback() {
    this.image = this.getAttribute("image") ?? "msn";
    this.render();
  }

  render() {
    this.shadowRoot.innerHTML = /* html */`
    <style>${MSNMessengerAvatar.styles}</style>
    <div class="container">
      <img class="picture" src="avatars/${this.image}.png" alt="Avatar">
      <button class="down">⯆</button>
      <img class="expand" src="ui/expand-left.png" alt="expand arrow">
    </div>
    `;
  }
}

customElements.define("msn-messenger-avatar", MSNMessengerAvatar);

class MSNMessengerChat extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: "open" });
  }

  static get styles() {
    return /* css */`
      .container {
        display: grid;
        grid-template-rows: 24px 1fr 24px;
        min-height: 122px;
        background: #fff;
        width: 97%;
        border: 1px solid #586170;
        border-radius: 6px;
      }
      .actionbar,
      .tabs {
        background: linear-gradient(#D8E8F7, #F5F2F9, #D8E8F7);
      }
      .actionbar {
        border-bottom: 1px solid #586170;
        border-radius: 6px 6px 0 0;
        display: flex;
      }
      .tabs {
        border-top: 1px solid #565F70;
        border-radius: 0 0 6px 6px;
        display: flex;
        justify-content: flex-end;
        padding-right: 12px;
      }
      .chat {
        display: flex;
        justify-content: flex-end;
        margin: 3px;
      }
      .chat .buttons {
        display: flex;
        flex-direction: column;
        gap: 3px 0;
      }
      .normal {
        border: 1px solid #93989C;
        background: #FBFBFB;
        box-shadow: -4px -4px 4px #C0C9E0 inset;
        width: 58px;
        height: 37px;
        border-radius: 5px;
        font-family: Tahoma;
        font-weight: bold;
        font-size: 11px;
        color: #969C9A;
      }
      .normal span {
        text-decoration: underline;
      }
      .normal.small {
        height: 25px;
      }
    `;
  }

  connectedCallback() {
    this.render();
  }

  render() {
    this.shadowRoot.innerHTML = /* html */`
    <style>${MSNMessengerChat.styles}</style>
    <div class="container">
      <div class="actionbar">
        <simple-button image="letter"></simple-button>
        <simple-button image="happy" arrow></simple-button>
        <simple-button image="voice-clip" label="Voice clip"></simple-button>
        <simple-button image="wink" arrow></simple-button>
        <simple-button image="mountain" arrow></simple-button>
        <simple-button image="gift" arrow></simple-button>
        <simple-button image="nudge"></simple-button>
      </div>
      <div class="chat">
        <div class="buttons">
          <button class="normal"><span>S</span>end</button>
          <button class="small normal">Sea<span>r</span>ch</button>
        </div>
      </div>
      <div class="tabs">
        <tab-button image="paint"></tab-button>
        <tab-button image="letter" focus></tab-button>
      </div>
    </div>`;
  }
}

customElements.define("msn-messenger-chat", MSNMessengerChat);

class MSNMessengerHistoryChat extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: "open" });
  }

  static get styles() {
    return /* css */`
      .container {
        display: grid;
        justify-content: center;
        grid-template-columns: 1fr;
        grid-template-rows: 28px 1fr;
        font-family: Verdana;
        font-size: 10px;
        width: 97%;
        height: 100%;
        border: 1px solid #586170;
        border-radius: 8px 8px 0 0;
        margin: 2px 1px;
      }
      .subject {
        border-radius: 8px 8px 0 0;
        background: #EEF0FD;
        display: flex;
        align-items: center;
        padding-left: 6px;
        border-bottom: 1px solid #586170;
      }
      .subject strong {
        padding-left: 3px;
      }
      .history {
        background: #fff;
      }
    `;
  }

  connectedCallback() {
    this.render();
  }

  render() {
    this.shadowRoot.innerHTML = /* html */`
    <style>${MSNMessengerHistoryChat.styles}</style>
    <div class="container">
      <div class="subject">To: <strong>ManzDev (esemanztodoxulo@hotmail.com)</strong></div>
      <div class="history"></div>
    </div>`;
  }
}

customElements.define("msn-messenger-history-chat", MSNMessengerHistoryChat);

class MSNMessengerLocalUser extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: "open" });
  }

  static get styles() {
    return /* css */`
    .container {
      width: 100%;
      height: 100%;
      display: grid;
      grid-template-columns: 1fr 140px;
      margin: 4px 8px;
    }
    `;
  }

  connectedCallback() {
    this.render();
  }

  render() {
    this.shadowRoot.innerHTML = /* html */`
    <style>${MSNMessengerLocalUser.styles}</style>
    <div class="container">
      <msn-messenger-chat></msn-messenger-chat>
      <msn-messenger-avatar image="duck"></msn-messenger-avatar>
    </div>`;
  }
}

customElements.define("msn-messenger-local-user", MSNMessengerLocalUser);

class MSNMessengerRemoteUser extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: "open" });
  }

  static get styles() {
    return /* css */`
    .container {
      width: 100%;
      height: 92%;
      display: grid;
      grid-template-columns: 1fr 140px;
      margin: 4px 8px;
    }
    `;
  }

  connectedCallback() {
    this.render();
  }

  render() {
    this.shadowRoot.innerHTML = /* html */`
    <style>${MSNMessengerRemoteUser.styles}</style>
    <div class="container">
      <msn-messenger-history-chat></msn-messenger-history-chat>
      <msn-messenger-avatar image="msn"></msn-messenger-avatar>
    </div>`;
  }
}

customElements.define("msn-messenger-remote-user", MSNMessengerRemoteUser);

class MSNMessengerStatusbar extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: "open" });
  }

  static get styles() {
    return `
      .container {
        width: 100%;
        height: 14px;
        border-radius: 0 0 var(--border-radius) var(--border-radius);
        border-top: 1px solid #505E67;
        background: #FDFDFF;
        position: relative;
        display: flex;
        align-items: center;
        padding-left: 8px;
      }

      .text {
        font-family: Verdana;
        font-size: 10px;
        font-weight: bold;
        color: navy;
      }

      .text a {
        color: black;
      }

      .text a:hover {
        color: darkred;
      }
    `;
  }

  connectedCallback() {
    this.render();
  }

  render() {
    this.shadowRoot.innerHTML = `
    <style>${MSNMessengerStatusbar.styles}</style>
    <div class="container">
      <div class="text">More content on <a href="https://manz.dev/">https://manz.dev/</a> and <a href="https://twitch.tv/ManzDev">Twitch</a>!</div>
    </div>`;
  }
}

customElements.define("msn-messenger-statusbar", MSNMessengerStatusbar);

class MSNMessengerToolbar extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: "open" });
  }

  static get styles() {
    return `
      .container {
        width: 100%;
        height: 100%;
        border-radius: var(--border-radius) var(--border-radius) 0 0;
        display: grid;
        grid-template-columns: 310px 1fr;
        position: relative;
      }
      .toolbar-container {
        display: grid;
        grid-template-columns: 40px 56px 44px 40px 54px 44px;
        justify-content: flex-end;
        align-items: center;
        background: url(ui/toolbar-background.png) repeat;
        background-size: contain;
      }
      .toolbar-small-container {
        display: grid;
        grid-template-columns: 50px 50px 37px 28px;
        height: 100%;
      }
      .toolbar-small-container .left {
        background: url(ui/small-toolbar-left-background.png) no-repeat;
      }
      .toolbar-small-container .center {
        background:
          url(ui/msn-logo.png) top left 4px,
          url(ui/small-toolbar-center-background.png);
        background-repeat: no-repeat, repeat-x;
      }
      .toolbar-small-container .right {
        background: url(ui/small-toolbar-right-background.png) no-repeat;
      }
      .toolbar-small-container .end {
        background: url(ui/small-toolbar-end-background.png) repeat;
      }
      .center .buttons {
        display: flex;
        gap: 0 4px;
        transform: translate(2px, 23px);
      }
      .center image-circular-button {
        --size: 19px;
        --image-size: 13px;
      }
      .up-down {
        --image-size: 15px;
        position: absolute;
        top: 2px;
        left: 2px;
      }
    `;
  }

  connectedCallback() {
    this.render();
  }

  render() {
    this.shadowRoot.innerHTML = `
    <style>${MSNMessengerToolbar.styles}</style>
    <div class="container">
      <div class="toolbar-container">
        <image-circular-button class="up-down" image="up-down"></image-circular-button>
        <image-button image="invite" text="Invite" bind="I"></image-button>
        <image-button image="send" text="Send Files" bind="l"></image-button>
        <image-button image="video" text="Video" bind="o"></image-button>
        <image-button image="voice" text="Voice" bind="c"></image-button>
        <image-button image="activities" text="Activities" bind="v"></image-button>
        <image-button image="games" text="Games" bind="G"></image-button>
      </div>
      <div class="toolbar-small-container">
        <div class="left"></div>
        <div class="center">
          <div class="buttons">
            <image-circular-button image="block"></image-circular-button>
            <image-circular-button image="paint"></image-circular-button>
          </div>
        </div>
        <div class="right"></div>
        <div class="end"></div>
      </div>
    </div>`;
  }
}

customElements.define("msn-messenger-toolbar", MSNMessengerToolbar);

class ImageCircularButton extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: "open" });
  }

  static get styles() {
    return `
      .container {
        width: var(--size, 16px);
        height: var(--size, 16px);
        display: flex;
        justify-content: center;
        align-items: center;
        background: url(ui/small-circle-button.png) no-repeat;
        background-size: cover;
      }
      .container img {
        width: var(--image-size, 11px);
        height: var(--image-size, 11px);
      }
    `;
  }

  connectedCallback() {
    this.text = this.getAttribute("image") ?? "notext";
    this.image = "toolbar/small-" + this.text + ".png";
    this.render();
  }

  render() {
    this.shadowRoot.innerHTML = `
    <style>${ImageCircularButton.styles}</style>
    <div class="container">
      <img src="${this.image}" alt="${this.text}">
    </div>`;
  }
}

customElements.define("image-circular-button", ImageCircularButton);

class MSNMessengerWindow extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: "open" });
  }

  static get styles() {
    return /* css */`
      :host {
        --width: 475px;
        --height: 400px;
        --border-radius: 6px;
      }
      .container {
        width: var(--width);
        height: var(--height);
        background: #D7E4F5 url(ui/main-background.png) bottom 20px right no-repeat;
        display: grid;
        grid-template-rows: 60px 1fr 140px 24px;
        border-radius: var(--border-radius);
        overflow: hidden;
        box-shadow:
          2px 2px 5px #0009,
          5px 5px 10px #000c;
        position: relative;
        transform: translate(var(--x, 0), var(--y, 0));
      }
      .border-window {
          position: absolute;
          bottom: 0;
          left: 0;
          width: 100%;
          height: 100%;
          background-image:
            url(ui/main-corner-left.png),
            url(ui/main-corner-right.png),
            url(ui/main-left.png),
            url(ui/main-right.png),
            url(ui/main-bottom.png);
          background-repeat: no-repeat, no-repeat, repeat-y, repeat-y, repeat-x;
          background-position: bottom left, bottom -1px right, bottom left, bottom right, bottom;
          clip-path: polygon(0 14.5%, 100% 5%, 100% 100%, 0 100%);
          pointer-events: none;
      }
    `;
  }

  move() {
    const x = -4 + ~~(Math.random() * 8);
    const y = -4 + ~~(Math.random() * 8);
    this.style.setProperty("--x", `${x}px`);
    this.style.setProperty("--y", `${y}px`);
  }

  nudge() {
    const times = [50, 100, 150, 200, 250, 350, 400, 450, 500, 550, 600, 650, 700, 750];

    const nudge = (delay = 0) => {
      setTimeout(() => {
        nudgeSound.currentTime = 0;
        nudgeSound.play();
        times.forEach(time => setTimeout(() => this.move(), time));
      }, delay);
    };

    nudge();
    nudge(1000);
  }

  connectedCallback() {
    this.render();
    this.addEventListener("nudge", () => this.nudge());
  }

  render() {
    this.shadowRoot.innerHTML = `
    <style>${MSNMessengerWindow.styles}</style>
    <div class="container">
      <msn-messenger-toolbar></msn-messenger-toolbar>
      <msn-messenger-remote-user></msn-messenger-remote-user>
      <msn-messenger-local-user></msn-messenger-local-user>
      <msn-messenger-statusbar></msn-messenger-statusbar>
      <div class="border-window"></div>
    </div>`;
  }
}

customElements.define("msn-messenger-window", MSNMessengerWindow);
              
            
!
999px

Console