UNPKG

lazy-youtube-player

Version:

A lightweight, customizable YouTube player component with lazy loading capabilities

138 lines (124 loc) 2.49 kB
/* Lazy YouTube */ .NexosYt { position: relative; overflow: hidden; height: 0; padding-top: 56.25%; /* Aspect ratio 16:9 */ border-radius: 6px; border: 2px solid hsla(340, 100%, 50%, 0.9); background-color: #000; } .NexYt-thumbnail { width: 100%; height: auto; position: absolute; top: -16.84%; left: 0; border-radius: 6px; opacity: 0.9; transition: opacity 0.3s ease; } .NexYt-thumbnail:hover { opacity: 1; } .NexYt-iframe { width: 100%; height: 100%; position: absolute; inset: 0; border: none; border-radius: 6px; } .NexYt-play-btn { position: absolute; top: 50%; left: 50%; transform: translate3d(-50%, -50%, 0); transition: all 0.5s ease; display: block; width: 70px; height: 70px; z-index: 1; cursor: pointer; } .NexYt-play-btn svg { width: inherit; height: inherit; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 10; stroke-width: 10; } .NexYt-play-btn .c { stroke: hsla(340, 100%, 50%, 0.9); stroke-dasharray: 650; stroke-dashoffset: 650; transition: all 0.4s ease-in-out; opacity: 0.6; } .NexYt-play-btn:hover .c { stroke-dashoffset: 0; opacity: 0.9; stroke: hsla(340, 100%, 50%, 1); } .NexYt-play-btn .t { stroke: hsla(340, 100%, 50%, 0.95); stroke-dasharray: 240; stroke-dashoffset: 480; transition: all 0.6s ease-in-out; opacity: 0.8; transform: translateY(0); } .NexYt-play-btn:hover .t { animation: nudge 0.6s ease-in-out; stroke-dashoffset: 0; opacity: 1; stroke: hsla(340, 100%, 50%, 1); } @keyframes nudge { 0% { transform: translateX(0); } 30% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 70% { transform: translateX(-2px); } 100% { transform: translateX(0); } } /* Spinner */ .NexosYt .NexYt-spinner { position: absolute; top: 50%; left: 50%; transform: translate3d(-50%, -50%, 0); border: 4px solid hsla(340, 100%, 50%, 0.3); border-top: 4px solid #000; border-radius: 50%; display: block; width: 70px; height: 70px; animation: spin 1s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } /* Responsive adjustments */ @media (max-width: 768px) { .NexosYt .NexYt-spinner { width: 48px; height: 48px; } }