@cimpress/react-components
Version:
React components to support the MCP styleguide
170 lines (161 loc) • 4.14 kB
JavaScript
/* eslint-disable import/prefer-default-export */
import { css } from '@emotion/css';
import cvar from '../theme/cvar';
export const inlineEdit = css `
position: relative;
display: flex;
max-width: 100%;
min-width: 130px;
.crc-inline-edit--inactive {
border-bottom: 1px dashed ${cvar('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: ${cvar('color-inline-edit-border')};
vertical-align: top;
display: none;
}
&:hover {
background-color: ${cvar('color-button-secondary-hover')};
cursor: pointer;
padding-right: 5px;
.crc-inline-edit__edit-icon {
display: inline-flex;
}
}
}
&.disabled {
border-bottom: 1px dashed ${cvar('color-background-disabled')};
p {
color: ${cvar('color-background-disabled')};
&:hover {
background-color: transparent;
cursor: not-allowed;
&:after {
content: none;
}
}
}
}
}
`;
export const labelStyle = css `
color: ${cvar('color-text-label')};
font-weight: normal;
position: absolute;
left: 0px;
top: 0px;
line-height: 14px;
transition: all 0.2s ease-out;
z-index: 5;
`;
export const sizeStyle = {
position: 'absolute',
top: 0,
left: 0,
visibility: 'hidden',
height: 0,
overflow: 'scroll',
whiteSpace: 'pre',
};
export const formControl = 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;
`;
export const inputBaseStyle = (size) => {
const fontSizeStyle = size !== 'default'
? css `
// Disable all top and bottom margin inherent with the heading and small elements.
&.${size} {
margin-bottom: 0;
margin-top: 0;
font-size: ${cvar(`text-size-${size}`)};
}
`
: '';
return 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 ${cvar('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% * ${cvar('text-size-small')}/ ${cvar('text-size-base')};
}
`;
};
// For content that is appended to the input/p tag
export const rightAddOn = css `
display: flex;
align-items: flex-end;
justify-content: space-between;
padding: 0px 5px;
button {
background: ${cvar('color-button-default')};
color: ${cvar('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: ${cvar('color-button-secondary-active')};
}
}
`;
// For error text below the input
export const errorMessage = css `
color: ${cvar('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: ${cvar('color-code-literal')};
}
}
`;
export const successIconWrapper = css `
margin-left: 5px;
display: inline;
`;
//# sourceMappingURL=styles.js.map