diff --git a/packages/gatsby-theme-patternfly-org/index.js b/packages/gatsby-theme-patternfly-org/index.js index baa178a5ca..01b09333c7 100644 --- a/packages/gatsby-theme-patternfly-org/index.js +++ b/packages/gatsby-theme-patternfly-org/index.js @@ -16,6 +16,7 @@ exports.mdxTypeDefs = ` coreComponentName: String showTitle: Boolean releaseNoteTOC: Boolean + hideSource: Boolean } type MdxFields @dontInfer { slug: String! diff --git a/packages/gatsby-theme-patternfly-org/templates/mdx.js b/packages/gatsby-theme-patternfly-org/templates/mdx.js index 31469a9242..6348bc6dba 100644 --- a/packages/gatsby-theme-patternfly-org/templates/mdx.js +++ b/packages/gatsby-theme-patternfly-org/templates/mdx.js @@ -40,7 +40,7 @@ const MDXTemplate = ({ data, location, pageContext }) => { katacodaId={location.state.katacodaId} /> ); } - const { cssPrefix, hideTOC, beta, optIn, hideDarkMode, showTitle, releaseNoteTOC } = data.doc.frontmatter; + const { cssPrefix, hideTOC, beta, optIn, hideDarkMode, showTitle, releaseNoteTOC, hideSource } = data.doc.frontmatter; const { componentName, navSection } = data.doc.fields; const { title, source, tableOfContents, htmlExamples, propComponents = [''], showBanner, showGdprBanner, sourceLink } = pageContext; const props = data.props && data.props.nodes && propComponents @@ -88,9 +88,11 @@ const MDXTemplate = ({ data, location, pageContext }) => { )} {!hideTOC && ( - + {!hideSource && ( + + )} {title} {optIn && ( .ws-color-family-label { + display: inline-block; + font-size: var(--pf-global--FontSize--sm); + font-weight: bold; + margin-top: var(--pf-global--spacer--md); + margin-bottom: var(--pf-global--spacer--sm); +} + +/* Specificity YAY */ +.ws-color-family-toggle.pf-c-accordion__toggle::before, +.ws-color-family-accordion-toggle.pf-c-accordion__toggle::before { + content: none; + width: 0; +} \ No newline at end of file diff --git a/packages/v4/src/content/design-guidelines/styles/colors/ColorFamily.js b/packages/v4/src/content/design-guidelines/styles/colors/ColorFamily.js new file mode 100644 index 0000000000..d518cbd121 --- /dev/null +++ b/packages/v4/src/content/design-guidelines/styles/colors/ColorFamily.js @@ -0,0 +1,123 @@ +import React from 'react'; +import tokens from '@patternfly/react-tokens/dist/variables/esm/patternfly_variables'; +import AngleRightIcon from '@patternfly/react-icons/dist/js/icons/angle-right-icon'; +import { css } from '@patternfly/react-styles'; +import { normalizeColor, getContrastRatio } from './helpers'; +import './ColorFamily.css'; + +const palettePrefix = '--pf-global--palette--'; + +export function ColorFamily({ + title, + family +}) { + const [expanded, setExpanded] = React.useState([]); + + const familyTokens = family === 'shadows' + ? tokens[':root'].filter(token => /--pf-global--BoxShadow--(sm|md|lg)$/.test(token.property)) + : tokens[':root'].filter(token => token.property.includes(`${palettePrefix}${family}`)); + if (family === 'black') { + const whiteToken = tokens[':root'].find(token => token.property === '--pf-global--palette--white'); + familyTokens.unshift(whiteToken); + } + + const expandAll = () => { + if (expanded.length > 0) { + setExpanded([]); + } else { + setExpanded(familyTokens.map(token => token.property)); + } + }; + + const expand = name => { + if (expanded.includes(name)) { + setExpanded(expanded.filter(token => token !== name)); + } else { + setExpanded(expanded.concat(name)); + } + }; + + return ( + +
+
+

+ + {title} +

+
+ {familyTokens.map(token => { + const isExpanded = expanded.includes(token.property); + const isShadows = family === 'shadows'; + const tokenClass = css( + 'pf-c-accordion__toggle', + 'ws-color-family-toggle', + isExpanded && 'pf-m-expanded' + ); + const itemStyle = { background: `var(${token.property})`, fontSize: 'var(--pf-global--FontSize--sm)' }; + if (isShadows) { + itemStyle.marginBottom = '1rem'; + itemStyle.boxShadow = `var(${token.property})`; + } + else if (getContrastRatio(token.value, '#151515') <= 4.5) { + itemStyle.color = '#fafafa'; + } + const expandedStyle = {}; + if (isExpanded && !isShadows) { + const borderLeftWidth = 'var(--pf-c-accordion__toggle--m-expanded--BorderWidth)'; + const borderColor = `var(${token.property})`; + const borderStyle = 'solid'; + itemStyle.borderLeftWidth = borderLeftWidth; + itemStyle.borderColor = borderColor; + itemStyle.borderStyle = borderStyle; + expandedStyle.borderLeftWidth = borderLeftWidth; + expandedStyle.borderColor = borderColor; + expandedStyle.borderStyle = borderStyle; + } + + return ( + +
expand(token.property)} + id={!isShadows ? token.value.replace('#', 'color-') : token.property.replace('--pf-global--BoxShadow--', '')} + > +
+ + {token.property + .replace(palettePrefix, '') + .replace('--pf-global--BoxShadow--', 'box shadow ')} +
+ {!isShadows && ( +
+ #{normalizeColor(token.value.toUpperCase())} +
+ )} +
+ {isExpanded && ( +
+ + {tokens[':root'] + .filter(t => t.value === token.value) + .map(t => t.property) + .sort() + .map(tokenName => +
{tokenName}
+ )} +
+ )} +
+ ); + })} +
+
+ ); +} \ No newline at end of file diff --git a/packages/v4/src/content/design-guidelines/styles/colors/ColorSwatch.css b/packages/v4/src/content/design-guidelines/styles/colors/ColorSwatch.css new file mode 100644 index 0000000000..c2e98aab86 --- /dev/null +++ b/packages/v4/src/content/design-guidelines/styles/colors/ColorSwatch.css @@ -0,0 +1,52 @@ +.ws-color-swatch { + display: flex; + margin-top: var(--pf-global--spacer--md); +} + +.ws-color-swatch > svg { + flex: 0 0 44px; + margin-right: var(--pf-global--spacer--md); + border-radius: 50%; +} + +.ws-color-swatch > svg:hover { + cursor: pointer; + box-shadow: var(--pf-global--BoxShadow--lg); + /* box-shadow: 0 0 0 0.0625rem rgba(3, 3, 3, 0.05), 0 0.25rem 0.5rem 0.25rem rgba(3, 3, 3, 0.06); */ +} + +.ws-color-swatch-description { + display: flex; + flex-direction: column; + align-content: space-between; +} + +.ws-color-swatch-description-label { + font-size: var(--pf-global--FontSize--xs); + font-weight: bold; +} + +.ws-color-swatch-description-code { + display: inline-block; + font-size: var(--pf-global--FontSize--xs); + padding-left: var(--pf-global--spacer--sm); + padding-right: var(--pf-global--spacer--sm); + border: 2px solid #d1d1d1; + background: var(--pf-global--palette--black-150); +} + +.ws-color-swatch-popover { + font-size: var(--pf-global--FontSize--sm); +} + +.ws-color-swatch-popover-label { + display: inline-block; + padding-top: var(--pf-global--spacer--md); + padding-bottom: var(--pf-global--spacer--xs); + font-weight: bold; +} + +.ws-color-swatch-popover-code { + white-space: nowrap; + margin-bottom: var(--pf-global--spacer--md); +} \ No newline at end of file diff --git a/packages/v4/src/content/design-guidelines/styles/colors/ColorSwatch.js b/packages/v4/src/content/design-guidelines/styles/colors/ColorSwatch.js new file mode 100644 index 0000000000..77fa30dc51 --- /dev/null +++ b/packages/v4/src/content/design-guidelines/styles/colors/ColorSwatch.js @@ -0,0 +1,84 @@ +import React from 'react'; +import tokens from '@patternfly/react-tokens/dist/variables/esm/patternfly_variables'; +import { Popover } from '@patternfly/react-core'; +import { normalizeColor } from './helpers'; +import './ColorSwatch.css'; + +const handSVG = ( + + + + + + + + + + + + + +); + +export function ColorSwatch({ + label, + color, + caption, + children +}) { + const isBoxShadow = color.includes('BoxShadow'); + const token = tokens[":root"].find(token => token.property === color); + const popoverContent = ( +
+ + + {color} + +

+ + See all global CSS color variables + +

+ {token && ( + + +

+ {isBoxShadow ? token.value : `#${normalizeColor(token.value)}`} +

+
+ )} + +

{children}

+
+ ); + + return ( +
+ + + + {label === 'Hover' && handSVG} + + +
+ + + {color} + +
+
+ ); +} \ No newline at end of file diff --git a/packages/v4/src/content/design-guidelines/styles/colors/colors.css b/packages/v4/src/content/design-guidelines/styles/colors/colors.css index 580e5073fe..ec757f123d 100644 --- a/packages/v4/src/content/design-guidelines/styles/colors/colors.css +++ b/packages/v4/src/content/design-guidelines/styles/colors/colors.css @@ -1,948 +1,8 @@ -.colors-in-context { - padding: 16px 32px; - background-color: #fff; +.ws-colors-gridtext { + max-width: 680px; } -.colors-theme--light h3, .colors-theme--light p { - margin-bottom: var(--pf-global--spacer--sm); -} -.colors-theme--light .pf-c-alert__title { - margin: 0 !important; - font-size: var(--pf-c-alert__title--FontSize) !important; -} - -.colors-theme--color-primary-100 { - height: 65px; - width: 65px; - background-color: var(--pf-global--primary-color--100); -} -@media screen and (min-width: 768px) { - .colors-theme--color-primary-100 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-primary-100 { - height: 100px; - width: 100px; - } -} -.colors-theme--color-primary-200 { - height: 65px; - width: 65px; - background-color: var(--pf-global--primary-color--200); -} -@media screen and (min-width: 768px) { - .colors-theme--color-primary-200 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-primary-200 { - height: 100px; - width: 100px; - } -} - -.colors-theme--color-secondary-100 { - height: 65px; - width: 65px; - background-color: var(--pf-global--secondary-color--100); -} -@media screen and (min-width: 768px) { - .colors-theme--color-secondary-100 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-secondary-100 { - height: 100px; - width: 100px; - } -} - -.colors-theme--color-text-100 { - height: 65px; - width: 65px; - background-color: var(--pf-global--Color--100); -} -@media screen and (min-width: 768px) { - .colors-theme--color-text-100 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-text-100 { - height: 100px; - width: 100px; - } -} -.colors-theme--color-text-200 { - height: 65px; - width: 65px; - background-color: var(--pf-global--Color--200); -} -@media screen and (min-width: 768px) { - .colors-theme--color-text-200 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-text-200 { - height: 100px; - width: 100px; - } -} -.colors-theme--color-text-300 { - height: 65px; - width: 65px; - background-color: var(--pf-global--Color--300); -} -@media screen and (min-width: 768px) { - .colors-theme--color-text-300 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-text-300 { - height: 100px; - width: 100px; - } -} -.colors-theme--color-link-text { - height: 65px; - width: 65px; - background-color: var(--pf-global--primary-color--100); -} -@media screen and (min-width: 768px) { - .colors-theme--color-link-text { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-link-text { - height: 100px; - width: 100px; - } -} -.colors-theme--color-link-hover { - height: 65px; - width: 65px; - background-color: var(--pf-global--primary-color--200); -} -@media screen and (min-width: 768px) { - .colors-theme--color-link-hover { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-link-hover { - height: 100px; - width: 100px; - } -} -.colors-theme--color-icons { - height: 65px; - width: 65px; - background-color: var(--pf-global--icon--Color--light); -} -@media screen and (min-width: 768px) { - .colors-theme--color-icons { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-icons { - height: 100px; - width: 100px; - } -} -.colors-theme--color-alerts--success { - height: 65px; - width: 65px; - background-color: var(--pf-global--success-color--100); -} -@media screen and (min-width: 768px) { - .colors-theme--color-alerts--success { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-alerts--success { - height: 100px; - width: 100px; - } -} -.colors-theme--color-alerts--success-icon { - height: 65px; - width: 65px; - background-color: var(--pf-global--success-color--200); -} -@media screen and (min-width: 768px) { - .colors-theme--color-alerts--success-icon { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-alerts--success-icon { - height: 100px; - width: 100px; - } -} -.colors-theme--color-alerts--info { - height: 65px; - width: 65px; - background-color: var(--pf-global--info-color--100); -} -@media screen and (min-width: 768px) { - .colors-theme--color-alerts--info { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-alerts--info { - height: 100px; - width: 100px; - } -} -.colors-theme--color-alerts--info-icon { - height: 65px; - width: 65px; - background-color: var(--pf-global--info-color--200); -} -@media screen and (min-width: 768px) { - .colors-theme--color-alerts--info-icon { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-alerts--info-icon { - height: 100px; - width: 100px; - } -} -.colors-theme--color-alerts--warning { - height: 65px; - width: 65px; - background-color: var(--pf-global--warning-color--100); -} -@media screen and (min-width: 768px) { - .colors-theme--color-alerts--warning { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-alerts--warning { - height: 100px; - width: 100px; - } -} -.colors-theme--color-alerts--warning-icon { - height: 65px; - width: 65px; - background-color: var(--pf-global--warning-color--200); -} -@media screen and (min-width: 768px) { - .colors-theme--color-alerts--warning-icon { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-alerts--warning-icon { - height: 100px; - width: 100px; - } -} -.colors-theme--color-alerts--danger { - height: 65px; - width: 65px; - background-color: var(--pf-global--danger-color--100); -} -@media screen and (min-width: 768px) { - .colors-theme--color-alerts--danger { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-alerts--danger { - height: 100px; - width: 100px; - } -} -.colors-theme--color-alerts--danger-icon { - height: 65px; - width: 65px; - background-color: var(--pf-global--danger-color--300); -} -@media screen and (min-width: 768px) { - .colors-theme--color-alerts--danger-icon { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .colors-theme--color-alerts--danger-icon { - height: 100px; - width: 100px; - } -} - -/* -** Gallery styles -*/ -.chart-colors-gallery--blue-1 { - height: 65px; - width: 65px; - background-color: #8BC1F7; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--blue-1 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--blue-1 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--blue-2 { - height: 65px; - width: 65px; - background-color: #519DE9; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--blue-2 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--blue-2 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--blue-3 { - height: 65px; - width: 65px; - background-color: #0066cc; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--blue-3 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--blue-3 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--blue-4 { - height: 65px; - width: 65px; - background-color: #004B95; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--blue-4 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--blue-4 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--blue-5 { - height: 65px; - width: 65px; - background-color: #002F5D; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--blue-5 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--blue-5 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--green-1 { - height: 65px; - width: 65px; - background-color: #BDE2B9; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--green-1 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--green-1 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--green-2 { - height: 65px; - width: 65px; - background-color: #7CC674; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--green-2 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--green-2 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--green-3 { - height: 65px; - width: 65px; - background-color: #4CB140; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--green-3 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--green-3 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--green-4 { - height: 65px; - width: 65px; - background-color: #38812f; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--green-4 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--green-4 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--green-5 { - height: 65px; - width: 65px; - background-color: #23511e; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--green-5 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--green-5 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--cyan-1 { - height: 65px; - width: 65px; - background-color: #A2D9D9; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--cyan-1 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--cyan-1 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--cyan-2 { - height: 65px; - width: 65px; - background-color: #73C5C5; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--cyan-2 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--cyan-2 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--cyan-3 { - height: 65px; - width: 65px; - background-color: #009596; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--cyan-3 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--cyan-3 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--cyan-4 { - height: 65px; - width: 65px; - background-color: #005f60; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--cyan-4 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--cyan-4 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--cyan-5 { - height: 65px; - width: 65px; - background-color: #003737; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--cyan-5 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--cyan-5 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--purple-1 { - height: 65px; - width: 65px; - background-color: #B2B0EA; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--purple-1 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--purple-1 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--purple-2 { - height: 65px; - width: 65px; - background-color: #8481DD; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--purple-2 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--purple-2 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--purple-3 { - height: 65px; - width: 65px; - background-color: #5752D1; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--purple-3 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--purple-3 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--purple-4 { - height: 65px; - width: 65px; - background-color: #3C3D99; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--purple-4 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--purple-4 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--purple-5 { - height: 65px; - width: 65px; - background-color: #2A265F; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--purple-5 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--purple-5 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--gold-1 { - height: 65px; - width: 65px; - background-color: #F9E0A2; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--gold-1 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--gold-1 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--gold-2 { - height: 65px; - width: 65px; - background-color: #F6D173; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--gold-2 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--gold-2 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--gold-3 { - height: 65px; - width: 65px; - background-color: #F4C145; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--gold-3 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--gold-3 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--gold-4 { - height: 65px; - width: 65px; - background-color: #F0AB00; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--gold-4 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--gold-4 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--gold-5 { - height: 65px; - width: 65px; - background-color: #C58C00; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--gold-5 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--gold-5 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--orange-1 { - height: 65px; - width: 65px; - background-color: #F4B678; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--orange-1 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--orange-1 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--orange-2 { - height: 65px; - width: 65px; - background-color: #EF9234; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--orange-2 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--orange-2 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--orange-3 { - height: 65px; - width: 65px; - background-color: #EC7A08; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--orange-3 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--orange-3 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--orange-4 { - height: 65px; - width: 65px; - background-color: #C46100; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--orange-4 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--orange-4 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--orange-5 { - height: 65px; - width: 65px; - background-color: #8F4700; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--orange-5 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--orange-5 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--black-1 { - height: 65px; - width: 65px; - background-color: #D2D2D2; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--black-1 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--black-1 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--black-2 { - height: 65px; - width: 65px; - background-color: #BBB; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--black-2 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--black-2 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--black-3 { - height: 65px; - width: 65px; - background-color: #8B8D8F; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--black-3 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--black-3 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--black-4 { - height: 65px; - width: 65px; - background-color: #72767B; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--black-4 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--black-4 { - height: 100px; - width: 100px; - } -} -.chart-colors-gallery--black-5 { - height: 65px; - width: 65px; - background-color: #4D5258; -} -@media screen and (min-width: 768px) { - .chart-colors-gallery--black-5 { - height: 85px; - width: 85px; - } -} -@media screen and (min-width: 1200px) { - .chart-colors-gallery--black-5 { - height: 100px; - width: 100px; - } -} - -@media screen and (min-width: 997px) { - .grid-modifier .grid-modifier-first { - order: 1; - margin-top: 31px; - } - .grid-modifier .grid-modifier-second { - order: 3; - margin-top: 31px; - } - .grid-modifier .grid-modifier-third { - order: 2; - margin-top: 31px; - } - .grid-modifier .grid-modifier-four { - order: 1; - margin-top: 31px; - } - .grid-modifier .grid-modifier-five { - order: 5; - margin-top: 31px; - } -} - -.css-var-text { - display: none; - visibility: hidden; -} -@media screen and (min-width: 768px) { - .css-var-text { - display: block; - visibility: visible; - } -} - -.chart-colors-gallery--information { - margin-top: 8px; - margin-bottom: 16px; -} -.chart-colors-gallery--information > * { - font-size: 12px; -} -.chart-colors-gallery--information > * > code { - font-size: 10px !important; +/* Specifity YEAH */ +.pf-c-divider.ws-colors-divider { + margin-top: var(--pf-c-content--h2--MarginTop); } diff --git a/packages/v4/src/content/design-guidelines/styles/colors/colors.md b/packages/v4/src/content/design-guidelines/styles/colors/colors.md index 4bb53e2741..feede2797c 100644 --- a/packages/v4/src/content/design-guidelines/styles/colors/colors.md +++ b/packages/v4/src/content/design-guidelines/styles/colors/colors.md @@ -1,432 +1,229 @@ --- title: Colors section: styles -hideTOC: true -showTitle: true +hideSource: true --- -import { Alert, Gallery, GalleryItem, Grid, GridItem, AlertActionCloseButton } from '@patternfly/react-core'; +import { Alert, Grid, GridItem, Divider } from '@patternfly/react-core'; import { Link } from 'gatsby'; +import { ColorSwatch } from './ColorSwatch'; +import { ColorFamily } from './ColorFamily'; import './colors.css'; + -## Theme colors - - - -

Primary default

-
- - - -
-
- -

#0066CC

-

Global CSS variable

- --pf-global--primary-color--100 -
-
+## Primary colors + + +

PatternFly blue

+ Primary colors are the colors displayed most frequently across your application screens and components. Our primary colors are used within a variety of components and are typically applied to default or active states and hover states. + + This color is most commonly used as as default or active state for many components including badges and spinners. + + + This color is most commonly used as the hover or focus state for components that use the default primary color, such as buttons and dropdowns. +
- - - -
-
- -

#004080

-

Global CSS variable

- --pf-global--primary-color--200 -
-
-
- - - -

Colors in context

- -

This call-to-action uses default PatternFly 4 colors. The active state button takes --pf-global--primary-color--100. On a hover, the color adjusts to --pf-global--primary-color--200.

-
-
+ + PatternFly blue colors
- - -

Secondary default

-
- - - -
-
- -

#72767B

-

Global CSS variable

- --pf-global--secondary-color--100 -
-
-
- - - -

Colors in context

-
- - Chip - - -
-
- - Really long Chip that goes on and on - - -
-

This Chip uses default PatternFly 4 colors. The border uses --pf-global--secondary-color--100.

-
-
+ + +## Typography and iconography colors + + +

Text and icons

+ Typography and iconography colors are extremely similar because they can both be used in the same context, such as a link button. We have multiple shades of text colors on light and dark backgrounds so that you can emphasize hierarchy. + + This color is used as a standard text and icon color as well as a hover state color for icon buttons. It is most commonly used as a text color for many components and application screens. + + + This color is used as a secondary text color as well as a default color for icon buttons. It is most commonly used for many components, such as the app launcher and empty states. + + + This color is most commonly used as a link text and icon color for many components, such as navigation and accordions. Blue icons use the same primary color variable as the blue text. + +
+ + PatternFly typography colors
-

Typography colors

- - - -

Text

-
- - - -
-
- -

#151515

-

Global CSS variable

- --pf-global--Color--100 -
-
-
- - - - -
-
- -

#72767B

-

Global CSS variable

- --pf-global--Color--200 -
-
-
- - - -
-
- -

#393F44

-

Global CSS variable

- --pf-global--Color--300 -
-
-
- - - -

Colors in context

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

-

Body text should be Overpass Regular at 16px. It should have leading of 24px because of it’s relative line-height of 1.5.

-
-
-
- - Learn more about typography styles. + + +## Background colors + + + Background colors are used throughout components and can be used for certain screens depending on the use case. The light colors can be interchangeable for full-screen backgrounds. The dark background colors are strictly used within components. + + This color is most commonly used as a secondary background color for full application screens and hover backgrounds. + + + This color is most commonly used as a primary background color for full application screens and many components, such as cards and tables/data lists. + + + This color is most commonly used as a background color for many components, such as tooltips and wizards. + + + This color is used as a background color for navigation. + + + This color is most commonly used as a background color for many components, such as navigation. + + + This color is used as a background color for navigation. + + + + PatternFly background colors - - -

Links

-
- - - -
-
- -

#0066CC

-

Global CSS variable

- --pf-global--link--Color -
-
+ + +## Status and state colors + + + Status and state colors are important when communicating data and action aspects through the UI with the user. Our status colors cover a variety of statuses including default, danger, success, information, and warning. - - - -
-
- -

#004080

-

Global CSS variable

- --pf-global--link--Color--hover -
-
+ + PatternFly status colors - - - -

Colors in context

-

Body text should be Overpass Regular at 16px. This is a link in-content. It should have leading of 24px because of its relative line-height of 1.5. -

-
-
+ +

Danger

+ + This color is used as the icon color for the danger alert component. + + + This color is used as the title color for the danger alert as well as the background color for the danger button. + + + This color is most commonly used as an indication of danger or error for components, such as alerts and form inputs. + +
+ +

Default

+ + This color is used as the icon and title color for the default alert component. + + + This color is used as the background and icon color for the default inline alert component. + + + This color is used as the icon background color for the default alert component. + +
+ +

Info

+ + This color is used as the icon and title color for the info alert component. + + + This color is used as the icon background color for the info alert component as well as the background and icon color for the info inline alert component. + +
+ +

Success

+ + This color is used as an indication of success for components, such as alerts and forms. It is used as the icon and title color for the success alert component. + + + This color is most commonly used as an indication of success for components, such as alerts and forms. It is used as the background color for the success alert component as well as the background and icon color for the success inline alert component. + +
+ +

Warning

+ + This color is used as the icon and title color for the warning alert component. + + + This color is used as the icon background color for the warning alert component as well as the background and icon color for the warning inline alert component. + +
+ +

Disabled

+ + This color is used as the disabled text color when text is indicated as disabled. + + + This color is most commonly used as a disabled background color for many components, such as buttons and the app launcher. + + + This color is most commonly used as an alternate disabled background color for many components, such as dropdowns and options menus. +
- - -

Icons

-
- - - -
-
- -

#72767B

-

Global CSS variable

- --pf-global--icon--Color--light -
-
-
- - - -

Colors in context

-

Icon color is #72767B unless used in an alert.

-
-
-
- - Learn more about icons. + + +## Shadows + + + Shadows provide specifics about depth, direction of movement, and surface edges. Depending on the surface’s elevation and relationships to other surfaces, the type of shadow will change. + + This variable is used to indicate a large shadow for many components, such as alerts and modals. + + + This variable is used to indicate a medium shadow for many components, such as accordion and dropdowns. + + + This variable is used to indicate a small shadow for the card component. + + + + PatternFly shadows -

Alert statuses

+ - - -

Success

-
- - - -
-
- -

#92D400

-

Global CSS variable

- --pf-global--success-color--100 -
-
-
- - - -
-
- -

#486B00

-

Global CSS variable

- --pf-global--success-color--200 -
-
-
- - - -

Colors in context

- } - /> -

Success alert color: --pf-global--success-color--100

-

Success alert icon color: --pf-global--success-color--200

-
-
-
-
+## Contrast ratios +

+ Level AA in the Web Content Accessibility Guidelines 2.1 requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text, and a contrast ratio of at least 3:1 for graphics and user interface components (such as form input borders). +

+ +Check color contrast between background color and text color using a WCAG AA-compliance tool. + +Make sure that, on hover, link texts provides ample contrast from both background color and from the default state of link text. - - -

Information

+ + +## Color palette +Our palettes are created as a system designed to reinforce application content and workflows. Bright colors are reserved for specific interactions such as reinforcing status and are used sparingly. Our palettes are simple and consolidated to allow them to be easily deployed and versatile for any situation. + + + + - - - -
-
- -

#73BCF7

-

Global CSS variable

- --pf-global--info-color--100 -
-
+ + - - - -
-
- -

#004368

-

Global CSS variable

- --pf-global--info-color--200 -
-
+ + - - - -

Colors in context

- } - /> -

Info alert color: --pf-global--info-color--100

-

Info alert icon color: --pf-global--info-color--200

-
-
+ + -
- - - -

Warning

+ + - - - -
-
- -

#f0AB00

-

Global CSS variable

- --pf-global--warning-color--100 -
-
+ + - - - -
-
- -

#795600

-

Global CSS variable

- --pf-global--warning-color--200 -
-
+ + - - - -

Colors in context

- } - /> -

Warning alert color: --pf-global--warning-color--100

-

Warning alert icon color: --pf-global--warning-color--200

-
-
+ + -
- - - -

Danger

-
- - - -
-
- -

#C9190B

-

Global CSS variable

- --pf-global--danger-color--100 -
-
+ + - - - -
-
- -

#470000

-

Global CSS variable

- --pf-global--danger-color--300 -
-
+ + - - - -

Colors in context

- } - /> -

Danger/critical alert color: --pf-global--danger-color--100

-

Danger/critical alert icon color: --pf-global--danger-color--300

-
-
+ + -
- -## Contrast ratios -

- Level AA in the Web Content Accessibility Guildelines 2.1 requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text, and a contrast ratio of at least 3:1 for graphics and user interface components (such as form input borders). -

- -Check color contrast between background color and text color using a WCAG AA-compliance tool. - -Make sure that, on hover, link texts provides ample contrast from both background color and from the default state of link text. +
\ No newline at end of file diff --git a/packages/v4/src/content/design-guidelines/styles/colors/helpers.js b/packages/v4/src/content/design-guidelines/styles/colors/helpers.js new file mode 100644 index 0000000000..9b8a927c50 --- /dev/null +++ b/packages/v4/src/content/design-guidelines/styles/colors/helpers.js @@ -0,0 +1,32 @@ +export function normalizeColor(color) { + color = color.toUpperCase(); + if (color.startsWith('#')) { + const hex = color.substr(1); + return hex.length === 3 ? hex.split('').map(char => char.repeat(2)).join('') : hex; + } +} + +function normalizeLuminance(val) { + val = parseInt(val, 16) / 255; + return val <= 0.03928 ? val / 12.92 : Math.pow((val + 0.055) / 1.055, 2.4); +} + +function getRelativeLuminance(color) { + // https://www.w3.org/TR/WCAG21/relative-luminance.xml + const r = normalizeLuminance(color.substr(0, 2)); + const g = normalizeLuminance(color.substr(2, 2)); + const b = normalizeLuminance(color.substr(4, 2)); + return (0.2126 * r) + (0.7152 * g) + (0.0722 * b); +} + +export function getContrastRatio(c1, c2) { + // https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio + c1 = normalizeColor(c1); + c2 = normalizeColor(c2); + + const l1 = getRelativeLuminance(c1); + const l2 = getRelativeLuminance(c2); + + return (l1 + 0.05) / (l2 + 0.05); +} + diff --git a/packages/v4/src/content/design-guidelines/styles/colors/patternfly-background.png b/packages/v4/src/content/design-guidelines/styles/colors/patternfly-background.png new file mode 100644 index 0000000000..febb54a110 Binary files /dev/null and b/packages/v4/src/content/design-guidelines/styles/colors/patternfly-background.png differ diff --git a/packages/v4/src/content/design-guidelines/styles/colors/patternfly-blue.png b/packages/v4/src/content/design-guidelines/styles/colors/patternfly-blue.png new file mode 100644 index 0000000000..121e65cddc Binary files /dev/null and b/packages/v4/src/content/design-guidelines/styles/colors/patternfly-blue.png differ diff --git a/packages/v4/src/content/design-guidelines/styles/colors/patternfly-shadows.png b/packages/v4/src/content/design-guidelines/styles/colors/patternfly-shadows.png new file mode 100644 index 0000000000..16795a4fe3 Binary files /dev/null and b/packages/v4/src/content/design-guidelines/styles/colors/patternfly-shadows.png differ diff --git a/packages/v4/src/content/design-guidelines/styles/colors/patternfly-status.png b/packages/v4/src/content/design-guidelines/styles/colors/patternfly-status.png new file mode 100644 index 0000000000..e48471ef6a Binary files /dev/null and b/packages/v4/src/content/design-guidelines/styles/colors/patternfly-status.png differ diff --git a/packages/v4/src/content/design-guidelines/styles/colors/patternfly-typography.png b/packages/v4/src/content/design-guidelines/styles/colors/patternfly-typography.png new file mode 100644 index 0000000000..dd6340f78c Binary files /dev/null and b/packages/v4/src/content/design-guidelines/styles/colors/patternfly-typography.png differ