How to use the @wordpress/editor.getColorClassName function in @wordpress/editor

To help you get started, we’ve selected a few @wordpress/editor 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 TomodomoCo / gutenberg-block-columns / src / block / renderer.js View on Github external
const Renderer = (props) => {
  const {
    className,
    attributes: {
      columns,
      backgroundColor,
      textColor,
    },
  } = props

  const classes = classnames(
    className,
    'gridlex',
    `has-${columns.length}-columns`,
    getColorClassName('background', backgroundColor),
    getColorClassName('text', textColor),
  )

  // UI
  return (
    <div>
      
    </div>
  )
}
github TomodomoCo / gutenberg-block-columns / src / block / renderer.js View on Github external
const Renderer = (props) =&gt; {
  const {
    className,
    attributes: {
      columns,
      backgroundColor,
      textColor,
    },
  } = props

  const classes = classnames(
    className,
    'gridlex',
    `has-${columns.length}-columns`,
    getColorClassName('background', backgroundColor),
    getColorClassName('text', textColor),
  )

  // UI
  return (
    <div>
      
    </div>
  )
}
github front / gutenberg-js / src / js / gutenberg-overrides / @wordpress / block-library / build-module / cover / index.js View on Github external
save ({ attributes }) {
    const {
      align,
      backgroundType,
      contentAlign,
      customOverlayColor,
      dimRatio,
      hasParallax,
      overlayColor,
      title,
      url,
      // GUTENBERG JS
      data,
    } = attributes;
    const overlayColorClass = getColorClassName('background-color', overlayColor);
    const style = backgroundType === IMAGE_BACKGROUND_TYPE ?
      backgroundImageStyles(url) :
      {};
    if (! overlayColorClass) {
      style.backgroundColor = customOverlayColor;
    }

    const classes = classnames(
      dimRatioToClass(dimRatio),
      overlayColorClass,
      {
        'has-background-dim': dimRatio !== 0,
        'has-parallax': hasParallax,
        [ `has-${contentAlign}-content` ]: contentAlign !== 'center',
      },
      align ? `align${align}` : null,
github front / gutenberg-js / src / js / gutenberg-overrides / @wordpress / block-library / build-module / media-text / index.js View on Github external
customBackgroundColor,
      isStackedOnMobile,
      mediaAlt,
      mediaPosition,
      mediaType,
      mediaUrl,
      mediaWidth,
      // Gutenberg JS
      mediaData,
    } = attributes;
    const mediaTypeRenders = {
      image: () =&gt; <img alt="{" src="{">,
      video: () =&gt; <video src="{" controls="">,
    };

    const backgroundClass = getColorClassName('background-color', backgroundColor);
    const className = classnames({
      'has-media-on-the-right': 'right' === mediaPosition,
      [ backgroundClass ]: backgroundClass,
      'is-stacked-on-mobile': isStackedOnMobile,
    });

    let gridTemplateColumns;
    if (mediaWidth !== DEFAULT_MEDIA_WIDTH) {
      gridTemplateColumns = 'right' === mediaPosition ? `auto ${mediaWidth}%` : `${mediaWidth}% auto`;
    }
    const style = {
      backgroundColor: backgroundClass ? undefined : customBackgroundColor,
      gridTemplateColumns,
    };
    return (
      <div style="{"></div></video>
github TomodomoCo / gutenberg-block-columns / src / block / editor.js View on Github external
const Editor = withColors('backgroundColor', 'textColor')((props) =&gt; {
  // Variables
  const {
    attributes: {
      columns,
      backgroundColor,
      textColor,
    },
    className,
  } = props

  const classes = classnames(
    className,
    `has-${columns.length}-columns`,
    getColorClassName('background', backgroundColor),
    getColorClassName('text', textColor),
  )

  // UI for columns without any columns
  if (columns.length === 0 &amp;&amp; sum(columns) &lt; 1) {
    return (
      
        
        
      
    )
github TomodomoCo / gutenberg-block-columns / src / block / editor.js View on Github external
const Editor = withColors('backgroundColor', 'textColor')((props) =&gt; {
  // Variables
  const {
    attributes: {
      columns,
      backgroundColor,
      textColor,
    },
    className,
  } = props

  const classes = classnames(
    className,
    `has-${columns.length}-columns`,
    getColorClassName('background', backgroundColor),
    getColorClassName('text', textColor),
  )

  // UI for columns without any columns
  if (columns.length === 0 &amp;&amp; sum(columns) &lt; 1) {
    return (
      
        
        
      
    )
  }
github WordPress / gutenberg / packages / block-library / src / container / index.js View on Github external
save( { attributes } ) {
		const { backgroundColor, customBackgroundColor } = attributes;

		const backgroundClass = getColorClassName( 'background-color', backgroundColor );
		const className = classnames( backgroundClass, {
			'has-background': backgroundColor || customBackgroundColor,
		} );

		const styles = {
			backgroundColor: backgroundClass ? undefined : customBackgroundColor,
		};

		return (
			<div style="{">
				
			</div>
		);
	},
};
github front / gutenberg-js / src / js / gutenberg-overrides / @wordpress / block-library / build-module / cover / index.js View on Github external
save ({ attributes }) {
      const { url, title, hasParallax, dimRatio, align, contentAlign, overlayColor, customOverlayColor } = attributes;
      const overlayColorClass = getColorClassName('background-color', overlayColor);
      const style = backgroundImageStyles(url);
      if (! overlayColorClass) {
        style.backgroundColor = customOverlayColor;
      }

      const classes = classnames(
        'wp-block-cover-image',
        dimRatioToClass(dimRatio),
        overlayColorClass,
        {
          'has-background-dim': dimRatio !== 0,
          'has-parallax': hasParallax,
          [ `has-${contentAlign}-content` ]: contentAlign !== 'center',
        },
        align ? `align${align}` : null,
      );