UNPKG

shine-on-hover

Version:

Lightweight, zero-dependency library for adding a mouse-tracking shine effect.

4 lines (3 loc) 1.4 kB
export declare const SHINE_STYLES = "\n.shine-effect {\n --shine-x: 0%;\n --shine-y: 0%;\n --shine-from: 0%;\n --shine-to: 0%;\n --shine-border: transparent;\n\n isolation: isolate;\n position: relative;\n overflow: hidden;\n\n &::before {\n pointer-events: none;\n content: '';\n\n position: absolute;\n z-index: 1;\n inset: 1px;\n border-radius: inherit; \n\n opacity: 0;\n background: radial-gradient(\n circle at var(--shine-x) var(--shine-y),\n var(--shine-color) var(--shine-from),\n transparent var(--shine-to)\n );\n\n outline: 1px solid var(--shine-border);\n outline-offset: -1px;\n box-shadow: \n inset 0 0 10px calc(8px * (1 - (var(--shine-x) + var(--shine-y)) / 200)) var(--shine-border),\n 0 0 20px calc(12px * (1 - (var(--shine-x) + var(--shine-y)) / 200)) var(--shine-border);\n\n transition: \n opacity 150ms cubic-bezier(0, 0, 0.2, 1),\n box-shadow 150ms cubic-bezier(0, 0, 0.2, 1);\n }\n\n &::after {\n pointer-events: none;\n content: '';\n\n position: absolute;\n z-index: 0;\n inset: 0;\n border-radius: inherit;\n\n opacity: 0;\n transition: opacity 150ms cubic-bezier(0, 0, 0.2, 1);\n }\n\n &:hover::before,\n &:hover::after {\n opacity: 1;\n }\n}\n"; export declare function injectStyles(styles: string): void; export declare function removeStyles(): void;