@cimpress/react-components
Version:
React components to support the MCP styleguide
177 lines (168 loc) • 4.89 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.successIconWrapper = exports.errorMessage = exports.rightAddOn = exports.inputBaseStyle = exports.formControl = exports.sizeStyle = exports.labelStyle = exports.inlineEdit = void 0;
/* eslint-disable import/prefer-default-export */
const css_1 = require("@emotion/css");
const cvar_1 = __importDefault(require("../theme/cvar"));
exports.inlineEdit = (0, css_1.css) `
position: relative;
display: flex;
max-width: 100%;
min-width: 130px;
.crc-inline-edit--inactive {
border-bottom: 1px dashed ${(0, cvar_1.default)('color-inline-edit-border')};
max-width: 100%;
margin-top: 15px;
line-height: 20px;
p {
margin: 0;
padding: 2px 0 2px 1px;
word-break: break-all;
.crc-inline-edit__edit-icon {
margin-left: 5px;
color: ${(0, cvar_1.default)('color-inline-edit-border')};
vertical-align: top;
display: none;
}
&:hover {
background-color: ${(0, cvar_1.default)('color-button-secondary-hover')};
cursor: pointer;
padding-right: 5px;
.crc-inline-edit__edit-icon {
display: inline-flex;
}
}
}
&.disabled {
border-bottom: 1px dashed ${(0, cvar_1.default)('color-background-disabled')};
p {
color: ${(0, cvar_1.default)('color-background-disabled')};
&:hover {
background-color: transparent;
cursor: not-allowed;
&:after {
content: none;
}
}
}
}
}
`;
exports.labelStyle = (0, css_1.css) `
color: ${(0, cvar_1.default)('color-text-label')};
font-weight: normal;
position: absolute;
left: 0px;
top: 0px;
line-height: 14px;
transition: all 0.2s ease-out;
z-index: 5;
`;
exports.sizeStyle = {
position: 'absolute',
top: 0,
left: 0,
visibility: 'hidden',
height: 0,
overflow: 'scroll',
whiteSpace: 'pre',
};
exports.formControl = (0, css_1.css) `
display: block;
width: 100%;
height: auto;
padding: 10px 24px;
background-color: #fff;
background-image: none;
border: 1px solid #c4cdd6;
border-radius: 2px;
box-shadow: inset 0 1px 1px rgb(0 0 0 / 8%);
transition: border-color ease-in-out;
`;
const inputBaseStyle = (size) => {
const fontSizeStyle = size !== 'default'
? (0, css_1.css) `
// Disable all top and bottom margin inherent with the heading and small elements.
&.${size} {
margin-bottom: 0;
margin-top: 0;
font-size: ${(0, cvar_1.default)(`text-size-${size}`)};
}
`
: '';
return (0, css_1.css) `
box-shadow: none;
flex: 1;
padding: 17px 2px 2px 2px;
font-size: 14px;
transition: all 0.2s ease-out;
border: none;
border-bottom: 1px solid ${(0, cvar_1.default)('color-inline-edit-border')};
min-width: 50px;
max-width: 100%;
line-height: 20px;
&:focus {
box-shadow: none;
outline-offset: 2px;
}
${fontSizeStyle}
&.small {
// This is a copy + paste of how Bootstrap sizes text in <small> tags.
// Simply using $font-size-small will result in this having a slightly different size than the
// element used for measuring the width of the input, so things will be slightly out-of-sync.
font-size: floor((100% * ${(0, cvar_1.default)('text-size-small')}/ ${(0, cvar_1.default)('text-size-base')};
}
`;
};
exports.inputBaseStyle = inputBaseStyle;
// For content that is appended to the input/p tag
exports.rightAddOn = (0, css_1.css) `
display: flex;
align-items: flex-end;
justify-content: space-between;
padding: 0px 5px;
button {
background: ${(0, cvar_1.default)('color-button-default')};
color: ${(0, cvar_1.default)('color-inline-edit-border')};
font-size: 16px;
border-radius: 2px;
border: none;
padding: 1px 2px 1px 2px;
margin: 2px;
width: 24px;
height: 24px;
box-shadow: 0px 2px 4px 0px rgba(58, 65, 76, 0.5);
line-height: 16px;
&:hover {
cursor: pointer;
background-color: ${(0, cvar_1.default)('color-button-secondary-active')};
}
}
`;
// For error text below the input
exports.errorMessage = (0, css_1.css) `
color: ${(0, cvar_1.default)('color-background-error')};
font-weight: normal;
position: absolute;
left: 2px;
top: 48px;
line-height: 14px;
margin-bottom: 0;
transition: all 0.2s ease-out;
z-index: 5;
&.required {
.resting-label::after,
label::after {
content: ' *';
color: ${(0, cvar_1.default)('color-code-literal')};
}
}
`;
exports.successIconWrapper = (0, css_1.css) `
margin-left: 5px;
display: inline;
`;
//# sourceMappingURL=styles.js.map