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] Global theme #4643

Merged
merged 108 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from 106 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
40ce62e
Renaming basic color vars
Feb 24, 2021
91fb5ef
Creating separate color ts files per theme
Feb 24, 2021
5a232ca
States WIP
Mar 1, 2021
64c2201
Merge remote-tracking branch 2_upstream/feature/css-in-js into featur…
Mar 12, 2021
9542647
Squashed commit of the following:
Mar 12, 2021
0900118
Fixing up examples
Mar 12, 2021
7400cd2
Putting all keys under euiTheme[COLOR_MODE_KEY]
Mar 12, 2021
b4a5b98
Updated/Created `border` files
Mar 12, 2021
3887900
Updating/Creating `size` file
Mar 12, 2021
7e23c4b
Trying to do more separations but cant in the theme builder file
Mar 12, 2021
6b1a554
Rudimentary typography file, somewhat broken calculations
Mar 12, 2021
bcc13b2
Fixing titles
Mar 14, 2021
7ce5f18
Cleaning up and fixing
Mar 15, 2021
00f4bae
Merge remote-tracking branch '2_upstream/feature/css-in-js' into feat…
Mar 15, 2021
6af2a7e
Moved textVariants :D
Mar 15, 2021
f24ec3d
Update src-docs/src/components/with_theme/theme_context.tsx
cchaos Mar 16, 2021
297727d
files, arrays
thompsongl Mar 16, 2021
3afe8d7
Merge branch 'feature/css-in-js_themes' of https://github.com/cchaos/…
thompsongl Mar 16, 2021
a94e18f
types
thompsongl Mar 16, 2021
b2cd915
move all of ams
thompsongl Mar 16, 2021
93098f7
Merge pull request #43 from thompsongl/feature/css-in-js_themes
cchaos Mar 16, 2021
618c0ef
colorMode key improvements
thompsongl Mar 17, 2021
d0917ad
sizeToPixel; todos
thompsongl Mar 17, 2021
5567e00
better sizeToPixel
thompsongl Mar 17, 2021
ccd42e4
optional dependency array; clean up
thompsongl Mar 24, 2021
7a8595d
clean up
thompsongl Mar 25, 2021
eea1903
single dependency string
thompsongl Mar 26, 2021
c71a0ad
uppercase colorMode keys; getOn colorMode shortcut
thompsongl Mar 26, 2021
65b148e
clean up
thompsongl Mar 26, 2021
a2494b2
Merge pull request #44 from thompsongl/feature/css-in-js_themes
cchaos Mar 26, 2021
86978e7
Merge branch 'feature/css-in-js' into feature/css-in-js_themes
thompsongl Mar 29, 2021
067d9fa
Moved default theme creation to `src/themes/eui` folder
Mar 29, 2021
f9f33fc
Tyring to type colors
Mar 29, 2021
76455f2
wip ts for theme building
thompsongl Mar 30, 2021
ed0edee
better computed
thompsongl Mar 30, 2021
0e88097
computed type from uncomputed type; ams types
thompsongl Apr 6, 2021
df26bc2
strict; matching theme shapes
thompsongl Apr 8, 2021
2a2b699
Merge pull request #46 from thompsongl/feature/css-in-js_themes
cchaos Apr 12, 2021
9fdcbf0
Merge branch 'feature/css-in-js' into feature/css-in-js_themes
thompsongl Apr 12, 2021
a0d474c
states, shadows; utils
thompsongl Apr 12, 2021
0c0e525
clean up
thompsongl Apr 12, 2021
2e5705f
adjust makeHighContrastColor; color services
thompsongl Apr 14, 2021
16ea2ed
animation, responsive, zindex
thompsongl Apr 14, 2021
f030d3d
font type names
thompsongl Apr 14, 2021
4cb85c9
keyframes
thompsongl Apr 14, 2021
e77be96
WIP: mixin pattern
thompsongl Apr 15, 2021
474ae03
Merge branch 'feature/css-in-js' into feature/css-in-js_themes
thompsongl Apr 21, 2021
8b1d9aa
Organizing colors and starting a “Values” page for the Theme Context …
Apr 24, 2021
9225fd3
Making Amsterdam lightestShade slightly bluer
Apr 24, 2021
2b727c0
UPdating COlors and adding Size docs
Apr 24, 2021
e29541e
Nested all font variables under `font` and added Typography docs
Apr 24, 2021
b15af40
Added Border docs
Apr 24, 2021
87c8184
Added Shadow docs
Apr 24, 2021
41dd61a
Updated focus and added docs
Apr 24, 2021
e467e88
Created reusable component for theme values in docs
Apr 24, 2021
d288783
UPdated breakpoints>no s and flattened animation (and added docs)
Apr 24, 2021
c69e020
Questionable: Removed `font.size` from global theme
Apr 24, 2021
023ec79
Made brand colors editable, lots of TS errors on EuiColorPicker
Apr 24, 2021
f0f85b7
typescript updates
thompsongl Apr 26, 2021
8388209
exported type
thompsongl Apr 26, 2021
344350b
Merge pull request #50 from thompsongl/feature/css-in-js_themes_1
cchaos Apr 26, 2021
c87ad95
Working through some Typescript automation
Apr 30, 2021
018b57c
Finalizing docs layout with Sizing section (v1)
May 3, 2021
30a858b
Finalizing docs layout with Sizing section (v2)
May 3, 2021
acc9418
Finalizing docs layout with Sizing section (v2)
May 3, 2021
d68e49a
Better color samples (v1)
May 3, 2021
f3769c4
Property v2 with dot notation on name
May 3, 2021
efdc02e
Adding bottom bar to copy overrides
May 3, 2021
f514c6f
Using tabs to separate values from usage docs
May 3, 2021
3f49b2f
Adding more TS comments
May 4, 2021
d54a4dd
Moving docs to their own section
May 4, 2021
0c2907d
Different title
May 4, 2021
8b5458b
Merge remote-tracking branch 2_upstream/feature/css-in-js into featur…
May 4, 2021
7611c4b
A few fixes and addding more scales to size
May 4, 2021
f032da3
Working on typography docs
May 5, 2021
40cb4bd
Adding to the typography section
May 10, 2021
5ca383d
Building out Border section
May 11, 2021
1326bf6
Working on focus, but eventually deciding it doesn’t belong at the gl…
May 17, 2021
c6f7220
Moving Shadow into Colors
May 17, 2021
bbe6717
Started animation docs
May 17, 2021
66b58f4
Updating breakpoints
May 18, 2021
131fd12
Merge remote-tracking branch 'upstream/feature/css-in-js' into featur…
thompsongl Jul 7, 2021
2af12b6
clean up
thompsongl Jul 7, 2021
b39e5a0
provider docs
thompsongl Jul 7, 2021
6eafb03
color picker perf improvements
thompsongl Jul 8, 2021
8d385dd
Merge remote-tracking branch 'upstream/feature/css-in-js' into featur…
thompsongl Jul 13, 2021
4cbc67b
Merge remote-tracking branch 'upstream/feature/css-in-js' into featur…
thompsongl Jul 13, 2021
8603c87
trial: debounced text inputs
thompsongl Jul 19, 2021
5e40027
Merge remote-tracking branch 'upstream/feature/css-in-js' into featur…
thompsongl Jul 21, 2021
b295d35
Cleaning up existing docs
Jul 21, 2021
5e4a39f
Cleanup up theme files
Jul 21, 2021
8b67f26
Code cleanup
Jul 21, 2021
ed92df9
pagebackground -> body
thompsongl Jul 21, 2021
9326ad8
too many useCallbacks
thompsongl Jul 21, 2021
9c61627
Updating Theme Provider docs
Jul 21, 2021
0edb740
Added button for clearing overrides
Jul 21, 2021
1e8ef53
Added usage examples/notes to Animation and Breakpoints
Jul 21, 2021
bfff9f6
Added more usage examples
Jul 22, 2021
3f44b4a
useDebouncedUpdate
thompsongl Jul 22, 2021
adae3d5
unique id
thompsongl Jul 22, 2021
1cb2339
another unique id :expressionless:
thompsongl Jul 22, 2021
3773a1f
remove temporary docs
thompsongl Jul 28, 2021
eba5d30
update json flyout
thompsongl Jul 28, 2021
b9d269c
rearrange special colors so text colors can react to body
thompsongl Jul 28, 2021
2b5af68
clean up
thompsongl Jul 29, 2021
da02351
Merge remote-tracking branch 'upstream/feature/css-in-js' into featur…
thompsongl Jul 29, 2021
1f94496
Cleaning up and adding some more type names
Jul 29, 2021
d48553f
useCanAnimate
thompsongl Jul 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
2 changes: 1 addition & 1 deletion scripts/babel/proptypes-from-ts-props/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ function getPropTypesForNode(node, optional, state) {
types.arrayExpression(
node.properties.map(property =>
types.stringLiteral(
property.key.name || property.key.name || property.key.value
property.key ? property.key.name || property.key.value : property.argument.name
)
)
),
Expand Down
8 changes: 3 additions & 5 deletions src-docs/src/components/with_theme/theme_context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import React from 'react';
import { EUI_THEMES, EUI_THEME } from '../../../../src/themes';
// @ts-ignore importing from a JS file
import { applyTheme } from '../../services';
import {
EuiThemeProvider,
EuiThemeDefault,
EuiThemeAmsterdam,
} from '../../../../src/services';
import { EuiThemeProvider } from '../../../../src/services';
import { EuiThemeAmsterdam } from '../../../../src/themes/eui-amsterdam/theme';
import { EuiThemeDefault } from '../../../../src/themes/eui/theme';

const THEME_NAMES = EUI_THEMES.map(({ value }) => value);

Expand Down
29 changes: 12 additions & 17 deletions src-docs/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ import { I18nTokens } from './views/package/i18n_tokens';
import { SuperSelectExample } from './views/super_select/super_select_example';

import { ThemeExample } from './views/theme/theme_example';
import ThemeValues from './views/theme/values';

/** Elastic Charts */

Expand All @@ -238,10 +239,6 @@ import { ElasticChartsPieExample } from './views/elastic_charts/pie_example';

import { ElasticChartsAccessibilityExample } from './views/elastic_charts/accessibility_example';

/** ! Temporary ! */

import Canopy from './views/emotion/canopy';

const createExample = (example, customTitle) => {
if (!example) {
throw new Error(
Expand Down Expand Up @@ -324,18 +321,6 @@ const createMarkdownExample = (example, title) => {
};

const navigation = [
{
name: 'Temporary',
items: [
createExample(
{
intro: <Canopy />,
sections: [],
},
'Canopy'
),
],
},
{
name: 'Guidelines',
items: [
Expand Down Expand Up @@ -496,10 +481,20 @@ const navigation = [
ResizeObserverExample,
ResponsiveExample,
TextDiffExample,
ThemeExample,
WindowEventExample,
].map((example) => createExample(example)),
},
{
name: 'Theming',
items: [
createExample(ThemeExample, 'Theme provider'),
{
name: 'Global values',
component: ThemeValues,
isNew: true,
},
],
},
{
name: 'Package',
items: [Changelog, I18nTokens],
Expand Down
120 changes: 55 additions & 65 deletions src-docs/src/services/playground/knobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,38 @@ export const humanizeType = (type) => {
humanizedType = type.name;
}

return humanizedType;
let typeMarkup;

if (humanizedType) {
typeMarkup = humanizedType;

const functionMatches = [
...humanizedType.matchAll(/\([^=]*\) =>\s\w*\)*/g),
];

const types = humanizedType.split(/\([^=]*\) =>\s\w*\)*/);

if (functionMatches.length > 0) {
let elements = '';
let j = 0;
for (let i = 0; i < types.length; i++) {
if (functionMatches[j]) {
elements =
`${elements}` +
`${types[i]}` +
'\n' +
`${functionMatches[j][0]}` +
'\n';
j++;
} else {
elements = `${elements}` + `${types[i]}` + '\n';
}
}
typeMarkup = elements;
}
}

return typeMarkup || humanizedType;
};

const getTooltip = (description, type, name) => (
Expand Down Expand Up @@ -359,87 +390,46 @@ const Knob = ({
};

const KnobColumn = ({ state, knobNames, error, set, isPlayground }) => {
return knobNames.map((name, idx) => {
const codeBlockProps = {
className: 'guideSection__tableCodeBlock',
paddingSize: 'none',
language: 'ts',
};

/**
* TS Type
*/
let humanizedType;

if (
state[name].custom &&
state[name].custom.origin &&
state[name].custom.origin.type
)
humanizedType = humanizeType(state[name].custom.origin.type);

let typeMarkup;

if (humanizedType) {
typeMarkup = humanizedType && (
<EuiCodeBlock {...codeBlockProps}>{humanizedType}</EuiCodeBlock>
);

const functionMatches = [
...humanizedType.matchAll(/\([^=]*\) =>\s\w*\)*/g),
];

const types = humanizedType.split(/\([^=]*\) =>\s\w*\)*/);

if (functionMatches.length > 0) {
let elements = '';
let j = 0;
for (let i = 0; i < types.length; i++) {
if (functionMatches[j]) {
elements =
`${elements}` +
`${types[i]}` +
'\n' +
`${functionMatches[j][0]}` +
'\n';
j++;
} else {
elements = `${elements}` + `${types[i]}` + '\n';
}
}
typeMarkup = (
<EuiCodeBlock {...codeBlockProps}>{elements}</EuiCodeBlock>
);
}
}
const codeBlockProps = {
className: 'guideSection__tableCodeBlock',
paddingSize: 'none',
language: 'ts',
};

return knobNames.map((name, idx) => {
/**
* Prop name
*/
let humanizedName = <strong className="eui-textBreakNormal">{name}</strong>;

if (
state[name].custom &&
state[name].custom.origin &&
state[name].custom.origin.required
) {
if (state[name].custom?.origin?.required) {
humanizedName = (
<>
{humanizedName} <EuiTextColor color="danger">(required)</EuiTextColor>
</>
);
}

/**
* TS Type
*/
let typeMarkup;

if (state[name].custom?.origin?.type) {
const humanizedType = humanizeType(state[name].custom.origin.type);

if (humanizedType) {
typeMarkup = (
<EuiCodeBlock {...codeBlockProps}>{humanizedType}</EuiCodeBlock>
);
}
}

/**
* Default value
*/
let defaultValueMarkup;
if (
// !isPlayground &&
state[name].custom &&
state[name].custom.origin &&
state[name].custom.origin.defaultValue
) {
if (state[name].custom?.origin?.defaultValue) {
const defaultValue = state[name].custom.origin.defaultValue;
defaultValueMarkup = (
<EuiText size="xs">
Expand Down
4 changes: 1 addition & 3 deletions src-docs/src/views/code/code_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ export const CodeExample = {
<EuiLink external href="https://prismjs.com/">
library
</EuiLink>
.
<br />
The <EuiCode>language</EuiCode> prop can also be omitted to simply
. The <EuiCode>language</EuiCode> prop can also be omitted to simply
render formatted but unhighlighted code.
</p>
<p>
Expand Down
Loading