MCPcopy
hub / github.com/mui/material-ui / alpha

Function alpha

packages/mui-material/src/styles/createThemeNoVars.js:46–57  ·  view source on GitHub ↗
(color, coefficient)

Source from the content-addressed store, hash-verified

44function attachColorManipulators(theme) {
45 Object.assign(theme, {
46 alpha(color, coefficient) {
47 const obj = this || theme;
48 if (obj.colorSpace) {
49 return `oklch(from ${color} l c h / ${typeof coefficient === 'string' ? `calc(${coefficient})` : coefficient})`;
50 }
51 if (obj.vars) {
52 // To preserve the behavior of the CSS theme variables
53 // In the future, this could be replaced by `color-mix` (when https://caniuse.com/?search=color-mix reaches 95%).
54 return `rgba(${color.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g, 'var(--$1Channel)')} / ${typeof coefficient === 'string' ? `calc(${coefficient})` : coefficient})`;
55 }
56 return systemAlpha(color, parseAddition(coefficient));
57 },
58 lighten(color, coefficient) {
59 const obj = this || theme;
60 if (obj.colorSpace) {

Calls 1

parseAdditionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…