Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support null as a value for CSS object #229

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/pigment-css-react/src/utils/cssFnValueToVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,13 @@ function iterateAndReplaceFunctions(
includeThemeArg = false,
) {
const css = styleObj as StyleObj;
if (!css) {
return;
}
Object.keys(css).forEach((key) => {
const value = css[key];

if (typeof value === 'object') {
if (value && typeof value === 'object') {
if (!Array.isArray(value)) {
iterateAndReplaceFunctions(
value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,27 @@ process.env.NODE_ENV !== 'production'
: void 0;

process.env.NODE_ENV !== 'production' ? (App.muiName = 'App') : void 0;

const OutlinedInputInput = styled(InputBaseInput, {
name: 'MuiOutlinedInput',
slot: 'Input',
overridesResolver: inputBaseInputOverridesResolver,
})(({ theme }) => ({
padding: '16.5px 14px',
...(!theme.vars && {
'&:-webkit-autofill': {
WebkitBoxShadow: theme.palette.mode === 'light' ? null : '0 0 0 100px #266798 inset',
WebkitTextFillColor: theme.palette.mode === 'light' ? null : '#fff',
caretColor: theme.palette.mode === 'light' ? null : '#fff',
borderRadius: 'inherit',
Comment on lines +64 to +67
Copy link
Member Author

@siriwatknp siriwatknp Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that this throws an error without the fix.

},
}),
}));

const Component2 = styled.div(({ theme }) =>
theme.palette.mode === 'light'
? null
: {
backgroundColor: theme.palette.primary.main,
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@
.s1emg10t .s13xim6i {
display: none;
}
.o1l8bn4d {
padding: 16.5px 14px;
}
.o1l8bn4d:-webkit-autofill {
border-radius: inherit;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { styled as _styled5 } from '@pigment-css/react';
import _theme3 from '@pigment-css/react/theme';
import { styled as _styled4 } from '@pigment-css/react';
import _theme2 from '@pigment-css/react/theme';
import { styled as _styled, styled as _styled2, styled as _styled3 } from '@pigment-css/react';
import _theme from '@pigment-css/react/theme';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -27,3 +31,14 @@ process.env.NODE_ENV !== 'production'
})
: void 0;
process.env.NODE_ENV !== 'production' ? (App.muiName = 'App') : void 0;
const _exp7 = /*#__PURE__*/ () => InputBaseInput;
const OutlinedInputInput = /*#__PURE__*/ _styled4(_exp7(), {
name: 'MuiOutlinedInput',
slot: 'Input',
overridesResolver: inputBaseInputOverridesResolver,
})({
classes: ['o1l8bn4d'],
});
const Component2 = /*#__PURE__*/ _styled5('div')({
classes: ['c14kh110'],
});
1 change: 1 addition & 0 deletions packages/pigment-css-react/tests/styled/styled.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { runTransformation, expect } from '../testUtils';

const theme = {
palette: {
mode: 'light',
primary: {
main: 'red',
},
Expand Down
Loading