baseui
Version:
A React Component library implementing the Base design language
137 lines (132 loc) • 5.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StyledSubNavContainer = exports.StyledRoot = exports.StyledNavLink = exports.StyledNavItemElement = exports.StyledNavItemContainer = exports.StyledNavItem = void 0;
var React = _interopRequireWildcard(require("react"));
var _styles = require("../styles");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
/*
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 StyledRoot = exports.StyledRoot = (0, _styles.styled)('nav', props => {
const {
$theme: {
colors,
typography
}
} = props;
return {
...typography.font300,
color: colors.contentPrimary,
listStyleType: 'none',
marginTop: 0,
marginBottom: 0,
marginLeft: 0,
marginRight: 0,
paddingTop: 0,
paddingBottom: 0,
paddingLeft: 0,
paddingRight: 0
};
});
StyledRoot.displayName = "StyledRoot";
StyledRoot.displayName = 'StyledRoot';
const StyledNavItemContainer = exports.StyledNavItemContainer = (0, _styles.styled)('li', {});
StyledNavItemContainer.displayName = "StyledNavItemContainer";
StyledNavItemContainer.displayName = 'StyledNavItemContainer';
const StyledNavLink = exports.StyledNavLink = (0, _styles.styled)('a', ({
$theme,
$isFocusVisible
}) => ({
color: 'inherit',
outline: 'none',
textDecoration: 'none',
':focus > div': $isFocusVisible ? {
outline: `3px solid ${$theme.colors.borderAccent}`,
outlineOffset: '-3px',
borderLeftColor: 'transparent',
borderTopColor: 'transparent',
borderRightColor: 'transparent',
borderBottomColor: 'transparent'
} : {
outline: 'none'
}
}));
StyledNavLink.displayName = "StyledNavLink";
StyledNavLink.displayName = 'StyledNavLink';
// @ts-ignore
const StyledNavItemElement = exports.StyledNavItemElement = (0, _styles.styled)('div', props => {
const {
$active,
$selectable,
$level,
$disabled,
$theme,
$theme: {
colors,
sizing
}
} = props;
const bgImgGradient = (0, _styles.hexToRgb)(colors.backgroundPrimary, '0.92') || '';
const borderWidthDir = $theme.direction === 'rtl' ? 'borderRightWidth' : 'borderLeftWidth';
const borderStyleDir = $theme.direction === 'rtl' ? 'borderRightStyle' : 'borderLeftStyle';
const borderColorDir = $theme.direction === 'rtl' ? 'borderRightColor' : 'borderLeftColor';
const paddingPrefixDir = $theme.direction === 'rtl' ? 'paddingRight' : 'paddingLeft';
const paddingSuffixDir = $theme.direction === 'rtl' ? 'paddingLeft' : 'paddingRight';
let cursor = $selectable ? 'pointer' : 'default';
let color = $active ? colors.contentPrimary : null;
let hoverColor = $selectable ? colors.contentPrimary : null;
if ($disabled) {
cursor = 'not-allowed';
color = colors.contentStateDisabled;
hoverColor = null;
}
return {
backgroundColor: $active ? colors.backgroundInversePrimary : 'transparent',
backgroundImage: $active ? `linear-gradient(0deg, ${bgImgGradient}, ${bgImgGradient})` : null,
boxSizing: 'border-box',
[borderWidthDir]: '4px',
[borderStyleDir]: 'solid',
[borderColorDir]: $active ? colors.borderSelected : 'transparent',
color,
cursor,
paddingTop: sizing.scale500,
paddingBottom: sizing.scale500,
[paddingPrefixDir]: `calc(${sizing.scale800} * ${$level})`,
[paddingSuffixDir]: sizing.scale500,
':hover': {
color: hoverColor
},
':focus': {
color: $selectable ? colors.borderSelected : null
}
};
});
StyledNavItemElement.displayName = "StyledNavItemElement";
StyledNavItemElement.displayName = 'StyledNavItemElement';
// @ts-ignore
const StyledNavItem = exports.StyledNavItem = (0, _styles.withWrapper)(StyledNavItemElement, Styled =>
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function StyledNav({
item,
...restProps
}) {
return /*#__PURE__*/React.createElement(Styled, restProps);
});
const StyledSubNavContainer = exports.StyledSubNavContainer = (0, _styles.styled)('ul', {
listStyleType: 'none',
marginTop: 0,
marginBottom: 0,
marginLeft: 0,
marginRight: 0,
paddingTop: 0,
paddingBottom: 0,
paddingLeft: 0,
paddingRight: 0
});
StyledSubNavContainer.displayName = "StyledSubNavContainer";
StyledSubNavContainer.displayName = 'StyledSubNavContainer';