@chakra-v2/styled-system
Version:
Style function for css-in-js building component libraries
59 lines (56 loc) • 1.32 kB
JavaScript
import { memoizedGet } from '../get.mjs';
const srOnly = {
border: "0px",
clip: "rect(0, 0, 0, 0)",
width: "1px",
height: "1px",
margin: "-1px",
padding: "0px",
overflow: "hidden",
whiteSpace: "nowrap",
position: "absolute"
};
const srFocusable = {
position: "static",
width: "auto",
height: "auto",
clip: "auto",
padding: "0",
margin: "0",
overflow: "visible",
whiteSpace: "normal"
};
const getWithPriority = (theme, key, styles) => {
const result = {};
const obj = memoizedGet(theme, key, {});
for (const prop in obj) {
const isInStyles = prop in styles && styles[prop] != null;
if (!isInStyles)
result[prop] = obj[prop];
}
return result;
};
const others = {
srOnly: {
transform(value) {
if (value === true)
return srOnly;
if (value === "focusable")
return srFocusable;
return {};
}
},
layerStyle: {
processResult: true,
transform: (value, theme, styles) => getWithPriority(theme, `layerStyles.${value}`, styles)
},
textStyle: {
processResult: true,
transform: (value, theme, styles) => getWithPriority(theme, `textStyles.${value}`, styles)
},
apply: {
processResult: true,
transform: (value, theme, styles) => getWithPriority(theme, value, styles)
}
};
export { others };