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

[CSS-in-JS] @emotion/react in src/ #5121

Merged
merged 59 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
681d56e
emotion as peerDep; babel and typescript
thompsongl Sep 1, 2021
155c1d5
jest config
thompsongl Sep 1, 2021
601d2d0
isDefaultTheme util
thompsongl Sep 1, 2021
43e89c2
CL TODO
thompsongl Sep 1, 2021
98714ee
Merge branch 'master' into css-in-js/breaking
thompsongl Sep 1, 2021
6ebbb0d
update snapshots
thompsongl Sep 1, 2021
e2e2dfe
Merge branch 'master' into css-in-js/breaking
thompsongl Sep 9, 2021
b28f9a5
Merge branch 'master' into css-in-js/breaking
thompsongl Sep 16, 2021
6f782d7
Merge branch 'master' into css-in-js/breaking
cchaos Sep 23, 2021
caba1df
Merge remote-tracking branch upstream/master into css-in-js/breaking
Sep 28, 2021
e673838
Merge branch 'master' into css-in-js/breaking
thompsongl Sep 30, 2021
40d355f
Merge branch 'css-in-js/breaking' of https://github.com/elastic/eui i…
thompsongl Sep 30, 2021
64aacf7
Merge remote-tracking branch 'origin/master' into css-in-js/breaking
Sep 30, 2021
f00cacc
[CSS-in-JS] [Breaking] Deprecating EUI theme to Legacy (#5222)
cchaos Oct 1, 2021
3b60df7
[CSS-in-JS] Global style reset with `emotion` (#5122)
thompsongl Oct 6, 2021
8c1ec07
Merge branch 'master' into css-in-js/breaking
thompsongl Oct 6, 2021
ae19633
Merge branch 'css-in-js/breaking' of https://github.com/elastic/eui i…
thompsongl Oct 6, 2021
f2bc587
Merge branch 'master' into css-in-js/breaking
thompsongl Oct 7, 2021
f8d8675
[CSS-in-JS] Add provider to generated codesandbox examples (#5253)
thompsongl Oct 14, 2021
acc89ae
Merge branch 'master' into css-in-js/breaking
thompsongl Oct 14, 2021
2968430
Merge remote-tracking branch origin/master into css-in-js/breaking
Oct 20, 2021
63ef281
Merge remote-tracking branch 'origin/master' into css-in-js/breaking
Oct 20, 2021
7b6ac4c
fix snapshot tests
thompsongl Oct 21, 2021
c09c18c
[CSS-in-JS] Provider for fullscreen examples; Context refactor (#5309)
thompsongl Oct 26, 2021
59e3245
[CSS-in-JS] [Breaking] Better Getting Started page (#5299)
cchaos Oct 28, 2021
48477fa
Merge branch 'master' into css-in-js/breaking
thompsongl Oct 28, 2021
438e035
fix heading level
thompsongl Oct 28, 2021
2e47d07
Merge branch 'master' into css-in-js/breaking
thompsongl Oct 28, 2021
8e6d3ac
Merge branch 'master' into css-in-js/breaking
thompsongl Nov 2, 2021
15fd846
update changelog page regex to fully remove the master section
thompsongl Nov 2, 2021
0797bff
manual merge
thompsongl Nov 2, 2021
c1662ca
update release script changelog regex
thompsongl Nov 2, 2021
2422722
Merge branch 'master' into css-in-js/breaking
thompsongl Nov 2, 2021
804a415
Cleanup some docs
Nov 2, 2021
b1e75a8
Merge remote-tracking branch origin/master into css-in-js/breaking
Nov 2, 2021
b5aa3c1
Hide LanguageSelector tour on Getting Started page
Nov 3, 2021
f1a4a56
Some GS page cleanup
Nov 3, 2021
e37a062
Merge branch 'master' into css-in-js/breaking
thompsongl Nov 3, 2021
38c7125
PR feedback
Nov 6, 2021
5a1e555
Merge remote-tracking branch 'origin/main' into css-in-js/breaking
Nov 6, 2021
ecd2e0f
cl
Nov 6, 2021
32d302b
Merge branch 'main' into css-in-js/breaking
thompsongl Nov 15, 2021
fc7577e
Merge branch 'main' into css-in-js/breaking
thompsongl Nov 18, 2021
6f9bd20
Apply suggestions from code review
thompsongl Nov 18, 2021
d71c462
lint fix
thompsongl Nov 18, 2021
6c13740
make amsterdam default
thompsongl Nov 18, 2021
a9eb789
provider updates
thompsongl Nov 18, 2021
5da968c
fix cypress styles
thompsongl Nov 18, 2021
0963b81
PR feedback:
Nov 22, 2021
f35c0e4
Merge branch 'main' into css-in-js/breaking
cchaos Nov 22, 2021
5439053
move keydown inside useeffect
thompsongl Nov 22, 2021
30f66cc
Merge branch 'main' into css-in-js/breaking
cchaos Nov 23, 2021
a89a023
Merge remote-tracking branch 'origin/main' into css-in-js/breaking
Nov 23, 2021
134d6d3
Merge remote-tracking branch 'origin/main' into css-in-js/breaking
Nov 23, 2021
895c86a
Reusing correct Sass customization snippet under Customizing
Nov 23, 2021
6ce27dc
fix cypress path
thompsongl Nov 24, 2021
4a8477f
Merge branch 'main' into css-in-js/breaking
thompsongl Nov 24, 2021
dba14b1
Merge branch 'main' into css-in-js/breaking
thompsongl Nov 30, 2021
a319356
update export
thompsongl Nov 30, 2021
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
6 changes: 6 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ module.exports = {
}],
["@babel/typescript", { isTSX: true, allExtensions: true }],
"@babel/react",
[
"@emotion/babel-preset-css-prop",
{
"labelFormat": "[filename]-[local]"
},
],
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
Expand Down
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
## [`main`](https://github.com/elastic/eui/tree/main)

No public interface changes since `41.4.0`.
### Feature: CSS-in-JS ([#5121](https://github.com/elastic/eui/pull/5121))

- Added reset and global styles via CSS-in-JS with `@emotion/react/Global`
- Added `EuiProvider`, a React context provider for theming and global styles
- Added `isDefaultTheme` and `isLegacyTheme` utilities

**Breaking changes**

- Added `@emotion/react` to `peerDependencies`
- Amsterdam is now the default theme, deprecated and renamed old theme as "legacy"
- Re-organized Sass files including where the `globals` are imported from

## [`41.4.0`](https://github.com/elastic/eui/tree/v41.4.0)

Expand Down Expand Up @@ -278,7 +288,7 @@ No public interface changes since `41.4.0`.

## [`37.5.0`](https://github.com/elastic/eui/tree/v37.5.0)

### Feature: Emotion ([#4511](https://github.com/elastic/eui/pull/4511))
### Feature: CSS-in-JS ([#4511](https://github.com/elastic/eui/pull/4511))

- Added `EuiThemeProvider`, a React context provider for theme values and color mode selection
- Added `useEuiTheme` React hook, and `withEuiTheme` React HOC for consuming the EuiTheme
Expand Down
22 changes: 4 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,7 @@

Check out our [full documentation site][docs] which contains many examples of components in the EUI framework aesthetic, and how to use them in your products. We also have a [FAQ][faq] that covers common usage questions. For other general questions regarding EUI, check out the [Discussions tab](https://github.com/elastic/eui/discussions).

## Installation

To install the Elastic UI Framework into an existing project, use the `yarn` CLI (`npm` is not supported).

```
yarn add @elastic/eui
```

Note that EUI has [several `peerDependencies` requirements](package.json) that will also need to be installed if starting with a blank project. You can read more about other ways to [consume EUI][consuming].

```
yarn add @elastic/eui @elastic/datemath moment prop-types
```

The rest of this doc will detail how to run and contribute to the **EUI documentation** site locally.

## Running Locally

Expand All @@ -31,22 +18,22 @@ You will probably want to install a node version manager. [nvm](https://github.c

To install and use the correct node version with `nvm`:

```
```bash
nvm install
```

### Documentation

You can run the documentation locally at [http://localhost:8030/](http://localhost:8030/) by running the following.

```
```bash
yarn
yarn start
```

If another process is already listening on port 8030, the next free port will be used. Alternatively, you can specify a port:

```
```bash
yarn start --port 9000
```

Expand Down Expand Up @@ -75,7 +62,6 @@ directly in the code. And unit test coverage for the UI components allows us to
* [Creating components manually](wiki/creating-components-manually.md)
* [Creating components with Yeoman](wiki/creating-components-yeoman.md)
* [Creating icons](wiki/creating-icons.md)
* [Theming](wiki/theming.md)
* [Testing](wiki/testing.md)
* [Accessibility Testing](wiki/automated-accessibility-testing.md)
* [Documentation](wiki/documentation-guidelines.md)
Expand Down
2 changes: 1 addition & 1 deletion cypress/plugins/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
const path = require('path');
const webpack = require('webpack');

const THEME_IMPORT = `'../../dist/eui_theme_amsterdam_${process.env.THEME}.css'`;
const THEME_IMPORT = `'../../dist/eui_theme_${process.env.THEME}.css'`;

module.exports = {
mode: 'development',
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@
"@elastic/datemath": "^5.0.3",
"@elastic/eslint-config-kibana": "^0.15.0",
"@emotion/babel-preset-css-prop": "^11.0.0",
"@emotion/cache": "^11.4.0",
"@emotion/eslint-plugin": "^11.0.0",
"@emotion/jest": "^11.1.0",
"@emotion/react": "^11.1.1",
"@svgr/core": "5.5.0",
"@svgr/plugin-svgo": "^4.0.3",
Expand Down Expand Up @@ -234,6 +236,7 @@
},
"peerDependencies": {
"@elastic/datemath": "^5.0.2",
"@emotion/react": "11.x",
"@types/react": "^16.9.34",
"@types/react-dom": "^16.9.6",
"moment": "^2.13.0",
Expand Down
11 changes: 9 additions & 2 deletions scripts/compile-scss.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function compileScssFiles({

const inputFilenames = (await glob(sourcePattern, undefined)).filter(filename => {
if (targetTheme == null) return true;
return filename === `src/theme_${targetTheme}.scss`;
return filename === `src/themes/amsterdam/theme_${targetTheme}.scss`;
});

await Promise.all(
Expand Down Expand Up @@ -147,7 +147,14 @@ if (require.main === module) {
}

compileScssFiles({
sourcePattern: path.join('src', 'theme_*.scss'),
sourcePattern: path.join('src/themes/legacy', 'legacy_*.scss'),
destinationDirectory: 'dist',
docsVariablesDirectory: 'src-docs/src/views/theme/_json',
packageName: euiPackageName
});

compileScssFiles({
sourcePattern: path.join('src/themes/amsterdam', 'theme_*.scss'),
destinationDirectory: 'dist',
docsVariablesDirectory: 'src-docs/src/views/theme/_json',
packageName: euiPackageName
Expand Down
45 changes: 23 additions & 22 deletions scripts/cypress.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

const { execSync } = require('child_process');
const chalk = require('chalk');
const yargs = require('yargs/yargs')
const { hideBin } = require('yargs/helpers')
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');

const argv = yargs(hideBin(process.argv))
.parserConfiguration({
"camel-case-expansion": false, // don't convert dash-separated options into camel case (e.g. dashSeparated)
"unknown-options-as-args": true, // collect any extra options to pass on to cypress
'camel-case-expansion': false, // don't convert dash-separated options into camel case (e.g. dashSeparated)
'unknown-options-as-args': true, // collect any extra options to pass on to cypress
})
.options({
'skip-css': { type: 'boolean' },
'dev': { type: 'boolean' },
'theme': { type: 'string', default: 'light', choices: ['light', 'dark'] },
})
.argv
dev: { type: 'boolean' },
theme: { type: 'string', default: 'light', choices: ['light', 'dark'] },
}).argv;

const isDev = argv.hasOwnProperty('dev');
const skipScss = argv.hasOwnProperty('skip-css');
Expand All @@ -25,12 +32,9 @@ const log = chalk.grey;
// compile scss -> css so tests can render correctly
if (!skipScss) {
console.log(info('Compiling SCSS'));
execSync(
`TARGET_THEME=amsterdam_${theme} yarn compile-scss`,
{
stdio: 'inherit'
}
);
execSync(`TARGET_THEME=${theme} yarn compile-scss`, {
stdio: 'inherit',
});
} else {
console.log(info('Not compiling SCSS, disabled by --skip-css'));
}
Expand All @@ -41,15 +45,12 @@ const cypressCommandParts = [
'BABEL_MODULES=false', // let webpack receive ES Module code
'NODE_ENV=cypress_test', // enable code coverage checks
`cypress ${isDev ? 'open-ct' : 'run-ct'}`,
...argv._ // pass any extra options given to this script
...argv._, // pass any extra options given to this script
];
const cypressCommand = cypressCommandParts.join(' ');

console.log(info(`${isDev ? 'Opening' : 'Running'} cypress`));
console.log(log(cypressCommand))
execSync(
cypressCommand,
{
stdio: 'inherit'
}
);
console.log(log(cypressCommand));
execSync(cypressCommand, {
stdio: 'inherit',
});
3 changes: 2 additions & 1 deletion scripts/jest/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"^.+\\.(js|tsx?)$": "babel-jest"
},
"snapshotSerializers": [
"<rootDir>/node_modules/enzyme-to-json/serializer"
"<rootDir>/node_modules/enzyme-to-json/serializer",
"@emotion/jest/enzyme-serializer"
]
}
4 changes: 2 additions & 2 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ async function getVersionTypeFromChangelog() {
//
// "##.+?[\r\n]+" consume the first heading & linebreak(s), which describes the main branch
// "(.+?)" capture (non-greedy) all changes until the rest of the regex matches
// "[\r\n]+##" any linebreak(s) leading up to the next ## heading
// "[\r\n]+##(?= \[`\d)" any linebreak(s) leading up to the next ## heading with a numbered release, e.g. [`1.0.0`]
//
// regex flags "su" enable dotAll (s) and unicode-character matching (u)
//
// effectively capturing pending changes in the capture group
// which is stored as the second item in the returned array from `changelog.match()`
const [, unreleasedchanges] = changelog.match(/##.+?[\r\n]+(.+?)[\r\n]+##/su);
const [, unreleasedchanges] = changelog.match(/##.+?[\r\n]+(.+?)[\r\n]+##(?= \[`\d)/su);

// these changes contain bug fixes if the string "**bug fixes**" exists
const hasBugFixes = unreleasedchanges.toLowerCase().indexOf('**bug fixes**') !== -1;
Expand Down
6 changes: 0 additions & 6 deletions src-docs/.babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ const baseConfig = require('../.babelrc.js');
const index = baseConfig.plugins.indexOf(
'./scripts/babel/proptypes-from-ts-props'
);
baseConfig.presets.push([
'@emotion/babel-preset-css-prop',
{
labelFormat: '[local]',
},
]);
baseConfig.plugins.splice(
index + 1,
0,
Expand Down
Loading