Skip to content

Commit

Permalink
[Docs] Update references to Sass/Emotion migration (#8029)
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen authored Sep 20, 2024
1 parent 84aa840 commit e6ccac8
Show file tree
Hide file tree
Showing 16 changed files with 298 additions and 641 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ This activity counter can be soft reset by commenting on the issue directly, but

The EUI team, like everyone else, has a finite amount of time and resources, and it is not humanly possible for us to implement every task or feature requested of us. However, that's where the beauty of open source comes in - if your request is important to you, we strongly encourage you to [contribute code directly to EUI](wiki/contributing-to-eui/) that addresses your issue or request!

<!-- TODO: Delete this question once the Emotion migration is complete -->
### What is the status of EUI's theming?
### I have more questions!

The EUI library was previously built upon Sass and is in the process of migrating to CSS-in-JS (specifically [Emotion](https://emotion.sh)). While this work is in progress, we ask for your patience with our in-between state in areas such as documentation and setup.

If you're a Kibana developer with questions around CSS-in-JS usage in Kibana, please check out our [FAQ discussion](https://github.com/elastic/eui/discussions/6828)!
The EUI team has ongoing FAQs for more transient or component-specific questions. [Please see the FAQ section in our GitHub discussions here](https://github.com/elastic/eui/discussions/categories/faq).

## Wiki

Expand Down
70 changes: 1 addition & 69 deletions packages/eui/README.md
Original file line number Diff line number Diff line change
@@ -1,69 +1 @@
<img src="https://repository-images.githubusercontent.com/107422373/b6180480-a1d7-11eb-8a3c-902086232aa7" alt="" />

# Elastic UI Framework

**The Elastic UI Framework is a collection of React UI components for quickly building user interfaces at Elastic.**

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. Our FAQ below covers common usage questions — for other general questions regarding EUI, check out the [Discussions tab](https://github.com/elastic/eui/discussions).

> [!NOTE]
> We're in the process of migrating this repository to a monorepo structure. You can find `@elastic/eui` files in the [packages/eui](https://github.com/elastic/eui/tree/main/packages/eui) directory.
## Frequently Asked Questions

### What is the Elastic UI Framework?

The Elastic UI Framework (EUI) is a design library in use at Elastic to build React applications that need to share our branding and aesthetics. It distributes typed UI React components and static assets for use in building web layouts. Alongside the React components, we ship theme & style utilities that can be used independently on their own.

The primary goal of this library is to provide reusable UI components that can be used throughout Elastic's web products. As React components, they remove CSS from the process of building UIs. As a single source of truth, the framework allows our designers to make changes to our aesthetic directly in the code. And unit test coverage for the UI components allows us to deliver a stable "API for user interfaces".

### Can I use EUI?

Please see Elastic's licensing FAQ: [I’m using EUI or Elastic Charts in my application outside of Kibana, how does this affect me?][licensing-faq]

### Why is EUI open source?

Many of Elastic's products are open source and rely upon this library to function. The Elastic UI Framework began as a folder of code in Kibana and we decided it could be used beyond that codebase. It exists as an independent library so that patterns can be shared across teams and design standards can be scaled across our organization. Since most of our products are open source, we treat this one similarly as far as public publishing and conversation even if its usage tends to focus more inward towards Elastic itself.

### What is the versioning, release, and upgrade strategy?

We use [semver](https://semver.org/) for versioning and use that to denote breaking changes in EUI upgrades. Traditionally we consider API changes in our prop names or existing component functionality to be a reason for a breaking change, but do not track the renaming of CSS selectors, mixins or other style changes under this same rigor.

Traditionally releases are made weekly against whatever is in the `main` branch and you can upgrade from NPM as you see fit.

### Can I contribute to EUI?

Yes! We welcome community-contributed PRs, especially around feature requests that the EUI team may not have bandwidth to carry out alone. You can find documentation around creating and submitting new components in [our wiki](wiki/contributing-to-eui/).

### What about reporting bugs and feature requests?

Bug reports and feature requests are most welcome, but our roadmap and prioritization are driven primarily by [internal Elastic usage](wiki/contributing-to-eui#how-we-assign-work-and-define-our-roadmap).

Please note that in order to keep our backlog manageable and focused on tasks we intend to complete, feature requests & tech debt issues that are inactive for a year will be auto-closed (bugs will remain open if determined to be reproducible and valid).

This activity counter can be soft reset by commenting on the issue directly, but please do so mindfully. We would ask that you proactively let the EUI team know why this request matters to you or how it impacts you or your users, in order to help us prioritize accordingly.

The EUI team, like everyone else, has a finite amount of time and resources, and it is not humanly possible for us to implement every task or feature requested of us. However, that's where the beauty of open source comes in - if your request is important to you, we strongly encourage you to [contribute code directly to EUI](wiki/contributing-to-eui/) that addresses your issue or request!

<!-- TODO: Delete this question once the Emotion migration is complete -->
### What is the status of EUI's theming?

The EUI library was previously built upon Sass and is in the process of migrating to CSS-in-JS (specifically [Emotion](https://emotion.sh)). While this work is in progress, we ask for your patience with our in-between state in areas such as documentation and setup.

If you're a Kibana developer with questions around CSS-in-JS usage in Kibana, please check out our [FAQ discussion](https://github.com/elastic/eui/discussions/6828)!

## Wiki

Our wiki docs contain instructions and guidelines on multiple areas of EUI usage and development that are too detailed for an initial README. For more information, see:

- [Consuming EUI](wiki/consuming-eui)
- [Contributing to EUI](wiki/contributing-to-eui/)
- [Running EUI locally](wiki/contributing-to-eui/running-eui-locally.md)

## License

[Dual-licensed under Elastic v2 and Server Side Public License, v1][license]. See Elastic's [licensing FAQ][licensing-faq] for details.

[license]: LICENSE.txt
[licensing-faq]: https://www.elastic.co/pricing/faq/licensing#im-using-eui-or-elastic-charts-in-my-application-outside-of-kibana-how-does-this-affect-me
[docs]: https://elastic.github.io/eui/
## See [the top-level repo README](../../#readme) and [wiki](../../wiki) for more information on consuming and contributing to EUI.
37 changes: 5 additions & 32 deletions packages/eui/src-docs/src/components/codesandbox/link.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from 'react';
import { getParameters } from 'codesandbox/lib/api/define';
import { useEuiTheme } from '../../../../src/services';
import {
cleanEuiImports,
hasDisplayToggles,
listExtraDeps,
} from '../../services';

import { ThemeContext } from '../with_theme';

const pkg = require('../../../../package.json');

const getVersion = (packageName) => {
Expand All @@ -33,39 +32,14 @@ const getVersion = (packageName) => {
const displayTogglesRawCode =
require('!!raw-loader!../../views/form_controls/display_toggles').default;

export const CodeSandboxLink = ({ ...rest }) => {
return (
<ThemeContext.Consumer>
{(context) => <CodeSandboxLinkComponent context={context} {...rest} />}
</ThemeContext.Consumer>
);
};

/* 1 */
export const CodeSandboxLinkComponent = ({
export const CodeSandboxLink = ({
children,
className,
content,
type = 'js',
context,
}) => {
const isDarkMode = context.theme.includes('dark');
const colorMode = isDarkMode ? 'dark' : 'light';

const cssFile = `@elastic/eui/dist/eui_theme_${colorMode}.css`;

const providerPropsObject = {};
// Only add configuration if it isn't the default
if (isDarkMode) {
providerPropsObject.colorMode = 'dark';
}
// Can't spread an object inside of a string literal
const providerProps = Object.keys(providerPropsObject)
.map((prop) => {
const value = providerPropsObject[prop];
return value !== null ? `${prop}="${value}"` : `${prop}={${value}}`;
})
.join(' ');
const { colorMode } = useEuiTheme();

let demoContent;

Expand Down Expand Up @@ -165,8 +139,7 @@ import '@elastic/charts/dist/theme_only_${colorMode}.css';`
content: demoContent,
},
'index.js': {
content: `import '${cssFile}';
import React from 'react';
content: `import React from 'react';
import { createRoot } from 'react-dom/client';
import createCache from '@emotion/cache';
import { EuiProvider, euiStylisPrefixer } from '@elastic/eui';
Expand All @@ -182,7 +155,7 @@ cache.compat = true;
const root = createRoot(document.getElementById('root'));
root.render(
<EuiProvider cache={cache} ${providerProps}>
<EuiProvider cache={cache}>
<Demo />
</EuiProvider>
);`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,15 @@ export const GuideTabbedPage: FunctionComponent<GuideTabbedPageProps> = ({
const currentLanguage = themeContext.themeLanguage;
const showSass = currentLanguage.includes('sass');

const headerBadge =
isBeta || (showThemeLanguageToggle && !showSass) ? (
<EuiBetaBadge
label="Beta"
color="accent"
tooltipContent="This component is still under development and may contain breaking changes in the nearby future."
/>
) : isNew ? (
<EuiBetaBadge label="New" color="accent" />
) : undefined;
const headerBadge = isBeta ? (
<EuiBetaBadge
label="Beta"
color="accent"
tooltipContent="This component is still under development and may contain breaking changes in the nearby future."
/>
) : isNew ? (
<EuiBetaBadge label="New" color="accent" />
) : undefined;

let tabs:
| Array<{
Expand Down Expand Up @@ -190,7 +189,7 @@ export const GuideTabbedPage: FunctionComponent<GuideTabbedPageProps> = ({
};

const renderNotice = () => {
if (!showSass && notice) {
if (showSass && notice) {
return (
<GuideSection>
<div role="region" aria-label="Notice">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,71 +1,52 @@
import React, { FunctionComponent } from 'react';
import React from 'react';
import { Link } from 'react-router-dom';
import {
EuiCodeBlock,
useEuiTheme,
EuiCode,
EuiSpacer,
EuiText,
EuiCallOut,
EuiLink,
} from '../../../../../src';

type AppSetup = {};

export const AppSetup: FunctionComponent<AppSetup> = ({}) => {
const { colorMode } = useEuiTheme();
export const AppSetup = () => {
return (
<>
<EuiText grow={false}>
<p>
EUI uses CSS-in-JS (specifically{' '}
<EuiLink href="https://emotion.sh" target="_blank">
Emotion
</EuiLink>
) for its styles and theming. As such, we require an{' '}
<EuiCode>{'<EuiProvider>'}</EuiCode> wrapper around your application
in order for various theme-related UI & UX (such as dark/light mode
switching) to work as expected.
</p>
</EuiText>

const appSetup = (
<EuiCodeBlock language="jsx" isCopyable fontSize="m">
{`import React from 'react';
import '@elastic/eui/dist/eui_theme_${colorMode.toLowerCase()}.css';
<EuiSpacer />
<EuiCodeBlock language="jsx" isCopyable fontSize="m">
{`import React from 'react';
import { EuiProvider, EuiText } from '@elastic/eui';
const MyApp = () => (
<EuiProvider colorMode="${colorMode.toLowerCase()}">
<EuiProvider>
<EuiText><p>Hello World!</p></EuiText>
</EuiProvider>
);
export default MyApp;`}
</EuiCodeBlock>
);

return (
<>
<EuiCallOut color="warning">
<p>
While EUI is in the process of converting from a Sass based theme to
CSS-in-JS via Emotion. We require that both the{' '}
<Link to="/utilities/provider">
<strong>EuiProvider</strong>
</Link>{' '}
<strong>and</strong> the compiled CSS (or raw Sass) files be imported
during this transition.
</p>
</EuiCallOut>

<EuiSpacer />

<EuiText grow={false}>
<p>
EUI provides a general context provider to handle global aspects like
light and dark theme. You can import these default themes through
their respective compiled CSS files. Use the{' '}
<EuiCode>.min.css</EuiCode> file extension for the minified version.
</p>
</EuiText>

<EuiSpacer />
{appSetup}
</EuiCodeBlock>
<EuiSpacer />

<EuiText grow={false}>
<p>
For the dark theme, you can swap the words <EuiCode>light</EuiCode>{' '}
for <EuiCode>dark</EuiCode>. <br />
For more configuration options of the provider, see the{' '}
<Link to="/utilities/provider">EuiProvider documentation</Link>.
<Link to="/utilities/provider">
<strong>EuiProvider</strong> documentation
</Link>
.
</p>
</EuiText>
</>
Expand Down
Loading

0 comments on commit e6ccac8

Please sign in to comment.