@blend-ui/core
Version:
Blend core cmponents
132 lines (116 loc) • 3.35 kB
JavaScript
import { objectSpread2 as _objectSpread2, objectWithoutProperties as _objectWithoutProperties, extends as _extends } from './_virtual/_rollupPluginBabelHelpers.js';
import React from 'react';
import styled from 'styled-components';
import PropTypes from 'prop-types';
import { typography, space } from 'styled-system';
import styledProps from '@styled-system/prop-types';
var _excluded = ["as"];
var customPropsList = {
bold: "fontWeight",
italic: "fontStyle"
};
var customProps = function customProps(props) {
//console.log("PROPS CUSTOM ", props);
var propsList = [];
Object.keys(props).forEach(function (p) {
if (Object.keys(customPropsList).indexOf(p) > -1) {
var cssProp = {};
if (p === "bold") {
cssProp[customPropsList[p]] = props.theme.fontWeights["semiBold"];
} else {
cssProp[customPropsList[p]] = p;
}
propsList.push(cssProp);
}
});
return propsList;
};
/*
//https://styled-system.com/how-it-works
const TextElement = styled.div`
${textStyle}
${typography}
${space}
${color}
${customProps}
color: ${props => (props.color ? props.color : "currentColor")};
font-family: ${props => (props.fontFamily ? props.fontFamily : "body")};
`;
*/
/*
//https://styled-components.com/releases
const TextElement = styled("div").withConfig({
shouldForwardProp: (prop, defaultValidatorFn) =>
!["color", "fontFamily"].includes(prop),
})`
${textStyle}
${typography}
${space}
${color}
${customProps}
`;
*/
var color = function color(props) {
//console.log("color PROPS ", props);
return {
color: props.colorStyle ? null : props.color ? props.color : props.theme.colors["textPrimary"]
};
};
var textStyles = function textStyles(props) {
return props.textStyle ? props.theme.textStyles[props.textStyle] : null;
};
var colorStyles = function colorStyles(props) {
return props.colorStyle ? props.theme.colorStyles.text[props.colorStyle] : null;
}; // https://styled-system.com/guides/build-a-box
var TextElement = styled.div.withConfig({
displayName: "Text__TextElement",
componentId: "sc-z9dcxz-0"
})(typography, space, textStyles, colorStyles, customProps, color);
var Text = function Text(_ref) {
var as = _ref.as,
props = _objectWithoutProperties(_ref, _excluded); //console.log("PROPS ", props);
//const {colors} = useTheme();
//console.log(colors);
/* color: themeGet("palette.primary.main")(props), */
return /*#__PURE__*/React.createElement(TextElement, _extends({
as: as
}, props));
};
Text.displayName = "Text";
Text.defaultProps = {
as: "div"
};
Text.propTypes = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, styledProps.space), styledProps.typography), styledProps.color), {}, {
bold: PropTypes.bool,
italic: PropTypes.bool
});
Text.__docgenInfo = {
"description": "",
"methods": [],
"displayName": "Text",
"props": {
"as": {
"defaultValue": {
"value": "\"div\"",
"computed": false
},
"required": false
},
"bold": {
"description": "",
"type": {
"name": "bool"
},
"required": false
},
"italic": {
"description": "",
"type": {
"name": "bool"
},
"required": false
}
},
"composes": ["@styled-system/prop-types"]
};
export { Text as default };