justinribeiro / lite-youtube

The fastest little YouTube web component on this side of the internet. The shadow dom web component version of Paul's lite-youtube-embed.
https://www.npmjs.com/package/@justinribeiro/lite-youtube
MIT License
836 stars 63 forks source link

Use official YouTube logo #80

Closed neilitalia closed 1 year ago

neilitalia commented 1 year ago

Would it be possible to use the official YouTube logo for the previews?

By default this is how it looks:

image

I'm currently using this with vanilla js and as a quick hack, I took some styling from Paul Irish's lite-youtube and appended these styles into the shadow dom

const liteYoutube = document.querySelector("lite-youtube")
styleEmbed(liteYoutube)

function styleEmbed(embed) {
  const style = document.createElement("style")
  style.textContent = /*css*/`
    #playButton {
      display: block;
      width: 68px;
      height: 48px;
      position: absolute;
      cursor: pointer;
      transform: translate3d(-50%, -50%, 0);
      top: 50%;
      left: 50%;
      z-index: 1;
      background-color: transparent;
      background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 68 48"><path d="M66.52 7.74c-.78-2.93-2.49-5.41-5.42-6.19C55.79.13 34 0 34 0S12.21.13 6.9 1.55c-2.93.78-4.63 3.26-5.42 6.19C.06 13.05 0 24 0 24s.06 10.95 1.48 16.26c.78 2.93 2.49 5.41 5.42 6.19C12.21 47.87 34 48 34 48s21.79-.13 27.1-1.55c2.93-.78 4.64-3.26 5.42-6.19C67.94 34.95 68 24 68 24s-.06-10.95-1.48-16.26z" fill="red"/><path d="M45 24 27 14v20" fill="white"/></svg>');
      filter: grayscale(100%);
      transition: filter .1s cubic-bezier(0, 0, 0.2, 1);
      border: none;
      border-radius: inherit;
    }
    #frame:hover > #playButton,
    lite-youtube #playButton:focus {
      background-color: transparent;
      filter: none;
      border-radius: inherit;
    }
  `
  embed.shadowRoot.appendChild(style)
}

Resulting in a little bit of a nicer preview

image

I think it would look great like this out-of-the-box. I could start a PR if this sounds good.

justinribeiro commented 1 year ago

Sure, we can swap it out. If you'd like to open a PR on that, have at it. If not, I'll get it into the release I'm working on for later in the week.