Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Feature/410 gradient support #508

Merged
merged 3 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion components/blocks/Gutenberg/BlockButton/BlockButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import PropTypes from 'prop-types'
* @param {string} props.backgroundColorHex The background color hex value.
* @param {number} props.borderRadius The border radius in pixels.
* @param {string} props.className Optional classnames.
* @param {string} props.gradientHex The background gradient hex value.
* @param {string} props.linkTarget The target for the link.
* @param {string} props.rel The rel attribute for the link.
* @param {object} props.style The style attributes.
Expand All @@ -26,6 +27,7 @@ export default function BlockButton({
backgroundColorHex,
borderRadius,
className,
gradientHex,
linkTarget,
rel,
style,
Expand All @@ -38,10 +40,11 @@ export default function BlockButton({
const backgroundcolor =
backgroundColorHex || style?.color?.background || 'inherit'
const textcolor = textColorHex || style?.color?.text || 'inherit'
const background = gradientHex || style?.color?.gradient || 'inherit'

// Create style object for button.
const buttonStyle = {
background: style?.color?.gradient || 'inherit',
background: background,
backgroundColor: backgroundcolor,
borderRadius: `${borderRadius}px`,
color: textcolor,
Expand Down Expand Up @@ -77,6 +80,7 @@ BlockButton.propTypes = {
backgroundColorHex: PropTypes.string,
borderRadius: PropTypes.number,
className: PropTypes.string,
gradientHex: PropTypes.string,
linkTarget: PropTypes.string,
rel: PropTypes.string,
style: PropTypes.object,
Expand Down
7 changes: 7 additions & 0 deletions components/blocks/Gutenberg/BlockCode/BlockCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import PropTypes from 'prop-types'
* @param {string} props.backgroundColorHex The background color hex value.
* @param {string} props.className Optional classnames.
* @param {string} props.content The content of the block.
* @param {string} props.gradientHex The background gradient hex value.
* @param {object} props.style The style attributes (Typography panel).
* @param {string} props.textColorHex The text color hex value.
* @return {Element} The Code component.
Expand All @@ -21,13 +22,15 @@ export default function BlockCode({
backgroundColorHex,
className,
content,
gradientHex,
style,
textColorHex
}) {
// Determine background and text colors, and font size, using stylelint-accepted const names.
const backgroundcolor = backgroundColorHex || style?.color?.background
const textcolor = textColorHex || style?.color?.text
const fontsize = style?.typography?.fontSize
const background = gradientHex || style?.color?.gradient

// Create style object for code.
const codeStyle = {}
Expand All @@ -46,6 +49,9 @@ export default function BlockCode({
if (fontsize) {
codeStyle.fontSize = fontsize
}
if (background) {
codeStyle.background = background
}

return (
<Code
Expand All @@ -62,6 +68,7 @@ BlockCode.propTypes = {
backgroundColorHex: PropTypes.string,
content: PropTypes.string,
className: PropTypes.string,
gradientHex: PropTypes.string,
style: PropTypes.object,
textColorHex: PropTypes.string
}