@ember-eui/core 1.5.0 → 1.6.0
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/CHANGELOG.md +4 -0
- package/addon/components/eui-markdown-format/index.hbs +2 -1
- package/addon/components/eui-stat/description/index.hbs +16 -0
- package/addon/components/eui-stat/index.hbs +82 -0
- package/addon/components/eui-stat/index.ts +45 -0
- package/addon/components/eui-stat/title/index.hbs +18 -0
- package/addon/helpers/class-names.ts +8 -2
- package/addon/utils/css-mappings/eui-stat.ts +26 -0
- package/addon/utils/css-mappings/index.ts +2 -0
- package/addon/utils/markdown/plugins/to-dom.ts +4 -0
- package/app/components/eui-stat/description/index.js +1 -0
- package/app/components/eui-stat/index.js +1 -0
- package/app/components/eui-stat/title/index.js +1 -0
- package/docs/display/stat-demo/demo1.md +131 -0
- package/docs/display/stat-demo/demo2.md +59 -0
- package/docs/display/stat.md +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
{{! This hbs was inspired by https://github.com/ampatspell/ember-cli-remark-static/blob/v3.0.5/addon/components/remark.hbs }}
|
|
1
2
|
<div class="euiMarkdownFormat">
|
|
2
3
|
{{this.result.element}}
|
|
3
4
|
{{#each this.result.components as |CompNode|}}
|
|
@@ -10,4 +11,4 @@
|
|
|
10
11
|
{{/let}}
|
|
11
12
|
{{/in-element}}
|
|
12
13
|
{{/each}}
|
|
13
|
-
</div>
|
|
14
|
+
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{{#if @descriptionElement}}
|
|
2
|
+
{{#let (element @descriptionElement) as |DescriptionElement|}}
|
|
3
|
+
<EuiText class="euiStat__description" @size="s">
|
|
4
|
+
<DescriptionElement aria-hidden="true">
|
|
5
|
+
{{yield}}
|
|
6
|
+
</DescriptionElement>
|
|
7
|
+
</EuiText>
|
|
8
|
+
{{/let}}
|
|
9
|
+
|
|
10
|
+
{{else}}
|
|
11
|
+
<EuiText class="euiStat__description" @size="s">
|
|
12
|
+
<p aria-hidden="true">
|
|
13
|
+
{{yield}}
|
|
14
|
+
</p>
|
|
15
|
+
</EuiText>
|
|
16
|
+
{{/if}}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{{#let
|
|
2
|
+
(class-names
|
|
3
|
+
textAlign=(arg-or-default @textAlign "left") componentName="EuiStat"
|
|
4
|
+
)
|
|
5
|
+
(class-names
|
|
6
|
+
"euiStat__title"
|
|
7
|
+
(if @isLoading "euiStat__title-isLoading")
|
|
8
|
+
color=(arg-or-default @titleColor "default")
|
|
9
|
+
addBase=false
|
|
10
|
+
componentName="EuiStat"
|
|
11
|
+
)
|
|
12
|
+
(arg-or-default @reverse false)
|
|
13
|
+
(arg-or-default @titleSize "l")
|
|
14
|
+
as |classes titleClasses reverse titleSize|
|
|
15
|
+
}}
|
|
16
|
+
<div class={{classes}} ...attributes>
|
|
17
|
+
{{#if reverse}}
|
|
18
|
+
<EuiStat::Title
|
|
19
|
+
class={{titleClasses}}
|
|
20
|
+
@titleElement={{@titleElement}}
|
|
21
|
+
@titleSize={{titleSize}}
|
|
22
|
+
@isColorClass={{this.isColorClass}}
|
|
23
|
+
>
|
|
24
|
+
{{#if @isLoading}}
|
|
25
|
+
--
|
|
26
|
+
{{else}}
|
|
27
|
+
{{#if (has-block "title")}}
|
|
28
|
+
{{yield to="title"}}
|
|
29
|
+
{{else}}
|
|
30
|
+
{{@title}}
|
|
31
|
+
{{/if}}
|
|
32
|
+
{{/if}}
|
|
33
|
+
</EuiStat::Title>
|
|
34
|
+
<EuiStat::Description
|
|
35
|
+
@descriptionElement={{@descriptionElement}}
|
|
36
|
+
>
|
|
37
|
+
{{#if (has-block "description")}}
|
|
38
|
+
{{yield to="description"}}
|
|
39
|
+
{{else}}
|
|
40
|
+
{{@description}}
|
|
41
|
+
{{/if}}
|
|
42
|
+
</EuiStat::Description>
|
|
43
|
+
{{else}}
|
|
44
|
+
<EuiStat::Description
|
|
45
|
+
@descriptionElement={{@descriptionElement}}
|
|
46
|
+
>
|
|
47
|
+
{{#if (has-block "description")}}
|
|
48
|
+
{{yield to="description"}}
|
|
49
|
+
{{else}}
|
|
50
|
+
{{@description}}
|
|
51
|
+
{{/if}}
|
|
52
|
+
</EuiStat::Description>
|
|
53
|
+
<EuiStat::Title
|
|
54
|
+
class={{titleClasses}}
|
|
55
|
+
@titleElement={{@titleElement}}
|
|
56
|
+
@titleSize={{titleSize}}
|
|
57
|
+
@isColorClass={{this.isColorClass}}
|
|
58
|
+
>
|
|
59
|
+
{{#if @isLoading}}
|
|
60
|
+
--
|
|
61
|
+
{{else}}
|
|
62
|
+
{{#if (has-block "title")}}
|
|
63
|
+
{{yield to="title"}}
|
|
64
|
+
{{else}}
|
|
65
|
+
{{@title}}
|
|
66
|
+
{{/if}}
|
|
67
|
+
{{/if}}
|
|
68
|
+
</EuiStat::Title>
|
|
69
|
+
{{/if}}
|
|
70
|
+
{{#if this.screenReader}}
|
|
71
|
+
<p {{screen-reader-only}}>
|
|
72
|
+
{{#if reverse}}
|
|
73
|
+
{{@title}}
|
|
74
|
+
{{@description}}
|
|
75
|
+
{{else}}
|
|
76
|
+
{{@description}}
|
|
77
|
+
{{@title}}
|
|
78
|
+
{{/if}}
|
|
79
|
+
</p>
|
|
80
|
+
{{/if}}
|
|
81
|
+
</div>
|
|
82
|
+
{{/let}}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { colorMapping } from '../../utils/css-mappings/eui-stat';
|
|
3
|
+
import { sizeMapping } from '../../utils/css-mappings/eui-title';
|
|
4
|
+
import { keysOf } from '../common';
|
|
5
|
+
|
|
6
|
+
type EuiTitleSize = keyof typeof sizeMapping;
|
|
7
|
+
|
|
8
|
+
export const COLORS = keysOf(colorMapping);
|
|
9
|
+
|
|
10
|
+
export const isColorClass = (
|
|
11
|
+
input: string
|
|
12
|
+
): input is keyof typeof colorMapping => {
|
|
13
|
+
return colorMapping.hasOwnProperty(input);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type StatArgs = {
|
|
17
|
+
/**
|
|
18
|
+
* The color of the title text
|
|
19
|
+
*/
|
|
20
|
+
titleColor?: keyof typeof colorMapping | string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Size of the title. See EuiTitle for options ('s', 'm', 'l'... etc)
|
|
24
|
+
*/
|
|
25
|
+
titleSize?: EuiTitleSize;
|
|
26
|
+
|
|
27
|
+
title?: string | Component;
|
|
28
|
+
description?: string | Component;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default class EuiStart extends Component<StatArgs> {
|
|
32
|
+
get isColorClass() {
|
|
33
|
+
if (this.args.titleColor) {
|
|
34
|
+
return isColorClass(this.args.titleColor);
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get useScreenReader() {
|
|
40
|
+
return (
|
|
41
|
+
typeof this.args.title === 'string' &&
|
|
42
|
+
typeof this.args.description === 'string'
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{{#if @titleElement}}
|
|
2
|
+
{{#let (element @titleElement) as |TitleElement|}}
|
|
3
|
+
<EuiTitle @size={{@titleSize}} ...attributes>
|
|
4
|
+
<TitleElement
|
|
5
|
+
aria-hidden="true"
|
|
6
|
+
{{style (if @isColorClass (hash color=@titleColor))}}
|
|
7
|
+
>
|
|
8
|
+
{{yield}}
|
|
9
|
+
</TitleElement>
|
|
10
|
+
</EuiTitle>
|
|
11
|
+
{{/let}}
|
|
12
|
+
{{else}}
|
|
13
|
+
<EuiTitle @size={{@titleSize}} ...attributes>
|
|
14
|
+
<p aria-hidden="true" {{style (if @isColorClass (hash color=@titleColor))}}>
|
|
15
|
+
{{yield}}
|
|
16
|
+
</p>
|
|
17
|
+
</EuiTitle>
|
|
18
|
+
{{/if}}
|
|
@@ -40,8 +40,12 @@ interface Options extends IObjectKeys {
|
|
|
40
40
|
*
|
|
41
41
|
* @param classes - List of classes that will be joined
|
|
42
42
|
*/
|
|
43
|
-
export function classNames(
|
|
43
|
+
export function classNames(
|
|
44
|
+
classNames: string[] = [],
|
|
45
|
+
options: Options & { addBase: boolean }
|
|
46
|
+
): string {
|
|
44
47
|
let { componentName, ...rest } = options;
|
|
48
|
+
let includeBase = options.addBase !== false;
|
|
45
49
|
let str = `${classNames.join(' ')}`;
|
|
46
50
|
if (options.componentName) {
|
|
47
51
|
assert(
|
|
@@ -49,7 +53,9 @@ export function classNames(classNames: string[] = [], options: Options): string
|
|
|
49
53
|
cssMappings[options.componentName] !== undefined
|
|
50
54
|
);
|
|
51
55
|
const component = cssMappings[options.componentName];
|
|
52
|
-
|
|
56
|
+
if (includeBase) {
|
|
57
|
+
str = `${str} ${component.base}`;
|
|
58
|
+
}
|
|
53
59
|
|
|
54
60
|
for (let key in rest) {
|
|
55
61
|
if (component.properties[key] && component.properties[key][rest[key]]) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const baseClass = 'euiStat';
|
|
2
|
+
|
|
3
|
+
export const textAlignMapping = {
|
|
4
|
+
left: `${baseClass}--leftAligned`,
|
|
5
|
+
center: `${baseClass}--centerAligned`,
|
|
6
|
+
right: `${baseClass}--rightAligned`
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const colorMapping = {
|
|
10
|
+
default: '',
|
|
11
|
+
subdued: `${baseClass}__title--subdued`,
|
|
12
|
+
primary: `${baseClass}__title--primary`,
|
|
13
|
+
success: `${baseClass}__title--success`,
|
|
14
|
+
danger: `${baseClass}__title--danger`,
|
|
15
|
+
accent: `${baseClass}__title--accent`
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const mapping: ComponentMapping = {
|
|
19
|
+
base: baseClass,
|
|
20
|
+
properties: {
|
|
21
|
+
textAlign: textAlignMapping,
|
|
22
|
+
color: colorMapping
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default mapping;
|
|
@@ -53,8 +53,10 @@ import EuiToolTip from './eui-tool-tip';
|
|
|
53
53
|
import EuiToast from './eui-toast';
|
|
54
54
|
import EuiGlobalToastList from './eui-global-toast-list';
|
|
55
55
|
import EuiCodeBlockImpl from './eui-code-block-impl';
|
|
56
|
+
import EuiStat from './eui-stat';
|
|
56
57
|
|
|
57
58
|
const mapping: Mapping = {
|
|
59
|
+
EuiStat,
|
|
58
60
|
EuiCodeBlockImpl,
|
|
59
61
|
EuiAccordion,
|
|
60
62
|
EuiIcon,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-stat/description';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-stat';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-stat/title';
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
---
|
|
2
|
+
order: 1
|
|
3
|
+
---
|
|
4
|
+
# Demo
|
|
5
|
+
|
|
6
|
+
```hbs template
|
|
7
|
+
<div>
|
|
8
|
+
<EuiFlexGroup>
|
|
9
|
+
<EuiFlexItem>
|
|
10
|
+
<EuiStat @title='7,600 mm' @description='Total people' />
|
|
11
|
+
</EuiFlexItem>
|
|
12
|
+
</EuiFlexGroup>
|
|
13
|
+
</div>
|
|
14
|
+
<EuiSpacer />
|
|
15
|
+
<div>
|
|
16
|
+
<EuiFlexGroup>
|
|
17
|
+
<EuiFlexItem>
|
|
18
|
+
<EuiStat
|
|
19
|
+
@title='22,123'
|
|
20
|
+
@description='Total people'
|
|
21
|
+
@titleColor='primary'
|
|
22
|
+
/>
|
|
23
|
+
</EuiFlexItem>
|
|
24
|
+
<EuiFlexItem>
|
|
25
|
+
<EuiStat
|
|
26
|
+
@title='22,123'
|
|
27
|
+
@description='Total people'
|
|
28
|
+
@titleColor='accent'
|
|
29
|
+
/>
|
|
30
|
+
</EuiFlexItem>
|
|
31
|
+
<EuiFlexItem>
|
|
32
|
+
<EuiStat
|
|
33
|
+
@title='22,123'
|
|
34
|
+
@description='Total people'
|
|
35
|
+
@titleColor='danger'
|
|
36
|
+
/>
|
|
37
|
+
</EuiFlexItem>
|
|
38
|
+
</EuiFlexGroup>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<EuiSpacer />
|
|
42
|
+
<div>
|
|
43
|
+
<EuiFlexGroup>
|
|
44
|
+
<EuiFlexItem>
|
|
45
|
+
<EuiStat
|
|
46
|
+
@title='22,123'
|
|
47
|
+
@description='Total people'
|
|
48
|
+
@isLoading={{this.isLoading}}
|
|
49
|
+
@titleColor='primary'
|
|
50
|
+
/>
|
|
51
|
+
<EuiSpacer />
|
|
52
|
+
<EuiSwitch
|
|
53
|
+
@label='Show as loading'
|
|
54
|
+
@checked={{this.isLoading}}
|
|
55
|
+
@onChange={{pick 'target.checked' (set this 'isLoading')}}
|
|
56
|
+
/>
|
|
57
|
+
</EuiFlexItem>
|
|
58
|
+
</EuiFlexGroup>
|
|
59
|
+
</div>
|
|
60
|
+
<EuiSpacer />
|
|
61
|
+
<div>
|
|
62
|
+
<EuiFlexGroup>
|
|
63
|
+
<EuiFlexItem>
|
|
64
|
+
<EuiPanel>
|
|
65
|
+
<EuiStat
|
|
66
|
+
@title='8,888'
|
|
67
|
+
@description='Total widgets'
|
|
68
|
+
@textAlign='right'
|
|
69
|
+
@isLoading={{this.isLoading}}
|
|
70
|
+
>
|
|
71
|
+
<EuiIcon @type='empty' />
|
|
72
|
+
</EuiStat>
|
|
73
|
+
</EuiPanel>
|
|
74
|
+
</EuiFlexItem>
|
|
75
|
+
<EuiFlexItem>
|
|
76
|
+
<EuiPanel>
|
|
77
|
+
<EuiStat
|
|
78
|
+
@title='2,000'
|
|
79
|
+
@description='Pending widgets'
|
|
80
|
+
@titleColor='accent'
|
|
81
|
+
@textAlign='right'
|
|
82
|
+
@isLoading={{this.Loading}}
|
|
83
|
+
>
|
|
84
|
+
<EuiIcon @type='clock' @color='accent' />
|
|
85
|
+
</EuiStat>
|
|
86
|
+
</EuiPanel>
|
|
87
|
+
</EuiFlexItem>
|
|
88
|
+
<EuiFlexItem>
|
|
89
|
+
<EuiPanel>
|
|
90
|
+
<EuiStat
|
|
91
|
+
@title='6,800'
|
|
92
|
+
@description='Success widgets'
|
|
93
|
+
@titleColor='success'
|
|
94
|
+
@textAlign='right'
|
|
95
|
+
@isLoading={{this.isLoading}}
|
|
96
|
+
>
|
|
97
|
+
<EuiIcon @type='check' @color='success' />
|
|
98
|
+
</EuiStat>
|
|
99
|
+
</EuiPanel>
|
|
100
|
+
</EuiFlexItem>
|
|
101
|
+
<EuiFlexItem>
|
|
102
|
+
<EuiPanel>
|
|
103
|
+
<EuiStat
|
|
104
|
+
@title='88'
|
|
105
|
+
@description='Error widgets'
|
|
106
|
+
@titleColor='danger'
|
|
107
|
+
@textAlign='right'
|
|
108
|
+
@isLoading={{this.isLoading}}
|
|
109
|
+
>
|
|
110
|
+
<EuiIcon @type='alert' @color='danger' />
|
|
111
|
+
</EuiStat>
|
|
112
|
+
</EuiPanel>
|
|
113
|
+
</EuiFlexItem>
|
|
114
|
+
</EuiFlexGroup>
|
|
115
|
+
<EuiSpacer />
|
|
116
|
+
<EuiSwitch
|
|
117
|
+
@label='Show as loading'
|
|
118
|
+
@checked={{this.isLoading}}
|
|
119
|
+
@onChange={{pick 'target.checked' (set this 'isLoading')}}
|
|
120
|
+
/>
|
|
121
|
+
</div>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
```js component
|
|
125
|
+
import Component from '@glimmer/component';
|
|
126
|
+
import { tracked } from '@glimmer/tracking';
|
|
127
|
+
|
|
128
|
+
export default class StatDemoComponent extends Component {
|
|
129
|
+
@tracked isLoading = true;
|
|
130
|
+
}
|
|
131
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Demo
|
|
2
|
+
|
|
3
|
+
<EuiTitle>Title size</EuiTitle>
|
|
4
|
+
<EuiText>
|
|
5
|
+
title uses the <EuiCode>EuiTitle</EuiCode> component and thus uses the same sizing property
|
|
6
|
+
values (applied via the titleSize property). Although all EuiTitle sizes are
|
|
7
|
+
available, suggested sizes include <EuiCode>'l' | 'm' | 's' | 'xs' | 'xxs' | 'xxxs'</EuiCode>. By
|
|
8
|
+
default, the size is set to large <EuiCode>l</EuiCode>. The @description label cannot be
|
|
9
|
+
re-sized via component properties.
|
|
10
|
+
</EuiText>
|
|
11
|
+
<EuiSpacer/>
|
|
12
|
+
|
|
13
|
+
```hbs template
|
|
14
|
+
<div>
|
|
15
|
+
<EuiFlexGroup>
|
|
16
|
+
<EuiFlexItem>
|
|
17
|
+
<EuiStat @title='1,000,000' @description='Large size' @titleSize='l' />
|
|
18
|
+
</EuiFlexItem>
|
|
19
|
+
<EuiFlexItem>
|
|
20
|
+
<EuiStat @title='1,000,000' @description='Medium size' @titleSize='m' />
|
|
21
|
+
</EuiFlexItem>
|
|
22
|
+
<EuiFlexItem>
|
|
23
|
+
<EuiStat @title='1,000,000' @description='Small size' @titleSize='s' />
|
|
24
|
+
</EuiFlexItem>
|
|
25
|
+
</EuiFlexGroup>
|
|
26
|
+
<EuiFlexGroup>
|
|
27
|
+
<EuiFlexItem>
|
|
28
|
+
<EuiStat
|
|
29
|
+
@title='1,000,000'
|
|
30
|
+
@description='Extra small size'
|
|
31
|
+
@titleSize='xs'
|
|
32
|
+
/>
|
|
33
|
+
</EuiFlexItem>
|
|
34
|
+
<EuiFlexItem>
|
|
35
|
+
<EuiStat
|
|
36
|
+
@title='1,000,000'
|
|
37
|
+
@description='Extra extra small size'
|
|
38
|
+
@titleSize='xxs'
|
|
39
|
+
/>
|
|
40
|
+
</EuiFlexItem>
|
|
41
|
+
<EuiFlexItem>
|
|
42
|
+
<EuiStat
|
|
43
|
+
@title='1,000,000'
|
|
44
|
+
@description='Extra extra extra small size'
|
|
45
|
+
@titleSize='xxxs'
|
|
46
|
+
/>
|
|
47
|
+
</EuiFlexItem>
|
|
48
|
+
</EuiFlexGroup>
|
|
49
|
+
</div>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```js component
|
|
53
|
+
import Component from '@glimmer/component';
|
|
54
|
+
import { tracked } from '@glimmer/tracking';
|
|
55
|
+
|
|
56
|
+
export default class StatDemoComponent extends Component {
|
|
57
|
+
@tracked isLoading = true;
|
|
58
|
+
}
|
|
59
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Stat
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-eui/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Ember Components for Elastic UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -154,5 +154,5 @@
|
|
|
154
154
|
"volta": {
|
|
155
155
|
"node": "12.22.1"
|
|
156
156
|
},
|
|
157
|
-
"gitHead": "
|
|
157
|
+
"gitHead": "da091fff2aaf81d6988bc7c2ef11999764750d8b"
|
|
158
158
|
}
|