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

Fix css prop inline media style applied #37

Merged
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
11 changes: 10 additions & 1 deletion example/src/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ export default function Example() {
<Heading heading="h3">Heading</Heading>
<Heading heading="h4">Heading</Heading>
<Heading heading="h5">Heading</Heading>
<Heading underlined>Compound Variants</Heading>
<Heading
// NOTE: test inline media style.
// marginTopRem util function turns media style.
css={{
marginTopRem: 1,
}}
underlined
>
Compound Variants
</Heading>
<Heading underlined heading="h2">
Heading
</Heading>
Expand Down
7 changes: 6 additions & 1 deletion src/internals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,19 @@ export function createStitches(config = {}) {
.filter(Boolean);
}

const cssStyles = props.css
let cssStyles = props.css
? utils.processStyles({
styles: props.css || {},
theme: theme.values,
config,
})
: {};

if (cssStyles && breakpoint in cssStyles) {
// WARNING: lodash merge modifies the first argument reference or skips if object is frozen.
cssStyles = merge({}, cssStyles, cssStyles[breakpoint]);
}

const mediaStyle = styleSheet.base[breakpoint] || {};

const stitchesStyles = [
Expand Down