UNPKG

baseui

Version:

A React Component library implementing the Base design language

385 lines (377 loc) • 12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StyledStep = exports.StyledProgressSteps = exports.StyledNumberStep = exports.StyledNumberIcon = exports.StyledNumberContentTail = exports.StyledInnerIcon = exports.StyledIconContainer = exports.StyledIcon = exports.StyledContentTitle = exports.StyledContentTail = exports.StyledContentDescription = exports.StyledContent = void 0; var _styles = require("../styles"); var _constants = require("./constants"); /* Copyright (c) Uber Technologies, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. */ const StyledProgressSteps = exports.StyledProgressSteps = (0, _styles.styled)('ol', ({ $theme, $orientation }) => { const horizontalStyles = { display: 'flex', justifyContent: 'space-between', width: '100%' }; const verticalStyles = { display: 'inline-block' }; return { ...($orientation === _constants.ORIENTATION.horizontal ? horizontalStyles : verticalStyles), marginBottom: 0, marginTop: 0, paddingTop: $theme.sizing.scale300, paddingRight: $theme.sizing.scale100, paddingLeft: $theme.sizing.scale100, paddingBottom: $theme.sizing.scale300 }; }); StyledProgressSteps.displayName = "StyledProgressSteps"; StyledProgressSteps.displayName = 'StyledProgressSteps'; // eslint-disable-next-line @typescript-eslint/no-unused-vars const StyledStep = exports.StyledStep = (0, _styles.styled)('li', ({ $orientation }) => { const horizontalStyles = { display: 'flex', flexDirection: 'column', alignItems: 'flex-start' }; return { listStyleType: 'none', position: 'relative', overflow: 'visible', ...($orientation === _constants.ORIENTATION.horizontal ? horizontalStyles : {}) }; }); StyledStep.displayName = "StyledStep"; StyledStep.displayName = 'StyledStep'; const StyledIconContainer = exports.StyledIconContainer = (0, _styles.styled)('div', ({ $theme, $isActive, $orientation }) => { const size = $isActive ? $theme.sizing.scale700 : $theme.sizing.scale500; const font = $theme.typography.LabelMedium; const getOrientationStyles = orientation => { if (orientation === _constants.ORIENTATION.horizontal) { return { marginLeft: '50px', height: '20px', width: '20px' }; } let marginLeft = $isActive ? $theme.sizing.scale750 : '26px'; let marginRight = $isActive ? $theme.sizing.scale750 : '26px'; const titlePad = $theme.sizing.scale800; const marginTop = `calc(${titlePad} + (${font.lineHeight} - ${size}) / 2)`; if ($theme.direction === 'rtl') { [marginLeft, marginRight] = [marginRight, marginLeft]; } return { float: $theme.direction === 'rtl' ? 'right' : 'left', marginRight, marginLeft, marginTop, width: size, height: size, lineHeight: size }; }; return { ...getOrientationStyles($orientation), backgroundColor: $theme.colors.backgroundPrimary, float: $theme.direction === 'rtl' ? 'right' : 'left', textAlign: 'center', display: 'flex', justifyContent: 'center', alignItems: 'center' }; }); StyledIconContainer.displayName = "StyledIconContainer"; StyledIconContainer.displayName = 'StyledIconContainer'; const StyledIcon = exports.StyledIcon = (0, _styles.styled)('div', ({ $theme, $isActive, $isCompleted, $orientation }) => { let currentColor = $theme.colors.contentTertiary; let size = $theme.sizing.scale300; if ($isCompleted) { currentColor = $theme.colors.contentPrimary; } else if ($isActive) { currentColor = $theme.colors.progressStepsActiveFill; } if ($isActive) { size = $theme.sizing.scale600; } const verticalStyles = { float: $theme.direction === 'rtl' ? 'right' : 'left' }; return { width: size, height: size, lineHeight: size, borderTopLeftRadius: size, borderTopRightRadius: size, borderBottomRightRadius: size, borderBottomLeftRadius: size, backgroundColor: currentColor, textAlign: 'center', display: 'flex', justifyContent: 'center', alignItems: 'center', ...($orientation === _constants.ORIENTATION.horizontal ? {} : verticalStyles) }; }); StyledIcon.displayName = "StyledIcon"; StyledIcon.displayName = 'StyledIcon'; const StyledInnerIcon = exports.StyledInnerIcon = (0, _styles.styled)('div', ({ $theme }) => { return { width: $theme.sizing.scale300, height: $theme.sizing.scale300, lineHeight: $theme.sizing.scale300, borderTopLeftRadius: $theme.sizing.scale300, borderTopRightRadius: $theme.sizing.scale300, borderBottomRightRadius: $theme.sizing.scale300, borderBottomLeftRadius: $theme.sizing.scale300, backgroundColor: $theme.colors.progressStepsActiveText, textAlign: 'center' }; }); StyledInnerIcon.displayName = "StyledInnerIcon"; StyledInnerIcon.displayName = 'StyledInnerIcon'; const StyledContent = exports.StyledContent = (0, _styles.styled)('div', ({ $theme, $orientation }) => { if ($orientation === _constants.ORIENTATION.horizontal) { return { marginTop: '8px', width: '120px', flex: 'display', flexDirection: 'column', justifyContent: 'start' }; } const marginDir = $theme.direction === 'rtl' ? 'marginRight' : 'marginLeft'; return { [marginDir]: $theme.sizing.scale1600 }; }); StyledContent.displayName = "StyledContent"; StyledContent.displayName = 'StyledContent'; const StyledContentTitle = exports.StyledContentTitle = (0, _styles.styled)('div', ({ $theme, $isCurrent, $isCompleted, $orientation }) => { let color = $theme.colors.contentTertiary; if ($isCompleted) { color = $theme.colors.contentPrimary; } else if ($isCurrent) { color = $theme.colors.contentPrimary; } let font = $theme.typography.LabelMedium; const horizontalStyles = { textAlign: 'center' }; const verticalStyles = { paddingTop: $theme.sizing.scale800, paddingBottom: $theme.sizing.scale800 }; return { ...font, color, ...($orientation === _constants.ORIENTATION.horizontal ? horizontalStyles : verticalStyles) }; }); StyledContentTitle.displayName = "StyledContentTitle"; StyledContentTitle.displayName = 'StyledContentTitle'; const StyledContentTail = exports.StyledContentTail = (0, _styles.styled)('div', ({ $theme, $isCompleted, $isActive, $orientation }) => { const getOrientationStyles = orientation => { const dir = $theme.direction === 'rtl' ? 'right' : 'left'; // horizontal styles if (orientation === _constants.ORIENTATION.horizontal) { return { position: 'relative', top: '9px', marginLeft: '-48px', marginRight: '-48px', height: $theme.sizing.scale0, width: '100%' }; } // vertical styles let size = $isActive ? $theme.sizing.scale700 : $theme.sizing.scale500; let font = $theme.typography.LabelMedium; let titlePad = $theme.sizing.scale800; return { position: 'absolute', marginTop: `calc(${titlePad} + (${font.lineHeight} + ${size}) / 2)`, [dir]: '31px', top: 0, height: `calc(100% + ${$theme.sizing.scale500})`, marginBottom: 0, width: $theme.sizing.scale0, display: 'inline-block' }; }; return { ...getOrientationStyles($orientation), backgroundColor: $isCompleted ? $theme.colors.borderSelected : $theme.colors.borderOpaque }; }); StyledContentTail.displayName = "StyledContentTail"; StyledContentTail.displayName = 'StyledContentTail'; const StyledContentDescription = exports.StyledContentDescription = (0, _styles.styled)('div', ({ $theme }) => { return { marginBottom: $theme.sizing.scale700 }; }); StyledContentDescription.displayName = "StyledContentDescription"; StyledContentDescription.displayName = 'StyledContentDescription'; const StyledNumberStep = exports.StyledNumberStep = (0, _styles.styled)('li', ({ $orientation }) => { const horizontalStyles = { display: 'flex', flexDirection: 'column', alignItems: 'flex-start' }; return { listStyleType: 'none', position: 'relative', overflow: 'visible', ...($orientation === _constants.ORIENTATION.horizontal ? horizontalStyles : {}) }; }); StyledNumberStep.displayName = "StyledNumberStep"; StyledNumberStep.displayName = 'StyledNumberStep'; const StyledNumberIcon = exports.StyledNumberIcon = (0, _styles.styled)('div', ({ $theme, $isActive, $isCurrent, $isCompleted, $orientation }) => { let backgroundColor = $theme.colors.backgroundTertiary; let color = $theme.colors.contentPrimary; const size = $theme.sizing.scale1200; const font = $theme.typography.ParagraphLarge; if ($isCompleted) { color = $theme.colors.progressStepsCompletedText; backgroundColor = $theme.colors.progressStepsCompletedFill; } else if ($isCurrent) { color = $theme.colors.progressStepsActiveText; backgroundColor = $theme.colors.progressStepsActiveFill; } const getOrientationStyles = orientation => { if (orientation === _constants.ORIENTATION.horizontal) { return { marginLeft: '36px' }; } else { let titlePad = $theme.sizing.scale800; let titleFont = $theme.typography.LabelMedium; return { marginLeft: $theme.sizing.scale300, marginRight: $theme.sizing.scale550, marginTop: `calc(${titlePad} + (${titleFont.lineHeight} - ${size}) / 2)` }; } }; return { ...getOrientationStyles($orientation), width: size, height: size, borderTopLeftRadius: size, borderTopRightRadius: size, borderBottomRightRadius: size, borderBottomLeftRadius: size, backgroundColor, color, float: $theme.direction === 'rtl' ? 'right' : 'left', textAlign: 'center', display: 'flex', justifyContent: 'center', alignItems: 'center', ...font, ...($isActive ? { position: 'relative', '::before': { content: '""', position: 'absolute', top: '-4px', left: '-4px', width: `calc(100% + 8px)`, height: `calc(100% + 8px)`, borderRadius: '50%', border: `2px solid ${$theme.colors.progressStepsActiveFill}`, boxSizing: 'border-box' } } : {}) }; }); StyledNumberIcon.displayName = "StyledNumberIcon"; StyledNumberIcon.displayName = 'StyledNumberIcon'; const StyledNumberContentTail = exports.StyledNumberContentTail = (0, _styles.styled)('div', ({ $theme, $isCompleted, $orientation, $isActive, $isRightBeforeActive }) => { const getOrientationStyles = orientation => { const dir = $theme.direction === 'rtl' ? 'right' : 'left'; // horizontal styles if (orientation === _constants.ORIENTATION.horizontal) { return { position: 'relative', top: '23px', marginLeft: $isActive ? '-32px' : '-36px', marginRight: $isRightBeforeActive ? '-32px' : '-36px', height: $theme.sizing.scale0, width: '100%' }; } // vertical styles const size = $theme.sizing.scale950; const titleFont = $theme.typography.LabelMedium; const titlePad = $theme.sizing.scale800; const marginTop = `calc(${titlePad} + ${size} + (${titleFont.lineHeight} - ${size}) / 2)`; return { position: 'absolute', [dir]: '31px', top: $isActive ? '10px' : '6px', height: `calc(100% - ${$isActive || $isRightBeforeActive ? $theme.sizing.scale900 : $theme.sizing.scale850})`, paddingBottom: 0, marginTop, width: $theme.sizing.scale0, display: 'inline-block' }; }; return { ...getOrientationStyles($orientation), backgroundColor: $isCompleted ? $theme.colors.contentPrimary : $theme.colors.backgroundTertiary }; }); StyledNumberContentTail.displayName = "StyledNumberContentTail"; StyledNumberContentTail.displayName = 'StyledNumberContentTail';