UNPKG

@spark-web/theme

Version:

--- title: Theme isExperimentalPackage: true ---

1,417 lines (1,356 loc) 39.8 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var polished = require('polished'); var react = require('react'); var _objectSpread = require('@babel/runtime/helpers/objectSpread2'); var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties'); var core = require('@capsizecss/core'); var mapValues = require('lodash/mapValues'); var _defineProperty = require('@babel/runtime/helpers/defineProperty'); var _typeof = require('@babel/runtime/helpers/typeof'); var facepaint = require('facepaint'); var lodash = require('lodash'); var jsxRuntime = require('@emotion/react/jsx-runtime'); var react$1 = require('@emotion/react'); function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; } var mapValues__default = /*#__PURE__*/_interopDefault(mapValues); var facepaint__default = /*#__PURE__*/_interopDefault(facepaint); var smoothSaturation = function smoothSaturation(saturation, luminance) { var isBright = luminance > 0.6; if (isBright) { return saturation * 0.8; } return saturation * 0.45; }; var smoothLightness = function smoothLightness(lightness, luminance) { var isBright = luminance > 0.6; if (isBright) { return 0.95 - lightness * 0.03; } return 0.95 - lightness * 0.06; }; function getLightVariant(color) { var _parseToHsl3 = polished.parseToHsl(color), hue = _parseToHsl3.hue, saturation = _parseToHsl3.saturation, lightness = _parseToHsl3.lightness; var luminance = polished.getLuminance(color); return polished.toColorString({ hue: hue, saturation: smoothSaturation(saturation, luminance), lightness: smoothLightness(lightness, luminance) }); } var isLight = function isLight(inputColor) { var _parseToRgb = polished.parseToRgb(inputColor), red = _parseToRgb.red, green = _parseToRgb.green, blue = _parseToRgb.blue; // Convert RGB to YIQ to better take into account the // luminance of the separate color channels: // // Further reading: // - YIQ: // https://en.wikipedia.org/wiki/YIQ // - Calculating contrast: // https://24ways.org/2010/calculating-color-contrast/ var yiq = (red * 299 + green * 587 + blue * 114) / 1000; // Colour is considered `light` if greater than the midpoint: // eg. 256 / 2 = 128. return yiq >= 128; }; var breakpointNames = ['mobile', 'tablet', 'desktop', 'wide']; var breakpoints = { mobile: 0, tablet: 740, desktop: 992, wide: 1200 }; /** * Utilities related to responsive props. Emotion's * [facepaint](https://github.com/emotion-js/facepaint) ultimately generates * media queries for the resolved styles. */ var makeThemeUtils = function makeThemeUtils() { // NOTE: the `mobile` key is used to represent "below tablet" in certain // cases, but it SHOULD NOT create a media query: facepaint will apply the // first property in the array without a query. var validBreakpoints = Object.values(breakpointQuery); return { mapResponsiveProp: mapResponsiveProp, mapResponsiveScale: mapResponsiveScale, optimizeResponsiveArray: optimizeResponsiveArray, responsiveRange: responsiveRange, responsiveStyles: responsiveStyles, resolveResponsiveProps: facepaint__default["default"](validBreakpoints) }; }; // Responsive props // ------------------------------ /** * Helper for mapping keys/breakpoint map to a theme scale e.g. * * @example * mapResponsiveProp('small', { small: 8, large: 16 }) // 8 * mapResponsiveProp( * { mobile:'small', tablet:'large' }, * { small: 8, large: 16 } * ) // [8,16] */ var mapResponsiveScale = function mapResponsiveScale(value, scaleDefinition) { if (value === undefined) { return value; } if (_typeof(value) === 'object') { return resolveResponsiveScale(value, scaleDefinition); } return scaleDefinition[value]; }; function resolveResponsiveScale(value, scaleDefinition) { var valueArray = []; for (var i = 0; i < breakpointNames.length; i++) { var breakpoint = breakpointNames[i]; var keyForBreakpoint = value[breakpoint]; // NOTE: media queries are applied by index (facepaint). nullish value // ensures array length always matches breakpoints valueArray.push(keyForBreakpoint ? scaleDefinition[keyForBreakpoint] : null); } return valueArray; } var mapResponsiveProp = function mapResponsiveProp(value) { if (value != null && _typeof(value) === 'object') { return resolveResponsiveProp(value); } return value; }; function resolveResponsiveProp(value) { var valueArray = []; for (var i = 0; i < breakpointNames.length; i++) { var _value$breakpoint; var breakpoint = breakpointNames[i]; valueArray.push((_value$breakpoint = value[breakpoint]) !== null && _value$breakpoint !== void 0 ? _value$breakpoint : null); } return valueArray; } function createResponsiveMapFn(lookupMap) { return function mapResponsiveValue(prop) { if (typeof prop == 'undefined') { return prop; } if (_typeof(prop) === 'object') { var mobile = prop.mobile, tablet = prop.tablet, desktop = prop.desktop, wide = prop.wide; return { mobile: mobile ? lookupMap[mobile] : undefined, tablet: tablet ? lookupMap[tablet] : undefined, desktop: desktop ? lookupMap[desktop] : undefined, wide: wide ? lookupMap[wide] : undefined }; } return lookupMap[prop]; }; } // Responsive range // ------------------------------ var responsiveRange = function responsiveRange(props) { var above = props.above, below = props.below; if (!above && !below) { return [false, false, false, false]; } var startIndex = above ? breakpointNames.indexOf(above) + 1 : 0; var endIndex = below ? breakpointNames.indexOf(below) - 1 : breakpointNames.length - 1; var range = breakpointNames.slice(startIndex, endIndex + 1); var includeMobile = range.indexOf('mobile') >= 0; var includeTablet = range.indexOf('tablet') >= 0; var includeDesktop = range.indexOf('desktop') >= 0; var includeWide = range.indexOf('wide') >= 0; return [includeMobile, includeTablet, includeDesktop, includeWide]; }; var optimizeResponsiveArray = function optimizeResponsiveArray(value) { var _values$, _values$2, _values$3, _values$4; var lastValue; var values = value.map(function (v) { if (v !== lastValue && v !== null) { lastValue = v; return v; } return null; }); return [(_values$ = values[0]) !== null && _values$ !== void 0 ? _values$ : null, (_values$2 = values[1]) !== null && _values$2 !== void 0 ? _values$2 : null, (_values$3 = values[2]) !== null && _values$3 !== void 0 ? _values$3 : null, (_values$4 = values[3]) !== null && _values$4 !== void 0 ? _values$4 : null]; }; // ============================== // Experiment // ============================== var breakpointQuery = mapValues__default["default"](lodash.omit(breakpoints, 'mobile'), function (bp) { return "@media screen and (min-width: ".concat(bp, "px)"); }); var makeMediaQuery = function makeMediaQuery(breakpoint) { return function (styles) { return !styles || Object.keys(styles).length === 0 ? {} : _defineProperty({}, breakpointQuery[breakpoint], styles); }; }; var mediaQuery = { tablet: makeMediaQuery('tablet'), desktop: makeMediaQuery('desktop'), wide: makeMediaQuery('wide') }; var responsiveStyles = function responsiveStyles(_ref2) { var mobile = _ref2.mobile, tablet = _ref2.tablet, desktop = _ref2.desktop, wide = _ref2.wide; return _objectSpread(_objectSpread({}, mobile), tablet || desktop || wide ? _objectSpread(_objectSpread(_objectSpread({}, mediaQuery.tablet(tablet !== null && tablet !== void 0 ? tablet : {})), mediaQuery.desktop(desktop !== null && desktop !== void 0 ? desktop : {})), mediaQuery.wide(wide !== null && wide !== void 0 ? wide : {})) : {}); }; var white = '#ffffff'; var colorPalette$1 = { neutral: { '0': white, '50': '#fafcfe', '100': '#f1f4fb', '200': '#dce1ec', '300': '#c7cedb', '500': '#98a2b8', '550': '#8893A5', '600': '#646f84', '650': '#2A3A4A', '700': '#1a2a3a', '800': '#001A2A' }, primary: { '0': white, '50': '#f5fdf9', '100': '#edfaf5', '150': '#CDFDF0', '200': '#c8eada', '300': '#9acbb8', '500': '#00E0A3', '600': '#00D299', '700': '#00A97B' }, secondary: { '0': white, '50': '#fef5eb', '100': '#fff0e0', '500': '#ffbb66', '600': '#ffaa44', '700': '#e58f27' }, green: { '0': white, '50': '#f6fbf8', '100': '#f0f9f1', '200': '#cde9d2', '300': '#b1dab9', '500': '#1e9c65', '600': '#2c855d', '700': '#327e59' }, blue: { '0': white, '50': '#f6fafd', '100': '#f3f8fc', '200': '#d0e4ff', '300': '#b7d2f4', '500': '#2b8aed', '600': '#0677d6', '700': '#106fb8' }, red: { '0': white, '50': '#fef8f8', '100': '#fff4f4', '200': '#ffdad7', '300': '#fec1b5', '500': '#f53841', '600': '#e61e32', '700': '#c81b0e' }, yellow: { '0': white, '50': '#fefaf6', '100': '#fff5eb', '200': '#fdddc4', '300': '#face9b', '500': '#ffaa44', '600': '#be5c1c', '700': '#ad541a' } }; var borderColors$1 = { neutral: colorPalette$1.neutral[200], standard: colorPalette$1.neutral[200], standardInverted: colorPalette$1.neutral[0], field: colorPalette$1.neutral[200], fieldHover: colorPalette$1.neutral[300], fieldAccent: colorPalette$1.primary[500], fieldDisabled: colorPalette$1.neutral[300], // tones primary: colorPalette$1.primary[500], primaryHover: colorPalette$1.primary[600], primaryActive: colorPalette$1.primary[700], secondary: colorPalette$1.secondary[500], secondaryHover: colorPalette$1.secondary[600], secondaryActive: colorPalette$1.secondary[700], accent: '#8b5cf6', accentMuted: '#997dd8', caution: colorPalette$1.yellow[600], cautionMuted: colorPalette$1.yellow[500], critical: colorPalette$1.red[600], criticalMuted: colorPalette$1.red[500], info: colorPalette$1.blue[600], infoMuted: colorPalette$1.blue[500], positive: colorPalette$1.green[600], positiveMuted: colorPalette$1.green[500], dark: colorPalette$1.neutral[700], darkHover: colorPalette$1.neutral[650], darkActive: colorPalette$1.neutral[800] }; var colors$1 = { foreground: { neutral: colorPalette$1.neutral[700], neutralInverted: colorPalette$1.neutral[0], muted: colorPalette$1.neutral[600], mutedInverted: 'hsla(0, 0%, 100%, 0.75)', link: colorPalette$1.primary[600], disabled: colorPalette$1.neutral[500], field: colorPalette$1.neutral[550], fieldAccent: colorPalette$1.primary[500], placeholder: colorPalette$1.neutral[600], // tones accent: '#8b5cf6', primary: colorPalette$1.primary[500], primaryHover: colorPalette$1.primary[600], primaryActive: colorPalette$1.primary[700], secondary: colorPalette$1.secondary[500], secondaryHover: colorPalette$1.secondary[600], secondaryActive: colorPalette$1.secondary[700], caution: colorPalette$1.yellow[700], critical: colorPalette$1.red[700], info: colorPalette$1.blue[700], positive: colorPalette$1.green[700] }, background: { muted: colorPalette$1.neutral[600], disabled: colorPalette$1.neutral[500], backdrop: 'hsla(0, 0%, 0%, 0.4)', body: colorPalette$1.neutral[50], surface: colorPalette$1.primary[0], surfaceMuted: colorPalette$1.neutral[50], surfacePressed: colorPalette$1.neutral[300], fieldAccent: colorPalette$1.neutral[700], input: colorPalette$1.primary[0], inputPressed: colorPalette$1.neutral[100], inputDisabled: colorPalette$1.neutral[50], // tones accent: '#8b5cf6', accentMuted: '#f7f5ff', neutral: colorPalette$1.neutral[0], neutralLow: colorPalette$1.neutral[50], primary: colorPalette$1.primary[600], primaryLow: colorPalette$1.primary[100], primarySoft: colorPalette$1.primary[150], primaryMuted: colorPalette$1.primary[50], primaryDark: colorPalette$1.primary[700], secondary: colorPalette$1.secondary[600], secondaryLow: colorPalette$1.secondary[100], secondaryMuted: colorPalette$1.secondary[50], caution: colorPalette$1.yellow[600], cautionLow: colorPalette$1.yellow[100], cautionMuted: colorPalette$1.yellow[50], critical: colorPalette$1.red[600], criticalLow: colorPalette$1.red[100], criticalMuted: colorPalette$1.red[50], info: colorPalette$1.blue[600], infoLow: colorPalette$1.blue[100], infoMuted: colorPalette$1.blue[50], positive: colorPalette$1.green[600], positiveLow: colorPalette$1.green[100], positiveMuted: colorPalette$1.green[50], dark: colorPalette$1.neutral[700] }, status: { // tones for statuses can be either foreground or background accent: '#8b5cf6', caution: colorPalette$1.yellow[500], critical: colorPalette$1.red[500], info: colorPalette$1.blue[500], neutral: colorPalette$1.neutral[700], positive: colorPalette$1.green[500] } }; var interactionColors$1 = { none: colorPalette$1.neutral[0], primaryActive: colorPalette$1.primary[700], primaryHover: colorPalette$1.primary[500], primaryLowHover: colorPalette$1.primary[100], primaryLowActive: colorPalette$1.primary[200], secondaryActive: colorPalette$1.secondary[700], secondaryHover: colorPalette$1.secondary[500], secondaryLowHover: colorPalette$1.yellow[100], secondaryLowActive: colorPalette$1.yellow[200], neutralHover: colorPalette$1.neutral[100], neutralActive: colorPalette$1.neutral[200], neutralLowHover: colorPalette$1.neutral[100], neutralLowActive: colorPalette$1.neutral[200], cautionLowHover: colorPalette$1.yellow[200], cautionLowActive: colorPalette$1.yellow[300], criticalActive: colorPalette$1.red[700], criticalHover: colorPalette$1.red[500], criticalLowHover: colorPalette$1.red[200], criticalLowActive: colorPalette$1.red[300], infoLowHover: colorPalette$1.blue[200], infoLowActive: colorPalette$1.blue[300], positiveHover: colorPalette$1.green[500], positiveActive: colorPalette$1.green[700], positiveLowHover: colorPalette$1.green[200], positiveLowActive: colorPalette$1.green[300], darkHover: colorPalette$1.neutral[650], darkActive: colorPalette$1.neutral[800], darkLowHover: colorPalette$1.neutral[300], darkLowActive: colorPalette$1.neutral[100] }; var fontWeight$1 = { thin: 100, extralight: 200, light: 300, regular: 400, medium: 500, semibold: 600, bold: 700, extrabold: 800, black: 900 }; var heading$1 = { level: { '1': { mobile: { fontWeight: fontWeight$1.semibold, fontSize: 35, rows: 9 }, tablet: { fontWeight: fontWeight$1.semibold, fontSize: 35, rows: 11 } }, '2': { mobile: { fontWeight: fontWeight$1.semibold, fontSize: 23, rows: 8 }, tablet: { fontWeight: fontWeight$1.semibold, fontSize: 23, rows: 9 } }, '3': { mobile: { fontWeight: fontWeight$1.semibold, fontSize: 19, rows: 6 }, tablet: { fontWeight: fontWeight$1.semibold, fontSize: 19, rows: 7 } }, '4': { mobile: { fontWeight: fontWeight$1.semibold, fontSize: 17, rows: 5 }, tablet: { fontWeight: fontWeight$1.semibold, fontSize: 17, rows: 7 } } } }; var text$1 = { xsmall: { mobile: { fontSize: 13, fontWeight: fontWeight$1.regular, rows: 5 }, tablet: { fontSize: 13, fontWeight: fontWeight$1.regular, rows: 5 } }, small: { mobile: { fontSize: 15, fontWeight: fontWeight$1.regular, rows: 5 }, tablet: { fontSize: 15, fontWeight: fontWeight$1.regular, rows: 5 } }, standard: { mobile: { fontSize: 17, fontWeight: fontWeight$1.regular, rows: 6 }, tablet: { fontSize: 17, fontWeight: fontWeight$1.regular, rows: 6 } }, large: { mobile: { fontSize: 19, fontWeight: fontWeight$1.regular, rows: 7 }, tablet: { fontSize: 19, fontWeight: fontWeight$1.regular, rows: 7 } }, xlarge: { mobile: { fontSize: 24, fontWeight: fontWeight$1.regular, rows: 8, lineHeight: 34 }, tablet: { fontSize: 24, fontWeight: fontWeight$1.regular, rows: 8, lineHeight: 34 } }, xxlarge: { mobile: { fontSize: 35, fontWeight: fontWeight$1.regular, rows: 9, lineHeight: 49 }, tablet: { fontSize: 35, fontWeight: fontWeight$1.regular, rows: 9, lineHeight: 49 } } }; // NOTE: all tokens are currently assumptions and will need to be reviewed with // the design team, but the shape shouldn't change too much. var aesteticoFontMetrics = { capHeight: 666, ascent: 980, descent: -340, lineGap: 0, unitsPerEm: 1000 }; var typography$1 = { fontFamily: { sans: { fontMetrics: aesteticoFontMetrics, name: '"Aestetico", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"' }, display: { fontMetrics: aesteticoFontMetrics, name: '"Aestetico", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"' } }, fontWeight: fontWeight$1, heading: heading$1, text: text$1 }; var baseTokens = { name: 'Spark default: light', // tweak for breakpoints typography: typography$1, border: { radius: { none: 0, small: 4, medium: 8, large: 16 }, width: { standard: 1, large: 2 }, color: borderColors$1 }, color: colors$1, backgroundInteractions: interactionColors$1, // misc contentWidth: { xsmall: 400, small: 660, medium: 940, large: 1280, xlarge: 1400 }, contentHeight: { medium: 50, large: 85, full: 100 }, elevation: { dropdownBlanket: 90, dropdown: 100, sticky: 200, modalBlanket: 290, modal: 300, notification: 400 }, spacing: { xxsmall: 2, xsmall: 4, small: 8, medium: 12, large: 16, xlarge: 24, xxlarge: 32, xxxlarge: 40 }, sizing: { xxsmall: 16, xsmall: 24, small: 32, medium: 44, large: 56, xlarge: 64, xxlarge: 72 }, shadow: { small: '0 1px 2px rgba(0, 0, 0, 0.05)', medium: '0 2px 8px rgba(0, 0, 0, 0.04)', large: '0 6px 12px rgba(0, 0, 0, 0.1)' }, animation: { standard: { duration: 300, easing: 'cubic-bezier(0.2, 0, 0, 1)' } } }; var buttonTokens$1 = { fontWeight: 'semibold', focus: { outline: "2px solid ".concat(colorPalette$1.neutral[700]), outlineOffset: '-2px' } }; var checkboxTokens$1 = { border: { "default": colorPalette$1.neutral[550], radius: 'small', width: 'standard' }, background: 'surface', shadow: 'small', checked: { background: colors$1.background.primary, border: { color: borderColors$1.primaryHover }, icon: { stroke: colors$1.foreground.neutralInverted }, disabled: { background: borderColors$1.field, border: borderColors$1.accent, icon: { stroke: colors$1.foreground.neutral }, before: { background: colors$1.background.fieldAccent } } }, label: { hover: { border: borderColors$1.primaryHover }, checked: { hover: { background: interactionColors$1.primaryHover, border: borderColors$1.fieldAccent } } } }; var contentDialogTokens$1 = { borderRadius: 'medium', shadow: 'large' }; var radioTokens$1 = { background: 'surface', backgroundInteractions: { primaryHover: interactionColors$1.primaryHover, borderColor: borderColors$1.primary, borderWidthHover: 0, borderWidthChecked: 2, borderColorHover: interactionColors$1.primaryHover, borderColorFocus: borderColors$1.primary, backgroundColorHover: colors$1.background.surface }, color: { background: { primary: colors$1.background.primary, surface: colors$1.background.surface, fieldAccent: colors$1.background.fieldAccent } }, border: { width: baseTokens.border.width.standard, "default": colorPalette$1.neutral[550], radius: { pseudo: 9999, full: 'full' }, color: { primary: borderColors$1.primary, fieldAccent: colors$1.background.fieldAccent, field: borderColors$1.field, accent: borderColors$1.accent } }, radioCardBorder: { border: { width: baseTokens.border.width.standard, radius: baseTokens.border.radius.small } } }; var textInputTokens$1 = { borderColor: colorPalette$1.neutral[550], borderRadius: baseTokens.border.radius.small, boxShadow: baseTokens.shadow.small, menu: { borderRadius: baseTokens.border.radius.medium, boxShadow: baseTokens.shadow.medium, padding: baseTokens.spacing.small }, menuOption: { borderRadius: baseTokens.border.radius.small, active: { backgroundColor: colors$1.background.surfacePressed }, focused: { backgroundColor: colors$1.background.surfaceMuted }, selected: { color: colors$1.foreground.primaryActive, backgroundColor: colors$1.background.primaryMuted, focused: { backgroundColor: interactionColors$1.primaryLowHover }, active: { backgroundColor: interactionColors$1.positiveLowActive } } } }; var textLinkTokens$1 = { a: { textDecoration: 'underline', fontWeight: 'bold' }, span: { textDecoration: 'underline', fontWeight: 'bold' } }; var defaultTokens = _objectSpread(_objectSpread({}, baseTokens), {}, { // components components: { buttons: buttonTokens$1, checkbox: checkboxTokens$1, contentDialog: contentDialogTokens$1, radio: radioTokens$1, textInput: textInputTokens$1, textLink: textLinkTokens$1 } }); // Tokens // ------------------------------ var tokens$1 = lodash.merge({}, defaultTokens, {}); var brighteTokens = _objectSpread(_objectSpread({}, tokens$1), {}, { name: 'Brighte theme: light' }); var brand = { brandYellow: '#FFCC00', brandBeacon: '#FAEC20' }; var neutral = { black: { '0': '#1E1E1E' }, dark: { '50': '#918F90', '65': '#706D6E', '80': '#4F4C4D' }, light: { '5': '#F4F4F4', '10': '#E9E9E9', '20': '#D3D2D2' } }; var utility = { utilityRed: '#E1001A', utilityTangerine: '#F95200', utilityBlue: '#1175B5', utilityGreen: '#00AA00', accentGreen: '#1A7D1A', tintGreen: '#ECFEEC', tintBlue: '#D8EEF9' }; var interactionColors = { buttonHover: '#FFDB4D', buttonPressed: '#D3A906' }; var neutralColors = { black: neutral.black[0], dark80: neutral.dark[80], dark65: neutral.dark[65], dark50: neutral.dark[50], light20: neutral.light[20], light10: neutral.light[10], light05: neutral.light[5], white: '#FFFFFF' }; var colorPalette = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, brand), neutralColors), interactionColors), utility); var borderColors = lodash.merge({}, borderColors$1, { neutral: colorPalette.dark65 }); var colors = lodash.merge({}, colors$1, { foreground: { neutral: colorPalette.black, neutralLink: colorPalette.dark65, link: colorPalette.utilityBlue, disabled: colorPalette.light20, fieldAccent: colorPalette.accentGreen, accent: colorPalette.utilityBlue, primary: colorPalette.black, primaryActive: colorPalette.brandBeacon, caution: colorPalette.utilityTangerine, critical: colorPalette.utilityRed, info: colorPalette.utilityBlue, positive: colorPalette.utilityGreen }, background: { primary: colorPalette.brandYellow, disabled: colorPalette.dark50, surface: colorPalette.white, surfaceMuted: colorPalette.light10, surfacePressed: colorPalette.light05, fieldAccent: colorPalette.black } }); var backgroundInteractions = lodash.merge({}, interactionColors$1, { primaryHover: colorPalette.buttonHover, primaryActive: colorPalette.buttonPressed }); var buttonTokens = lodash.merge({}, buttonTokens$1, { fontWeight: 'regular', focus: { outline: "2px solid ".concat(colorPalette.utilityBlue), outlineOffset: '-2px' } }); var checkboxTokens = lodash.merge({}, checkboxTokens$1, { border: { "default": colorPalette.black, radius: 'none', width: 'large' }, checked: { background: colorPalette.black, border: { color: colorPalette.black } }, label: { hover: { border: colorPalette.black }, checked: { hover: { background: colorPalette.black, border: colorPalette.black } } }, focus: { border: "2px solid ".concat(colorPalette.utilityBlue), outline: "1px solid ".concat(colorPalette.utilityBlue), outlineOffset: '-1px', checked: { background: colorPalette.utilityBlue, border: { color: colorPalette.utilityBlue } } } }); var contentDialogTokens = { borderRadius: 'none', shadow: null }; var radioTokens = lodash.merge({}, radioTokens$1, { background: colorPalette.black, backgroundInteractions: { primaryHover: 'transparent', borderColor: colorPalette.black, borderWidthHover: 2, borderColorHover: colorPalette.light20, borderColorFocus: colorPalette.utilityBlue, backgroundColorHover: colorPalette.black }, color: { background: { primary: colorPalette.white, surface: colorPalette.black, fieldAccent: colorPalette.black } }, border: { width: 2, "default": '2px solid', color: { primary: colorPalette.black, fieldAccent: colorPalette.light20, field: colorPalette.light20, accent: colorPalette.black } }, radioCardBorder: { border: { width: 1, radius: 0 }, hover: { // TO DO: find correct vale for boxShadow boxShadow: "0 0 0 2px ".concat(colorPalette.light05) } }, focus: { border: "2px solid ".concat(colorPalette.utilityBlue), outline: "1px solid ".concat(colorPalette.utilityBlue), outlineOffset: '-1px', checked: { border: { width: 3, color: colorPalette.utilityBlue } } } }); var textInputTokens = lodash.merge({}, textInputTokens$1, { borderColor: neutralColors.dark65, borderRadius: baseTokens.border.radius.none, boxShadow: null, menu: { borderRadius: baseTokens.border.radius.none, padding: 0 }, menuOption: { borderRadius: baseTokens.border.radius.none, selected: { backgroundColor: colors.background.surfaceMuted, color: colors.foreground.neutral, active: { backgroundColor: colors.background.surfaceMuted }, focused: { backgroundColor: colors.background.surfaceMuted } } }, hover: { borderColor: 'unset' }, focused: { boxShadow: '0 0 0 transparent', outline: "2px solid ".concat(colorPalette.utilityBlue), outlineOffset: '-2px' } }); var textLinkTokens = lodash.merge({}, textLinkTokens$1, { a: { textDecoration: 'underline', fontWeight: 'regular', hover: { textDecoration: 'none' }, focus: { outline: "2px solid ".concat(colorPalette.utilityBlue), paddingTop: 5, paddingBottom: 5, textDecoration: 'none' }, active: { color: colorPalette.black, textDecoration: 'none' } }, span: { textDecoration: 'none', fontWeight: 'regular', hover: { textDecoration: 'underline' }, focus: { outline: "2px solid ".concat(colorPalette.utilityBlue), paddingTop: 5, paddingBottom: 5, textDecoration: 'none' }, active: { color: colorPalette.black, textDecoration: 'underline' } } }); var fontWeight = lodash.merge({}, fontWeight$1); var heading = { level: { '1': { mobile: { fontWeight: fontWeight.extrabold, fontSize: 32, rows: 9, lineHeight: 40 }, tablet: { fontWeight: fontWeight.extrabold, fontSize: 40, rows: 11, lineHeight: 48 } }, '2': { mobile: { fontWeight: fontWeight.extrabold, fontSize: 24, rows: 8, lineHeight: 32 }, tablet: { fontWeight: fontWeight.extrabold, fontSize: 32, rows: 9, lineHeight: 40 } }, '3': { mobile: { fontWeight: fontWeight.extrabold, fontSize: 20, rows: 6, lineHeight: 28 }, tablet: { fontWeight: fontWeight.extrabold, fontSize: 20, rows: 7, lineHeight: 28 } }, '4': { mobile: { fontWeight: fontWeight.extrabold, fontSize: 16, rows: 5, lineHeight: 24 }, tablet: { fontWeight: fontWeight.extrabold, fontSize: 16, rows: 7, lineHeight: 24 } } } }; var text = lodash.merge({}, text$1, { small: { mobile: { fontSize: 14, fontWeight: fontWeight.regular, rows: 5, lineHeight: 17 }, tablet: { fontSize: 14, fontWeight: fontWeight.regular, rows: 5, lineHeight: 17 } }, standard: { mobile: { fontSize: 16, fontWeight: fontWeight.regular, lineHeight: 24, rows: 6 }, tablet: { fontSize: 16, fontWeight: fontWeight.regular, rows: 6, lineHeight: 24 } }, large: { mobile: { fontSize: 20, fontWeight: fontWeight.regular, rows: 7, lineHeight: 28 }, tablet: { fontSize: 20, fontWeight: fontWeight.regular, rows: 7, lineHeight: 28 } } }); // NOTE: this is directly derived from the default theme font (Aestetico), so we may need to tweak this // NOTE: all tokens are currently assumptions and will need to be reviewed with // the design team, but the shape shouldn't change too much. var beaconSansFontMetrics = { capHeight: 666, ascent: 980, descent: -340, lineGap: 0, unitsPerEm: 1000 }; var typography = lodash.merge({}, typography$1, { fontFamily: { sans: { fontMetrics: beaconSansFontMetrics, name: '"CBA Beacon Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"' }, display: { fontMetrics: beaconSansFontMetrics, name: '"CBA Beacon Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"' } }, heading: heading, text: text }); // Tokens // ------------------------------ var tokens = lodash.merge({}, defaultTokens, { color: colors, backgroundInteractions: backgroundInteractions, typography: typography, components: { buttons: buttonTokens, checkbox: checkboxTokens, contentDialog: contentDialogTokens, radio: radioTokens, textInput: textInputTokens, textLink: textLinkTokens }, border: _objectSpread(_objectSpread({}, defaultTokens.border), {}, { color: borderColors }) }); var pantheonTokens = _objectSpread(_objectSpread({}, tokens), {}, { name: 'Pantheon theme: light' }); var _excluded = ["fontSize", "lineHeight"], _excluded2 = ["border", "color", "sizing", "spacing", "typography"]; // Typography // ------------------------------ // Adapted from node_modules/@capsizecss/core/dist/declarations/src/types.d.ts /** * Afford consumers the simplicity of pixel values for token declarations while * supporting our users' browser preferences. */ function pxToRem(value) { var px = typeof value === 'string' ? parseFloat(value) : value; // NOTE: assume default browser settings of 16px root var modifier = 1 / 16; return "".concat(px * modifier, "rem"); } /** * Calculate leading and trim styles using * [Capsize](https://seek-oss.github.io/capsize/) to ensure vertical spacing * around text elements behaves as expected. */ function fontSizeToCapHeight(definition, fontMetrics) { var _definition$lineHeigh; var rowHeight = 4; // TODO: move to theme? var capHeight = core.getCapHeight({ fontSize: definition.fontSize, fontMetrics: fontMetrics }); var _precomputeValues = core.precomputeValues({ fontSize: definition.fontSize, leading: (_definition$lineHeigh = definition === null || definition === void 0 ? void 0 : definition.lineHeight) !== null && _definition$lineHeigh !== void 0 ? _definition$lineHeigh : definition.rows * rowHeight, fontMetrics: fontMetrics }), fontSize = _precomputeValues.fontSize, lineHeight = _precomputeValues.lineHeight, trims = _objectWithoutProperties(_precomputeValues, _excluded); return { fontSize: pxToRem(fontSize), fontWeight: definition.fontWeight, lineHeight: pxToRem(lineHeight), capHeight: pxToRem(capHeight), trims: trims }; } function responsiveTypography(definition, fontMetrics) { var mobile = definition.mobile, tablet = definition.tablet; return { mobile: fontSizeToCapHeight(mobile, fontMetrics), tablet: fontSizeToCapHeight(tablet, fontMetrics) }; } /** * Apply "capsized" style rules to the typographic tokens, making them available * in the theme. */ function decorateTypography(typography) { var _ref = typography || defaultTokens.typography, heading = _ref.heading, text = _ref.text, fontFamily = _ref.fontFamily; return _objectSpread(_objectSpread({}, typography), {}, { heading: _objectSpread(_objectSpread({}, heading), {}, { level: _objectSpread({}, mapValues__default["default"](heading.level, function (definition) { return responsiveTypography(definition, fontFamily.display.fontMetrics); })) }), text: _objectSpread(_objectSpread({}, text), mapValues__default["default"](text, function (definition) { return responsiveTypography(definition, fontFamily.sans.fontMetrics); })) }); } function decorateTokens(tokens) { var _ref2 = tokens || defaultTokens, border = _ref2.border, color = _ref2.color, sizing = _ref2.sizing, spacing = _ref2.spacing, typography = _ref2.typography, restTokens = _objectWithoutProperties(_ref2, _excluded2); var decoratedTokens = _objectSpread({ breakpoint: breakpoints, border: _objectSpread(_objectSpread({}, border), {}, { radius: _objectSpread(_objectSpread({}, border.radius), {}, { full: 9999 // prefer over percentage to avoid ovals for irregular rectangles }) }), color: _objectSpread(_objectSpread({}, color), {}, { background: _objectSpread(_objectSpread({}, color.background), {}, { infoLight: getLightVariant(color.background.info), criticalLight: getLightVariant(color.background.critical), positiveLight: getLightVariant(color.background.positive), cautionLight: getLightVariant(color.background.caution) }) }), spacing: _objectSpread(_objectSpread({}, spacing), {}, { none: 0 }), sizing: _objectSpread(_objectSpread({}, sizing), {}, { none: 0, full: '100%' }), typography: decorateTypography(typography) }, restTokens); return decoratedTokens; } // Export // ------------------------------ function makeSparkTheme(tokens) { var decoratedTokens = decorateTokens(tokens); return _objectSpread(_objectSpread({}, decoratedTokens), {}, { backgroundLightness: mapValues__default["default"](decoratedTokens.color.background, function (background) { return isLight(background) ? 'light' : 'dark'; }), utils: makeThemeUtils() }); } // Register your themes here // ------------------------------ var globalTheme = { brighte: makeSparkTheme(brighteTokens), pantheon: makeSparkTheme(pantheonTokens) }; var defaultTheme = makeSparkTheme(brighteTokens); var GlobalThemeContext = /*#__PURE__*/react.createContext('brighte'); var ThemeContext = /*#__PURE__*/react.createContext(defaultTheme); var useGlobalTheme = function useGlobalTheme() { return react.useContext(GlobalThemeContext); }; var useTheme = function useTheme() { return react.useContext(ThemeContext); }; var GlobalThemeProvider = GlobalThemeContext.Provider; var ThemeProvider = function ThemeProvider(_ref) { var children = _ref.children, themeName = _ref.theme; var globalThemeName = useGlobalTheme(); var theme = react.useMemo(function () { return globalTheme[themeName !== null && themeName !== void 0 ? themeName : globalThemeName]; }, [globalThemeName, themeName]); return jsxRuntime.jsx(ThemeContext.Provider, { value: theme, children: children }); }; var AESTETICO_REGULAR_URL = 'https://static-assets.prod.cloud.brighte.com.au/fonts/Aestetico-Regular.woff2'; var AESTETICO_SEMIBOLD_URL = 'https://static-assets.prod.cloud.brighte.com.au/fonts/Aestetico-SemiBold.woff2'; var styles$1 = "\n@import \"//hello.myfonts.net/count/46e60e\";\n\n@font-face {\n font-family: Aestetico;\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(".concat(AESTETICO_REGULAR_URL, ") format(\"woff2\");\n}\n\n@font-face {\n font-family: Aestetico;\n font-style: normal;\n font-weight: 600;\n font-display: swap;\n src: url(").concat(AESTETICO_SEMIBOLD_URL, ") format(\"woff2\");\n}\n").trim(); function AesteticoStylesheet() { return jsxRuntime.jsx(react$1.Global, { styles: styles$1 }); } var BEACON_SANS_REGULAR_URL = 'https://static-assets.prod.cloud.brighte.com.au/fonts/CBABeaconSans-Regular.woff2'; var BEACON_SANS_EXTRABOLD_URL = 'https://static-assets.prod.cloud.brighte.com.au/fonts/CBABeaconSans-ExtraBold.woff2'; var styles = "\n@font-face {\n font-family: 'CBA Beacon Sans';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(".concat(BEACON_SANS_REGULAR_URL, ") format(\"woff2\");\n}\n\n@font-face {\n font-family: 'CBA Beacon Sans';\n font-style: normal;\n font-weight: 800;\n font-display: swap;\n src: url(").concat(BEACON_SANS_EXTRABOLD_URL, ") format(\"woff2\");\n}\n").trim(); function BeaconSansStylesheet() { return jsxRuntime.jsx(react$1.Global, { styles: styles }); } exports.AESTETICO_REGULAR_URL = AESTETICO_REGULAR_URL; exports.AESTETICO_SEMIBOLD_URL = AESTETICO_SEMIBOLD_URL; exports.AesteticoStylesheet = AesteticoStylesheet; exports.BEACON_SANS_EXTRABOLD_URL = BEACON_SANS_EXTRABOLD_URL; exports.BEACON_SANS_REGULAR_URL = BEACON_SANS_REGULAR_URL; exports.BeaconSansStylesheet = BeaconSansStylesheet; exports.GlobalThemeContext = GlobalThemeContext; exports.GlobalThemeProvider = GlobalThemeProvider; exports.ThemeProvider = ThemeProvider; exports.createResponsiveMapFn = createResponsiveMapFn; exports.defaultTheme = defaultTheme; exports.defaultTokens = defaultTokens; exports.globalTheme = globalTheme; exports.isLight = isLight; exports.makeSparkTheme = makeSparkTheme; exports.useTheme = useTheme;