@elastic/eui 94.5.1 → 94.5.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/es/components/date_picker/date_picker.js +4 -1
- package/es/components/date_picker/react-datepicker/src/index.js +7 -2
- package/es/components/drag_and_drop/drag_drop_context.js +0 -2
- package/es/components/flex/flex_group.js +4 -3
- package/es/components/flex/flex_item.js +4 -3
- package/es/components/table/table_header_cell.js +1 -1
- package/es/components/table/table_header_cell_checkbox.js +2 -1
- package/es/components/table/table_header_cell_shared.js +9 -0
- package/eui.d.ts +29 -24
- package/i18ntokens.json +6 -6
- package/lib/components/date_picker/date_picker.js +4 -1
- package/lib/components/date_picker/react-datepicker/src/index.js +7 -2
- package/lib/components/drag_and_drop/drag_drop_context.js +0 -1
- package/lib/components/flex/flex_group.js +4 -3
- package/lib/components/flex/flex_item.js +4 -3
- package/lib/components/table/table_header_cell.js +1 -1
- package/lib/components/table/table_header_cell_checkbox.js +2 -1
- package/lib/components/table/table_header_cell_shared.js +16 -0
- package/optimize/es/components/date_picker/date_picker.js +4 -1
- package/optimize/es/components/date_picker/react-datepicker/src/index.js +7 -2
- package/optimize/es/components/drag_and_drop/drag_drop_context.js +0 -2
- package/optimize/es/components/flex/flex_group.js +4 -3
- package/optimize/es/components/flex/flex_item.js +4 -3
- package/optimize/es/components/table/table_header_cell_checkbox.js +1 -0
- package/optimize/es/components/table/table_header_cell_shared.js +9 -0
- package/optimize/lib/components/date_picker/date_picker.js +4 -1
- package/optimize/lib/components/date_picker/react-datepicker/src/index.js +7 -2
- package/optimize/lib/components/drag_and_drop/drag_drop_context.js +0 -1
- package/optimize/lib/components/flex/flex_group.js +4 -3
- package/optimize/lib/components/flex/flex_item.js +4 -3
- package/optimize/lib/components/table/table_header_cell_checkbox.js +1 -0
- package/optimize/lib/components/table/table_header_cell_shared.js +16 -0
- package/package.json +1 -1
- package/test-env/components/date_picker/date_picker.js +4 -1
- package/test-env/components/date_picker/react-datepicker/src/index.js +7 -2
- package/test-env/components/drag_and_drop/drag_drop_context.js +0 -1
- package/test-env/components/flex/flex_group.js +4 -3
- package/test-env/components/flex/flex_item.js +4 -3
- package/test-env/components/table/table_header_cell.js +1 -1
- package/test-env/components/table/table_header_cell_checkbox.js +2 -1
- package/test-env/components/table/table_header_cell_shared.js +16 -0
- package/src/components/date_picker/react-datepicker/LICENSE +0 -21
- package/src/components/date_picker/react-datepicker/README.md +0 -168
- package/src/services/theme/README.md +0 -153
- package/src/test/README.md +0 -44
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
# JavaScript-based theming in EUI
|
|
2
|
-
|
|
3
|
-
The style system to replace Sass and Sass-based design tokens in EUI.
|
|
4
|
-
|
|
5
|
-
* Theme construction via a Proxy-based system with cascading and computed values
|
|
6
|
-
* Proxy-based: allows for the theme system to reference its own values (for reuse or for computational manipulation)
|
|
7
|
-
* Cascading: conceptually similar to Sass, where variable location and order are important
|
|
8
|
-
* Extendable: allows for appending style variables to the EUI theme structure, scoped to a React context provider
|
|
9
|
-
* Override-able: all theme tokens/variables can be altered by consumers
|
|
10
|
-
* Theme consumption via React hook and HOC methods
|
|
11
|
-
* Color mode support as first-class consideration
|
|
12
|
-
* "Light" and "dark" mode accounting
|
|
13
|
-
* Theme consumption is scoped to the current color mode (set in the context provider)
|
|
14
|
-
* Style adaptaion based on a smal set of base values
|
|
15
|
-
* Text colors are calculated with WCAG Level AA (4.5:1) in mind
|
|
16
|
-
* Scalable typographic and spacing rhythms
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## Layers of the theme system
|
|
20
|
-
|
|
21
|
-
### Unbuilt theme
|
|
22
|
-
|
|
23
|
-
_See [`euiThemeDefault`](../../themes/eui/theme.ts)_
|
|
24
|
-
An unbuilt theme is a composed object of style values or `computed` functions.
|
|
25
|
-
|
|
26
|
-
#### Style values
|
|
27
|
-
|
|
28
|
-
Think design tokens or CSS property values. Ready to be consumed as-is in an application environment, using some JavaScript method of applying styles (i.e., a CSS-in-JS library is not required).
|
|
29
|
-
|
|
30
|
-
#### `computed` functions
|
|
31
|
-
|
|
32
|
-
These properties specify that the value depends upon some other value in the theme, in the shape of:
|
|
33
|
-
|
|
34
|
-
```js
|
|
35
|
-
computed(
|
|
36
|
-
([size]) => size * 2 // predicate. What to do with the dependency values,
|
|
37
|
-
['sizes.euiSize'], // dependency array, referencing other properties in the theme object
|
|
38
|
-
)
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
The dependency array is optional. Omitting the array gives access to the computed theme.
|
|
42
|
-
|
|
43
|
-
```js
|
|
44
|
-
computed(
|
|
45
|
-
(theme) => theme.sizes.euiSize * 2
|
|
46
|
-
)
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Theme system (built theme)
|
|
50
|
-
|
|
51
|
-
_See [`EuiThemeDefault`](../../themes/eui/theme.ts)_
|
|
52
|
-
A built theme by way of `buildTheme`, which transforms the object containing static style values and `computed` functions into a JavaScript Proxy object with handler traps. In this state, the theme is essentially inaccessible and immutable, that is, it requires `getComputed` to correctly order and access values and dependencies, and `set()` is disabled.
|
|
53
|
-
|
|
54
|
-
### Computed theme
|
|
55
|
-
|
|
56
|
-
_See [`EuiThemeContext`](../../themes/eui/context.ts)_
|
|
57
|
-
A consumable theme object in which all `computed` function values have been computed; all values are accessible and usable in an application environment.
|
|
58
|
-
Returned from `getComputed`, in the shape of:
|
|
59
|
-
|
|
60
|
-
```js
|
|
61
|
-
getComputed(
|
|
62
|
-
EuiThemeDefault, // Theme system (Proxy)
|
|
63
|
-
{}, // Modifications object
|
|
64
|
-
'light' // Color mode
|
|
65
|
-
)
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
#### Modifications
|
|
69
|
-
|
|
70
|
-
Because the theme system (built theme) is immutable, modifications can only be made at compute time by providing overrides and extensions for theme property values. These modifications are passed to the `EuiThemeProvider` via the `modify` prop and should match the high-level object shape of the theme.
|
|
71
|
-
|
|
72
|
-
#### Color mode
|
|
73
|
-
|
|
74
|
-
Think light and dark mode. A theme has built-in color mode support, using the reserved `LIGHT` and `DARK` keys as a marker:
|
|
75
|
-
|
|
76
|
-
```js
|
|
77
|
-
colors: {
|
|
78
|
-
LIGHT: {...}
|
|
79
|
-
DARK : {...}
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
The reserved color mode keys can be used at any level and location in a theme.
|
|
83
|
-
`getComputed` will only compute and return values in the specified current color mode.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
## React-specific context
|
|
87
|
-
|
|
88
|
-
### EuiThemeProvider
|
|
89
|
-
|
|
90
|
-
_See [`EuiThemeProvider`](../../themes/eui/provider.ts)_
|
|
91
|
-
Umbrella provider component that holds the various top-level theme configuration option providers: theme system, color mode, modifications; as well as the primary output provider: computed theme.
|
|
92
|
-
The actual computation for computed theme values takes place at this level, where the three inputs are known (theme system, color mode, modifications) and the output (computed theme) can be cached for consumption. Input changes are captured and the output is recomputed.
|
|
93
|
-
|
|
94
|
-
```js
|
|
95
|
-
<EuiThemeProvider
|
|
96
|
-
theme={DefaultEuiTheme}
|
|
97
|
-
colorMode="light"
|
|
98
|
-
modify={{}}
|
|
99
|
-
/>
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
All three props are optional. The default values for EUI will be used in the event that no configuration is provided. Note, however that colorMode switching will require consumers to maintain that app state.
|
|
103
|
-
|
|
104
|
-
### useEuiTheme
|
|
105
|
-
|
|
106
|
-
_See [`useEuiTheme`](../../themes/eui/hooks.tsx)_
|
|
107
|
-
A custom React hook that returns the computed theme. This hook is little more than a wrapper around the `useContext` hook, accessing three of the top-level providers: computed theme, color mode, and modifications.
|
|
108
|
-
|
|
109
|
-
```js
|
|
110
|
-
const { euiTheme, colorMode, modifications } = useEuiTheme();
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
The `euiTheme` variable has TypeScript support, which will result in IDE autocomplete availability.
|
|
114
|
-
|
|
115
|
-
### WithEuiTheme
|
|
116
|
-
A higher-order-component that wraps `useEuiTheme` for React class components.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
___
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
## Emotion
|
|
123
|
-
|
|
124
|
-
[Emotion](https://emotion.sh/docs/introduction) is the CSS-in-JS library currently selected for use in EUI. Nothing in the EUI theming system is dependent upon Emotion packages, but the Emotion ecosystem will have impacts on generated styles.
|
|
125
|
-
|
|
126
|
-
### Composition
|
|
127
|
-
|
|
128
|
-
* Prefer the use of [`css` prop](https://emotion.sh/docs/css-prop) construction over [styled-component-like](https://emotion.sh/docs/styled) component construction
|
|
129
|
-
* Babel-based build accommodation
|
|
130
|
-
|
|
131
|
-
### Testing
|
|
132
|
-
|
|
133
|
-
Snapshot testing ([as currently configured](https://emotion.sh/docs/testing#writing-a-test)) will result in generic `emotion-${n}` class names with the generated style object as part of the snapshot.
|
|
134
|
-
|
|
135
|
-
* This seems good for EUI, but it also affects consumers
|
|
136
|
-
* Consumers will need to use the `@emotion/jest` snapshot serializer to avoid class name churn.
|
|
137
|
-
* Not ideal; unsure of any other solutions
|
|
138
|
-
* During the conversion process, the snapshot diffs will look less than ideal when using `shallow` (a single wrapper element; DOM itself is unchanged):
|
|
139
|
-
|
|
140
|
-
```diff
|
|
141
|
-
- <div
|
|
142
|
-
- className="euiTableRowCell__mobileHeader euiTableRowCell--hideForDesktop"
|
|
143
|
-
+ <EmotionCssPropInternal
|
|
144
|
-
+ __EMOTION_LABEL_PLEASE_DO_NOT_USE__="EuiTableRowCell"
|
|
145
|
-
+ __EMOTION_TYPE_PLEASE_DO_NOT_USE__="td"
|
|
146
|
-
+ className="euiTableRowCell"
|
|
147
|
-
+ style={
|
|
148
|
-
+ Object {
|
|
149
|
-
+ "width": undefined,
|
|
150
|
-
+ }
|
|
151
|
-
+ }
|
|
152
|
-
>
|
|
153
|
-
```
|
package/src/test/README.md
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# Testing-related utilities
|
|
2
|
-
|
|
3
|
-
EUI uses many of the utilities in this directory in its own Jest tests and, in case they are useful for consuming apps, exports them from `@elastic/eui/lib/test` (commonjs) and `@elastic/eui/es/test` (esm)
|
|
4
|
-
|
|
5
|
-
### findTestSubject
|
|
6
|
-
|
|
7
|
-
Provides a quick mechanism for searching an Enzyme-mounted component tree for an element with a specific `data-test-subj` attribute.
|
|
8
|
-
|
|
9
|
-
```js
|
|
10
|
-
// if mountedComponent contains e.g. <button data-test-subj="custom-button"/>, this would return that button
|
|
11
|
-
const component = findTestSubject(mountedComponent, 'custom-button');
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
### startThrowingReactWarnings
|
|
15
|
-
|
|
16
|
-
Patches `console.warn` and `console.error` to throw any warnings or errors, causing Jest to fail the test. This catches warnings emitted by React.
|
|
17
|
-
|
|
18
|
-
### stopThrowingReactWarnings
|
|
19
|
-
|
|
20
|
-
Must be called after `startThrowingReactWarnings`, this unpatches the console and restores normal functionality.
|
|
21
|
-
|
|
22
|
-
### sleep
|
|
23
|
-
|
|
24
|
-
Returns an `await`able promise that resolves after the specified duration.
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
doSomeAction();
|
|
28
|
-
await sleep(500); // wait 500ms
|
|
29
|
-
expect(resultOfSomeAction);
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### takeMountedSnapshot
|
|
33
|
-
|
|
34
|
-
Use this function to generate a Jest snapshot of components that have been fully rendered using Enzyme's `mount` method. Typically, a mounted component will result in a snapshot containing both React components and HTML elements. This function removes the React components, leaving only HTML elements in the snapshot.
|
|
35
|
-
|
|
36
|
-
This function takes an optional configuration as a second argument, which supports one option: `hasArrayOutput`. Enable this option if the mounted component has multiple direct children, otherwise only the first is included in the snapshot.
|
|
37
|
-
|
|
38
|
-
```js
|
|
39
|
-
expect(
|
|
40
|
-
takeMountedSnapshot(mountedComponent, {
|
|
41
|
-
hasArrayOutput: true,
|
|
42
|
-
})
|
|
43
|
-
).toMatchSnapshot();
|
|
44
|
-
```
|