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

Consolidate EuiText and EuiMarkdownFormat styling #4663

Merged
merged 41 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
514ab4d
Wrapping the EuiMarkdownFormat content with EuiText
miukimiu Mar 24, 2021
c0d4046
Comments
miukimiu Mar 24, 2021
e84df00
Unnecessary comment
miukimiu Mar 24, 2021
f002a89
Initial markdown format styles example
miukimiu Mar 25, 2021
6d5133a
Merge remote-tracking branch 'upstream/master' into EuiMarkdownFormat…
miukimiu May 28, 2021
c831eea
Getting started page matching other guideline pages
miukimiu May 28, 2021
baf8dbe
wip
miukimiu May 28, 2021
65c3b6f
Improving euiScaleText mixin to also return `em` sizes
miukimiu Jun 3, 2021
bb1e1de
Merge remote-tracking branch 'upstream/master' into EuiMarkdownFormat…
miukimiu Jun 8, 2021
4d45e35
Better amsterdam scaling
miukimiu Jun 9, 2021
76eeb28
Merge remote-tracking branch 'upstream/master' into EuiMarkdownFormat…
miukimiu Jun 18, 2021
537ca0a
Move mixins to appropriate files. Renaming mixins.
miukimiu Jun 22, 2021
6f3249c
Just one EM class
miukimiu Jun 22, 2021
23f1f8a
Moving functions to typography variables file
miukimiu Jun 22, 2021
8c42aae
marginToRemOrEm
miukimiu Jun 22, 2021
a4739a5
Adding relative class name and inherit text color
miukimiu Jun 23, 2021
45f17a0
Fixing jest test
miukimiu Jun 23, 2021
b547732
Ghost colors
miukimiu Jun 24, 2021
df6fd71
Merge remote-tracking branch 'upstream/master' into EuiMarkdownFormat…
miukimiu Jul 1, 2021
8e52331
Merge remote-tracking branch 'upstream/master' into EuiMarkdownFormat…
miukimiu Jul 7, 2021
6ca83ef
Adding components theme
miukimiu Jul 9, 2021
edb31cb
Changing GuideMarkdownFormat to medium text size
miukimiu Jul 13, 2021
df7fea0
Using `currentColor` to adjust bg and border colors.
miukimiu Jul 14, 2021
13c4710
Adding better comments
miukimiu Jul 14, 2021
d8c3b0c
Better comments
miukimiu Jul 15, 2021
a8544eb
Adding docs examples for md format styling.
miukimiu Jul 15, 2021
a7265c7
Extending EuiFormatProps into the editor.
miukimiu Jul 15, 2021
7a1752f
Merge remote-tracking branch 'upstream/master' into EuiMarkdownFormat…
miukimiu Jul 15, 2021
534589d
Adding CL
miukimiu Jul 15, 2021
fce4c8b
Better comment for color prop
miukimiu Jul 15, 2021
9491328
Replacing example with color success instead of secondary.
miukimiu Jul 15, 2021
344d9f8
Addressing PR review
miukimiu Jul 20, 2021
8efb4a5
Merge remote-tracking branch 'upstream/master' into EuiMarkdownFormat…
miukimiu Jul 20, 2021
844bfdc
Better text styles for text color
miukimiu Jul 20, 2021
aa6ae66
Adding `CSSProperties['color']` type
miukimiu Jul 20, 2021
9f95d59
retain fenced block styles
thompsongl Jul 21, 2021
74986ac
Adding home page getting started link
miukimiu Jul 22, 2021
678cb90
Updating CL
miukimiu Jul 22, 2021
fbf7ced
Update CL
miukimiu Jul 22, 2021
f1aa79d
Merge remote-tracking branch 'upstream/master' into EuiMarkdownFormat…
miukimiu Jul 22, 2021
eeea91f
CL again :D
miukimiu Jul 22, 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Fixed color of `html` scrollbar in dark mode ([#4969](https://github.com/elastic/eui/pull/4969))
- Updated `EuiMarkdownFormat` to use `EuiHorizontalRule` and better render tables, code blocks and blockquotes ([#4663](https://github.com/elastic/eui/pull/4947))
- Updated the `EuiMarkdownFormat` to use `EuiText` as a wrapper to handle all the CSS styling ([#4663](https://github.com/elastic/eui/pull/4947))
- Updated `EuiText`s `color` prop to accept `inherit` and custom colors. Updated the `size` prop to accept `relative` ([#4663](https://github.com/elastic/eui/pull/4947))
- Updated `EuiText`s `blockquote` font-size/line-height to match the base font-size/line-height which is the same as paragraphs ([#4663](https://github.com/elastic/eui/pull/4947))
- Added `markdownFormatProps` prop to `EuiMarkdownEditor` to extend the props passed to the rendered `EuiMarkdownFormat` ([#4663](https://github.com/elastic/eui/pull/4947))

## [`36.0.0`](https://github.com/elastic/eui/tree/v36.0.0)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,52 +1,30 @@
import React, { FunctionComponent } from 'react';
import {
EuiMarkdownFormat,
EuiMarkdownFormatProps,
getDefaultEuiMarkdownProcessingPlugins,
} from '../../../../src/components/markdown_editor';
import { EuiText } from '../../../../src/components/text';
import { EuiTitle } from '../../../../src/components/title';
import { slugify } from '../../../../src/services';

export type GuideMarkdownFormatProps = {
children: any;
};

export const GuideMarkdownFormat: FunctionComponent<GuideMarkdownFormatProps> = ({
export const GuideMarkdownFormat: FunctionComponent<EuiMarkdownFormatProps> = ({
children,
...rest
}) => {
const processingPlugins = getDefaultEuiMarkdownProcessingPlugins();
const rehype2reactConfig = processingPlugins[1][1];

rehype2reactConfig.components.h2 = ({ children }) => {
const id = slugify(children[0]);

return (
<EuiTitle>
<h2 id={id}>{children}</h2>
</EuiTitle>
);
return <h2 id={id}>{children}</h2>;
};

rehype2reactConfig.components.p = ({ children }) => (
<EuiText grow={false}>
<p>{children}</p>
</EuiText>
);

rehype2reactConfig.components.ul = ({ children }) => (
<EuiText grow={false}>
<ul>{children}</ul>
</EuiText>
);

rehype2reactConfig.components.ol = ({ children }) => (
<EuiText grow={false}>
<ol>{children}</ol>
</EuiText>
);

return (
<EuiMarkdownFormat processingPluginList={processingPlugins}>
<EuiMarkdownFormat
processingPluginList={processingPlugins}
className="guideMarkdownFormat"
textSize="m"
{...rest}>
{children}
</EuiMarkdownFormat>
);
Expand Down
43 changes: 21 additions & 22 deletions src-docs/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { slugify } from '../../src/services';

import { createHashHistory } from 'history';

import { GuidePage, GuideSection } from './components';
import { GuidePage, GuideSection, GuideMarkdownFormat } from './components';

import { EuiErrorBoundary } from '../../src/components';

import { playgroundCreator } from './services/playground';

// Guidelines
// const GettingStarted = require('!!raw-loader!./views/guidelines/getting_started.md');
const GettingStarted = require('!!raw-loader!./views/guidelines/getting_started.md');

import AccessibilityGuidelines from './views/guidelines/accessibility';

Expand Down Expand Up @@ -293,34 +293,33 @@ const createExample = (example, customTitle) => {
};
};

// const createMarkdownExample = (example, title) => {
// const headings = example.default.match(/^(##) (.*)/gm);
const createMarkdownExample = (example, title) => {
const headings = example.default.match(/^(##) (.*)/gm);

// const sections = headings.map((heading) => {
// const title = heading.replace('## ', '');
const sections = headings.map((heading) => {
const title = heading.replace('## ', '');

// return { id: slugify(title), title: title };
// });
return { id: slugify(title), title: title };
});

// return {
// name: title,
// component: () => (
// <GuidePage title={title}>
// <GuideMarkdownFormat title={title}>
// {example.default}
// </GuideMarkdownFormat>
// </GuidePage>
// ),
// sections: sections,
// };
// };
return {
name: title,
component: () => (
<GuidePage title={title}>
<GuideMarkdownFormat title={title} grow={false}>
{example.default}
</GuideMarkdownFormat>
</GuidePage>
),
sections: sections,
};
};

const navigation = [
{
name: 'Guidelines',
items: [
// TODO uncomment when EuiMarkdownFormat has a better text formatting
// createMarkdownExample(GettingStarted, 'Getting started'),
createMarkdownExample(GettingStarted, 'Getting started'),
createExample(AccessibilityGuidelines, 'Accessibility'),
{
name: 'Colors',
Expand Down
8 changes: 4 additions & 4 deletions src-docs/src/views/guidelines/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

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

```js
```
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].
Note that EUI has [several `peerDependencies` requirements](https://github.com/elastic/eui/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](https://github.com/elastic/eui/blob/master/wiki/consuming.md).

```js
yarn add @elastic/eui @elastic/datemath moment prop-types
Expand All @@ -17,7 +17,7 @@ yarn add @elastic/eui @elastic/datemath moment prop-types

### Node

We depend upon the version of node defined in [.nvmrc](.nvmrc).
We depend upon the version of node defined in [.nvmrc](https://github.com/elastic/eui/.nvmrc).

You will probably want to install a node version manager. [nvm](https://github.com/creationix/nvm) is recommended.

Expand All @@ -29,7 +29,7 @@ nvm install

### Documentation

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

```js
yarn
Expand Down
4 changes: 2 additions & 2 deletions src-docs/src/views/home/home_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ export const HomeView = () => (
</p>
<EuiFlexGroup gutterSize="xl" wrap responsive={false}>
<EuiFlexItem grow={false}>
<EuiLink href="https://github.com/elastic/eui/blob/master/wiki/consuming.md">
<Link to="/guidelines/getting-started">
<strong>Getting started</strong>
</EuiLink>
</Link>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<Link to="/package/changelog">
Expand Down
42 changes: 28 additions & 14 deletions src-docs/src/views/markdown_editor/mardown_format_example.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import React, { Fragment } from 'react';

import { renderToHtml } from '../../services';

import { GuideSectionTypes } from '../../components';

import {
EuiLink,
EuiMarkdownFormat,
EuiText,
EuiCode,
} from '../../../../src/components';

import { Link } from 'react-router-dom';

import MarkdownFormat from './markdown_format';
const markdownFormatSource = require('!!raw-loader!./markdown_format');
const markdownFormatHtml = renderToHtml(MarkdownFormat);

import MarkdownFormatStyles from './markdown_format_styles';
const markdownFormatStylesSource = require('!!raw-loader!./markdown_format_styles');

import MarkdownFormatSink from './markdown_format_sink';
const markdownFormatSinkSource = require('!!raw-loader!./markdown_format_sink');
const markdownFormatSinkHtml = renderToHtml(MarkdownFormatSink);

export const MarkdownFormatExample = {
title: 'Markdown format',
Expand All @@ -45,10 +44,6 @@ export const MarkdownFormatExample = {
type: GuideSectionTypes.JS,
code: markdownFormatSource,
},
{
type: GuideSectionTypes.HTML,
code: markdownFormatHtml,
},
],
title: 'Built in plugins',
text: (
Expand All @@ -59,8 +54,9 @@ export const MarkdownFormatExample = {
Remark
</EuiLink>{' '}
by default. The translation layer automatically substitutes raw HTML
output with their EUI equivalent. This means anchor and code blocks
will become <strong>EuiLink</strong> and <strong>EuiCodeBlock</strong>{' '}
output with their EUI equivalent. This means anchor, code blocks and
horizontal rules will become <strong>EuiLink</strong>,{' '}
<strong>EuiCodeBlock</strong> and <strong>EuiHorizontalRule</strong>{' '}
components respectively.
</p>
),
Expand All @@ -73,11 +69,29 @@ export const MarkdownFormatExample = {
source: [
{
type: GuideSectionTypes.JS,
code: markdownFormatSinkSource,
code: markdownFormatStylesSource,
},
],
title: 'Text sizing and coloring',
text: (
<p>
<strong>EuiMarkdownFormat</strong> uses{' '}
<Link to="/display/text/">EuiText</Link> as a wrapper to handle all
the CSS styling when rendering the HTML. It also gives the ability to
control the text size and color with the <EuiCode>textSize</EuiCode>{' '}
and <EuiCode>color</EuiCode> props, respectively.
</p>
),
props: {
EuiMarkdownFormat,
},
demo: <MarkdownFormatStyles />,
},
{
source: [
{
type: GuideSectionTypes.HTML,
code: markdownFormatSinkHtml,
type: GuideSectionTypes.JS,
code: markdownFormatSinkSource,
},
],
title: 'Kitchen sink',
Expand Down
Loading