UNPKG

cloudinary-video-player

Version:
62 lines (57 loc) 1.9 kB
import { i as isLight } from './video-player.js'; import './_videojs-proxy.js'; import './_commonjsHelpers.js'; import './index2.js'; import './video-player.const.js'; import './cloudinary-config-from-options.js'; import './cloudinary-url-prefix.js'; import './validators-functions.js'; const defaults = { colorsDark: { 'base': '#000000', 'accent': '#0D9AFF', 'text': '#FFFFFF' }, colorsLight: { 'base': '#FFFFFF', 'accent': '#0D9AFF', 'text': '#000000' } }; const getDefaultPlayerColor = options => { return isLight(options) ? defaults.colorsLight : defaults.colorsDark; }; const colorsPlugin = function (player) { let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; const skinDefaults = getDefaultPlayerColor(player.options_); opts.colors = Object.assign({}, skinDefaults, opts.colors); // Set CSS custom properties on the player element const playerEl = player.el(); if (opts.colors.base) { playerEl.style.setProperty('--color-base', opts.colors.base); } if (opts.colors.accent) { playerEl.style.setProperty('--color-accent', opts.colors.accent); } if (opts.colors.text) { playerEl.style.setProperty('--color-text', opts.colors.text); } // Return an object with methods to update colors if needed return { updateColors: newColors => { const updatedColors = Object.assign({}, opts.colors, newColors); if (updatedColors.base) { playerEl.style.setProperty('--color-base', updatedColors.base); } if (updatedColors.accent) { playerEl.style.setProperty('--color-accent', updatedColors.accent); } if (updatedColors.text) { playerEl.style.setProperty('--color-text', updatedColors.text); } opts.colors = updatedColors; }, getColors: () => opts.colors }; }; export { colorsPlugin as default, getDefaultPlayerColor };