Skip to content

Commit 3e597b1

Browse files
Update website limitations from recent fixes and findings (#1792)
1 parent 393b72c commit 3e597b1

File tree

2 files changed

+27
-32
lines changed

2 files changed

+27
-32
lines changed

website/packages/docs/src/pages/limitations.mdx

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ section: 50-Guides
66

77
The architecture or design of Compiled prevents some things that are possible with runtime libraries. There are also some features we would like to add to Compiled in the future that we have not yet.
88

9-
## Runtime styles
9+
## Dynamic selectors
1010

11-
Styles can't be created at runtime which includes dynamic selectors as well.
11+
Styles with dynamic selectors can't be created (at runtime or extraction) and may result in missing styles. If the variable is a local static value instead it should work!
1212

1313
```jsx
1414
/** @jsxImportSource @compiled/react */
@@ -25,45 +25,40 @@ const styles = css({
2525
<div css={styles} />;
2626
```
2727

28-
If a dynamic value resolves to a static constant value however, it will work!
28+
## Mixing dynamic styles and indirect selectors
2929

30-
## Overlapping styles, caused by media queries and other at-rules
31-
32-
Media queries and other at-rules are sorted deterministically when stylesheet extraction is turned on. See [this page](/media-queries-and-other-at-rules) for more details of how the sorting works and what its limitations are.
30+
You cannot mix dynamic styles and indirect selectors (eg. `div + label` or `div ~ label`) as the dynamic value will not be applied to the indirect selector.
3331

34-
## Unsupported features
35-
36-
Below is a non-exhaustive list of features that Compiled does not support. Some are features we would like to add to Compiled at some point in the future, while others are features that we don't plan to implement.
37-
38-
### Ternary operators
39-
40-
There is a bug where ternary operators in the `css` prop won't work:
41-
42-
```tsx
43-
/** @jsxImportSource @compiled/react */
44-
import { css } from '@compiled/react';
32+
Example, this will result in `label` not having the inline `props.margin` applied as it will not have access to the CSS variable we inject:
4533

46-
const styles = css({ color: 'blue' });
47-
const otherStyles = css({ color: 'red' });
34+
```jsx
35+
export default (props) => {
36+
const styles = css({
37+
'& + label': {
38+
margin: `8px ${props.margin}`,
39+
},
40+
});
4841

49-
// build-time error
50-
const Component = <div css={isPrimary ? styles : otherStyles}>Hello</div>;
42+
return (
43+
<div>
44+
<span css={styles}>Hello</span>
45+
<label>world</label>
46+
</div>
47+
);
48+
};
5149
```
5250

53-
A workaround is to use the `&&` operator, which is supported:
51+
Additionally, this currently happens with certain non-dynamic styles in a typical babel setup for certain target outputs, but this may be less common.
5452

55-
```tsx
56-
/** @jsxImportSource @compiled/react */
57-
import { css } from '@compiled/react';
53+
For more details, refer to the [Github Issue](https://github.com/atlassian-labs/compiled/issues/1789).
5854

59-
const styles = css({ color: 'blue' });
60-
const otherStyles = css({ color: 'red' });
55+
## Overlapping styles, caused by media queries and other at-rules
6156

62-
// build-time error
63-
const Component = <div css={[isPrimary && styles, !isPrimary && otherStyles]}>Hello</div>;
64-
```
57+
Media queries and other at-rules are sorted deterministically when stylesheet extraction is turned on. See [this page](/media-queries-and-other-at-rules) for more details of how the sorting works and what its limitations are.
6558

66-
There is a [bug report on GitHub](https://github.com/atlassian-labs/compiled/issues/389) if you would like to stay updated.
59+
## Unsupported features
60+
61+
Below is a non-exhaustive list of features that Compiled does not support. Some are features we would like to add to Compiled at some point in the future, while others are features that we don't plan to implement.
6762

6863
### Theming
6964

website/packages/docs/src/pages/migrating.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ There exists a [codemod](/pkg-codemods#emotion-to-compiled) to streamline this.
5353

5454
For features that aren't available due to the compile-time nature of the library, read our [limitations](/limitations).
5555

56-
For Emotion-specific issues you may run into, see [Migrating from Emotion](/migrating-from-emotion).
56+
For Emotion-specific issues you may run into, see [Migrating from Emotion](/issues-with-emotion).

0 commit comments

Comments
 (0)