@atlaskit/css 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/css
2
2
 
3
+ ## 0.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#165531](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/165531)
8
+ [`57f451bda8919`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/57f451bda8919) -
9
+ Adds side-effect config to support Compiled css extraction in third-party apps
10
+
3
11
  ## 0.6.1
4
12
 
5
13
  ### Patch Changes
@@ -8,8 +8,11 @@ import SectionMessage from '@atlaskit/section-message';
8
8
 
9
9
  <SectionMessage title="Migration from Emotion to Compiled" appearance="discovery">
10
10
  <p>
11
- The Atlassian Design System is under the process of migrating from Emotion to Compiled for our
12
- CSS-in-JS. Further details to come.
11
+ The Atlassian Design System is migrating from Emotion to Compiled CSS-in-JS. This transition
12
+ aims to improve performance and align with modern React features.{' '}
13
+ <a href="https://community.developer.atlassian.com/t/rfc-73-migrating-our-components-to-compiled-css-in-js/85953">
14
+ Read our RFC to learn more.
15
+ </a>
13
16
  </p>
14
17
  </SectionMessage>
15
18
 
@@ -53,6 +56,10 @@ The codemod should migrate something like this:
53
56
  +export const MyComponent = () => <Box xcss={styles.root} />;
54
57
  ```
55
58
 
59
+ The codemod will migrate most usecases, but there is a known issue that it's unable to handle any
60
+ logical operators in the `xcss` property. If you have any logical operators in your `xcss` property,
61
+ you will need to manually update them.
62
+
56
63
  Please note there may be very minute differences in this migration if you do not have theming
57
64
  enabled as `@atlaskit/primitives` and the Compiled variant of `@atlaskit/primitives/compiled` have
58
65
  different fallback colors. They are unchanged with theming applied, this will only happen if you're
@@ -6,45 +6,47 @@ import SectionMessage from '@atlaskit/section-message';
6
6
 
7
7
  <SectionMessage title="Migration from Emotion to Compiled" appearance="discovery">
8
8
  <p>
9
- The Atlassian Design System is under the process of migrating from Emotion to Compiled for our
10
- CSS-in-JS. Further details to come.
9
+ The Atlassian Design System is migrating from Emotion to Compiled CSS-in-JS. This transition
10
+ aims to improve performance and align with modern React features.{' '}
11
+ <a href="https://community.developer.atlassian.com/t/rfc-73-migrating-our-components-to-compiled-css-in-js/85953">
12
+ Read our RFC to learn more.
13
+ </a>
11
14
  </p>
12
15
  </SectionMessage>
13
16
 
14
- `@atlaskit/css` is the replacement for `@atlaskit/primitives.xcss`, refer to
15
- [Migration](/components/css/migration) for details migrating.
17
+ `@atlaskit/css` is the replacement for `@atlaskit/primitives.xcss`. It serves as a bounded styling
18
+ library for use with native HTML elements and the Atlassian Design System, including
19
+ [primitive components](/components/primitives).
16
20
 
17
- This is a bounded styling library to be used both with native styles (`<div>`) and the Atlassian
18
- Design System, such as our [primitive components](/components/primitives).
21
+ Built on [Compiled CSS-in-JS](https://compiledcssinjs.com/), it provides a performant, static
22
+ styling solution with some syntax changes. Notably, dynamic styles and certain imports/exports may
23
+ not work as before.
19
24
 
20
- This is built on top of [Compiled CSS-in-JS](https://compiledcssinjs.com/) which is a much more
21
- performant, static styling solution with the same syntax and a few breaking changes—the primary ones
22
- being dynamic styles as well as deep imports or exports for reuse of styles may not work.
23
-
24
- This will require configuration, refer to our
25
- [Get started](/get-started/develop#set-up-your-bundling-environment) guide.
25
+ For configuration details, see our
26
+ [Get Started](/get-started/develop#set-up-your-bundling-environment) guide.
26
27
 
27
28
  ## Usage
28
29
 
29
- For the most part, `@atlaskit/css` should behave like `@compiled/react` or other CSS-in-JS
30
- libraries' `css()` syntaxes, however we promote `cssMap` as a way to create maps of styles as that's
31
- the common use-case at Atlassian.
30
+ `@atlaskit/css` closely resembles the behavior of `@compiled/react` and other CSS-in-JS libraries'
31
+ `css()` functions. However, we encourage using `cssMap` to create style maps, as the common practice
32
+ at Atlassian.
32
33
 
33
- Please note that `@atlaskit/css` is a strictly bounded variant to help promote and align the usage
34
- of Design System tokens and properties, so you you cannot use arbitrary values such as
35
- `color: 'rgba(123, 45, 67)', padding: 8`, and typically we only allow our
36
- [tokenized values](/components/tokens/all-tokens), but a few other property restrictions or
37
- limitations exist, such as `zIndex` only having a few allowed literal numeric values.
34
+ This is a strictly bounded variant designed to align the use of
35
+ [Design System tokens](<(/components/tokens/all-tokens)>) and properties. You cannot use arbitrary
36
+ values, such as `color: 'rgba(123, 45, 67)'` nor `padding: 8`. Typically, only tokenized values are
37
+ allowed. Additionally, there are some restrictions, such as `zIndex`, which only supports a limited
38
+ set of numeric values.
38
39
 
39
40
  ### cssMap
40
41
 
41
- `cssMap` is the default function we suggest to use, it can be reused across native elements through
42
- `props.css` and React components through `props.xcss` and is flexible to style maps that are known
43
- ahead-of-time.
44
-
45
- These can be reused across multiple components, even across native and non-native.
42
+ We recommend using `cssMap` to create style maps. These maps can be applied and reused on both
43
+ native elements and React components using `props.css` and `props.xcss`.
46
44
 
47
45
  ```tsx
46
+ /**
47
+ * @jsxRuntime classic
48
+ * @jsx jsx
49
+ */
48
50
  import { cssMap } from '@atlaskit/css';
49
51
  const styles = cssMap({
50
52
  root: { display: 'inline-block' },
@@ -73,9 +75,8 @@ export default ({
73
75
 
74
76
  ### cx
75
77
 
76
- The `cx` function is required when combining styles inside of an `xcss` prop, but can be used
77
- anywhere. This is only required because `xcss={[styles.root, styles.bordered]}` results in incorrect
78
- typing while with a function it is preserved.
78
+ Use the `cx` function when combining styles in an `xcss` prop to maintain correct typing. This is
79
+ not required for native elements, but still works with or without.
79
80
 
80
81
  ```tsx
81
82
  <div css={[styles.root, styles.bordered]} />
@@ -83,7 +84,7 @@ typing while with a function it is preserved.
83
84
  <Box xcss={cx(styles.root, styles.bordered)} />
84
85
  ```
85
86
 
86
- ### Typical example
87
+ ### JSX pragma
87
88
 
88
89
  You must have a JSX pragma in scope in order to use this, depending on your setup this may be
89
90
  automatic, require `React` imported, or require `jsx` imported.
@@ -128,14 +129,15 @@ export default ({
128
129
  };
129
130
  ```
130
131
 
131
- ### Building a reusable component with pass-through styles
132
+ ## Building reusable components
132
133
 
133
- With the introduction of `@atlaskit/css` (and the underlying `createStrictAPI` from Compiled), we're
134
- now able to define a strictly bounded API for our components. This may be an API pattern that you
135
- want to copy as well.
134
+ With the introduction of `@atlaskit/css`, and leveraging the underlying `createStrictAPI` from
135
+ Compiled, we've established a strictly bounded API for our components. This approach ensures
136
+ consistency and alignment with our Design System, and it might be an API pattern you find beneficial
137
+ to adopt in your own projects.
136
138
 
137
- For example, if you want to create your own component that allows you to extend and pass-through
138
- styles, you can do so:
139
+ For instance, if you want to create a component that allows you to extend and pass-through styles,
140
+ you can do so:
139
141
 
140
142
  ```tsx
141
143
  /**
@@ -153,11 +155,10 @@ const styles = cssMap({
153
155
  export function Card({
154
156
  children,
155
157
  xcss,
156
- dense,
158
+ isDense,
157
159
  }: {
158
160
  children: React.ReactNode;
159
- dense?: boolean;
160
- /** Only `padding`, `borderRadius`, `backgroundColor`, and `color` properties and `hover` and `focus` pseudos are allowed */
161
+ isDense?: boolean;
161
162
  xcss?: StrictXCSSProp<
162
163
  'padding' | 'borderRadius' | 'backgroundColor' | 'color',
163
164
  '&:hover' | '&:focus'
@@ -171,8 +172,7 @@ export function Card({
171
172
  }
172
173
  ```
173
174
 
174
- I'm then allowed to build a component that uses this `Card` component and overrides these properties
175
- as I see fit:
175
+ You can then build a component using this Card component and override its properties as needed:
176
176
 
177
177
  ```tsx
178
178
  /**
@@ -229,6 +229,46 @@ export function Card({
229
229
  }
230
230
  ```
231
231
 
232
+ ### Unbounded styles
233
+
234
+ If you need to apply styles that aren't tokenized, or styles that aren't within the `@atlaskit/css`
235
+ API, you can use the `cssMap()` function from `@compiled/react` directly on native HTML elements.
236
+ Note that this won't work on primitive components. While it's best to stick to the Design System
237
+ guidelines, this option can be useful for handling specific edge cases. Please note this isn't
238
+ recommended for general use.
239
+
240
+ ```tsx
241
+ /**
242
+ * @jsxRuntime classic
243
+ * @jsx jsx
244
+ */
245
+ import { cssMap } from '@compiled/react';
246
+
247
+ import { jsx } from '@atlaskit/css';
248
+ import { token } from '@atlaskit/tokens';
249
+
250
+ const unboundedStyles = cssMap({
251
+ container: {
252
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors
253
+ '&:first-child': {
254
+ paddingBlockEnd: token('space.150'),
255
+ },
256
+ '@media (min-width: 48rem)': {
257
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors
258
+ '&:first-child': {
259
+ paddingBlockStart: token('space.400'),
260
+ },
261
+ },
262
+ },
263
+ });
264
+
265
+ const Container = ({ children, testId }: ContainerProps) => (
266
+ <div css={unboundedStyles.container} data-testid={testId}>
267
+ {children}
268
+ </div>
269
+ );
270
+ ```
271
+
232
272
  ## Configuration required
233
273
 
234
274
  In order to use any Atlassian Design System packages that distribute Compiled CSS-in-JS, you
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/css",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Style components backed by Atlassian Design System design tokens powered by Compiled CSS-in-JS.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -15,7 +15,14 @@
15
15
  "category": "Libraries",
16
16
  "ignorePropTypes": true,
17
17
  "status": {
18
- "type": "beta"
18
+ "type": "beta",
19
+ "description": "The Atlassian Design System is migrating from Emotion to Compiled CSS-in-JS. This transition aims to improve performance and align with modern React features.",
20
+ "actions": [
21
+ {
22
+ "text": "View RFC",
23
+ "href": "https://community.developer.atlassian.com/t/rfc-73-migrating-our-components-to-compiled-css-in-js/85953"
24
+ }
25
+ ]
19
26
  }
20
27
  }
21
28
  },
@@ -32,7 +39,9 @@
32
39
  ]
33
40
  }
34
41
  },
35
- "sideEffects": false,
42
+ "sideEffects": [
43
+ "**/*.compiled.css"
44
+ ],
36
45
  "atlaskit:src": "src/index.tsx",
37
46
  "af:exports": {
38
47
  ".": "./src/index.tsx"
@@ -48,7 +57,7 @@
48
57
  "devDependencies": {
49
58
  "@af/integration-testing": "*",
50
59
  "@af/visual-regression": "*",
51
- "@atlaskit/ds-lib": "^3.1.0",
60
+ "@atlaskit/ds-lib": "^3.2.0",
52
61
  "@atlaskit/ssr": "*",
53
62
  "@atlaskit/visual-regression": "*",
54
63
  "@emotion/react": "^11.7.1",