How to use the css-vars-ponyfill function in css-vars-ponyfill

To help you get started, we’ve selected a few css-vars-ponyfill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adorsys / XS2A-Sandbox / oba-ui / src / app / common / services / customize.service.ts View on Github external
private updateCSS(variables: CSSVariables = {}) {
    // Use css-vars-ponyfill to polyfill css-variables for legacy browser
    cssVars({
      include: 'style',
      onlyLegacy: true,
      watch: true,
      variables,
      onComplete(cssText, styleNode, cssVariables) {
        console.log(cssText, styleNode, cssVariables);
      },
    });
    // If you decide to drop ie11, edge < 14 support in future, use this as implementation to set variables
    // Object.keys(variables).forEach(variableName => {
    //   document.documentElement.style.setProperty('--' + variableName, variables[variableName]);
    // });
  }
}
github cdapio / cdap / cdap-ui / app / cdap / services / ThemeHelper.js View on Github external
export function applyTheme() {
  if (
    !objectQuery(window, 'CDAP_UI_THEME', 'styles') ||
    !isTheme10Spec() ||
    isNilOrEmpty(window.CDAP_UI_THEME.styles)
  ) {
    // need to run this at least once even if there's no theme customization
    // so that css variables are parsed correctly even in older browsers
    cssVars();
    return;
  }

  // this is what's going on under the hood for modern browsers:
  // document.documentElement.style.setProperty(`--${cssVar}`, cssValue);
  cssVars({
    variables: window.CDAP_UI_THEME.styles
  });
}
github cdapio / cdap / cdap-ui / app / cdap / services / ThemeHelper.ts View on Github external
if ('font-family' in stylesJSON && typeof stylesJSON['font-family'] === 'string') {
      stylesToApply['font-family'] = stylesJSON['font-family'];
    }
    if ('page-name-color' in stylesJSON && isColor(stylesJSON['page-name-color'])) {
      stylesToApply['page-name-color'] = stylesJSON['page-name-color'];
    }
    if (
      'plugin-reference-heading-bg-color' in stylesJSON &&
      isColor(stylesJSON['plugin-reference-heading-bg-color'])
    ) {
      stylesToApply['plugin-reference-heading-bg-color'] =
        stylesJSON['plugin-reference-heading-bg-color'];
    }
    // this is what's going on under the hood for modern browsers:
    // document.documentElement.style.setProperty(`--${cssVar}`, cssValue);
    cssVars({
      variables: stylesToApply,
    });
  }
github cdapio / cdap / cdap-ui / app / cdap / services / ThemeHelper.ts View on Github external
}
    }
    if ('product-logo-about' in contentJson) {
      const productLogoAbout = window.CDAP_UI_THEME.content['product-logo-about'];
      if (productLogoAbout.type) {
        const productLogoAboutType = productLogoAbout.type;
        if (productLogoAboutType === 'inline') {
          content.productLogoAbout = objectQuery(productLogoAbout, 'arguments', 'data');
        } else if (productLogoAboutType === 'link') {
          content.productLogoAbout = objectQuery(productLogoAbout, 'arguments', 'url');
        }
      }
    }
    if ('welcome-banner-image' in contentJson) {
      const welcomeBannerImage = window.CDAP_UI_THEME.content['welcome-banner-image'];
      cssVars({
        variables: {
          'welcome-banner-image': `url('${welcomeBannerImage}')`,
        },
      });
    }
    if ('feature-names' in contentJson) {
      const featureNames = { ...content.featureNames };

      if ('analytics' in contentJson['feature-names']) {
        featureNames.analytics = objectQuery(contentJson, 'feature-names', 'analytics');
      }
      if ('control-center' in contentJson['feature-names']) {
        featureNames.controlCenter = objectQuery(contentJson, 'feature-names', 'control-center');
      }
      if ('dashboard' in contentJson['feature-names']) {
        featureNames.dashboard = objectQuery(contentJson, 'feature-names', 'dashboard');
github comindware / core-ui / src / services / IEService.ts View on Github external
static __addCssVariables() {
        cssVars({
            onlyLegacy: true
        });
    }
github vmware / clarity / src / clr-core / common / css-vars / css-vars.ts View on Github external
export function runCssVarsPolyfill(config: {} = cssVarsDefaultConfig): void {
  cssVars(config);
}
github mattermost / mattermost-webapp / utils / utils.jsx View on Github external
if (theme.mentionHighlightBg) {
        changeCss('.app__body .mention--highlight, .app__body .search-highlight', 'background:' + theme.mentionHighlightBg);
        changeCss('.app__body .post.post--comment .post__body.mention-comment', 'border-color:' + theme.mentionHighlightBg);
        changeCss('.app__body .post.post--highlight', 'background:' + changeOpacity(theme.mentionHighlightBg, 0.5));
    }

    if (theme.mentionHighlightLink) {
        changeCss('.app__body .mention--highlight .mention-link, .app__body .mention--highlight, .app__body .search-highlight', 'color:' + theme.mentionHighlightLink);
    }

    if (!theme.codeTheme) {
        theme.codeTheme = Constants.DEFAULT_CODE_THEME;
    }
    updateCodeTheme(theme.codeTheme);
    cssVars({
        variables: {
            'sidebar-bg': theme.sidebarBg,
            'sidebar-text': theme.sidebarText,
            'sidebar-text-60': changeOpacity(theme.sidebarText, 0.6),
            'sidebar-unread-text': theme.sidebarUnreadText,
            'sidebar-text-hover-bg': theme.sidebarTextHoverBg,
            'sidebar-text-active-border': theme.sidebarTextActiveBorder,
            'sidebar-text-active-color': theme.sidebarTextActiveColor,
            'sidebar-header-bg': theme.sidebarHeaderBg,
            'sidebar-header-text-color': theme.sidebarHeaderTextColor,
            'online-indicator': theme.onlineIndicator,
            'away-indicator': theme.awayIndicator,
            'dnd-indicator': theme.dndIndicator,
            'mention-bg': theme.mentionBg,
            'mention-color': theme.mentionColor,
            'center-channel-bg': theme.centerChannelBg,

css-vars-ponyfill

Client-side support for CSS custom properties (aka "CSS variables") in legacy and modern browsers

MIT
Latest version published 9 months ago

Package Health Score

63 / 100
Full package analysis

Popular css-vars-ponyfill functions