Skip to content

Commit deabfa9

Browse files
[Emotion] Convert EuiListGroup (#6207)
* Converted list group styles to emotion * Initial list group item styles * Converting `EuiListGroupItem` and `EuiPinnableListGroup` to Emotion * Adding extra action component * Removed `inherit` color from `EuiListGroupItem` * Removed `ghost` color in favor of theme provider * Passing down `size` and `color` props * Added new CL entry * Added list group inner * Making focus outlines look good * Adding `alwaysShow` * Custom color in last example * Updating ghost examples with theme provider * Reverting class names in use * CL * [EuiDataGrid] Remove mounted snapshots in favor of render * [PR feedback ] misc test/css tweaks - make `css` merging as top-level prop and as iconProps work correctly - add requiredProps to basic renders test * [PR feedback] Remove unnecessary `euiListGroupItemInnerStyles` args in favor of array logic * [PR feedback] Remove `euiListGroupItemStyles` in favor of array conditionals & obj keys + DRY out repeated euiBackgroundColor() calls * Fix non-dark-mode EuiListGroup in docs * [docs] Convert EuiListGroup docs from js to tsx * [EuiListGroupItemExtraAction] Export props type and document more clearly in props table + move alwayShow to top of props list * [EuiListGroupItemExtraAction] Fix non-working hover/focus CSS selectors - `.euiListGroupItem-isDisabled` is no longer a className, so the :not() selector is not working and the action still appears on hover on disabled items - passing `parentIsDisabled` as an internal prop from EuiListGroupItem and making it an array conditional solves the hover issue - the parent li is not focusable so the `:focus &` selector doesn't work either. Changing it to to the button and `+ &` solves the issue + remove unnecessary comment * [EuiListGroupItemExtraAction] Add basic unit tests + clean up styles array further - the hover CSS is unnecessary if alwaysShow is true, so add a condition for it * Fix overflowing text pushing action icons outside of item * [EuiListGroupItemExtraAction] Fix margin-right spacing - currently 8px on prod which generally seems to match the button padding size better * [Enhancement] Improve button hitbox of tooltip wrapped items - this allows button content inside tooltips to grow to 100% of the EuiListGroupItem - this is an enhancement from current prod behavior * Clean up wrapText CSS - Remove unnecessary CSS on __inner - the width: 100% is totally unnecessary (tested with both extra action and without) and the word break can be applied to the __label CSS instead - DRY out unsetting CSS by using ternary instead of base CSS (but keep empty base for naming) - DRY out CSS by using text utils * Fix raw `icon` elements being passed it not receiving our new Emotion CSS * Fix/cleanup misc custom maxWidth behavior - use logical CSS property instead of max-width - do not apply maxWidthDefault emotion style if using a custom inline max-width - fix maxWidth conditional checks - remove || fallback / type def in favor of let - improve props documentation/typing * [docs] other misc props documentation improvements * misc code organization * [EuiListGroupItem] Add working `shouldRenderCustomStyles` + test nested `iconProps` and `extraAction` props + fix `extraAction` props not correctly passing/merging `className` + fix misc console.warn about missing EuiButtonIcon aria-label + add test for `style` prop on parent EuiListGroupItem, since it gets spread to the wrapped child and not the className wrapper * Remove `euiPinnableListGroup__itemExtraAction` classes - they're now being correctly passed to the `EuiListGroupItemExtraAction` but they're not really doing anything / just adding a lot of noise - consumers can simply hook into `.euiListGroupItemExtraAction` instead - no Kibana references to these classes, so IMO they're safe to remove Co-authored-by: Constance Chen <[email protected]>
1 parent bc232d2 commit deabfa9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1261
-1340
lines changed

src-docs/src/views/collapsible_nav/collapsible_nav_all.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { KibanaNavLinks, SecurityGroup } from './collapsible_nav_list';
2525

2626
import contentSvg from '../../images/content.svg';
2727
import { useExitPath } from '../../services/routing/routing';
28+
import { EuiThemeProvider } from '../../../../src/services';
2829

2930
const TopLinks: EuiPinnableListGroupItemProps[] = [
3031
{
@@ -151,22 +152,23 @@ const CollapsibleNavAll = () => {
151152
{/* Dark deployments section */}
152153
<EuiFlexItem grow={false} style={{ flexShrink: 0 }}>
153154
<EuiCollapsibleNavGroup isCollapsible={false} background="dark">
154-
<EuiListGroup
155-
color="ghost"
156-
maxWidth="none"
157-
gutterSize="none"
158-
size="s"
159-
listItems={[
160-
{
161-
label: 'Manage deployment',
162-
href: '#',
163-
iconType: 'logoCloud',
164-
iconProps: {
165-
color: 'ghost',
155+
<EuiThemeProvider colorMode="dark">
156+
<EuiListGroup
157+
maxWidth="none"
158+
gutterSize="none"
159+
size="s"
160+
listItems={[
161+
{
162+
label: 'Manage deployment',
163+
href: '#',
164+
iconType: 'logoCloud',
165+
iconProps: {
166+
color: 'ghost',
167+
},
166168
},
167-
},
168-
]}
169-
/>
169+
]}
170+
/>
171+
</EuiThemeProvider>
170172
</EuiCollapsibleNavGroup>
171173
</EuiFlexItem>
172174

src-docs/src/views/collapsible_nav/collapsible_nav_list.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import { EuiSpacer } from '../../../../src/components/spacer';
1212
import { EuiButton, EuiButtonIcon } from '../../../../src/components/button';
1313
import { EuiLink } from '../../../../src/components/link';
14+
import { EuiThemeProvider } from '../../../../src/services';
1415

1516
const deploymentsList: EuiListGroupProps['listItems'] = [
1617
{
@@ -62,11 +63,11 @@ export const DeploymentsGroup = (
6263
background="dark"
6364
>
6465
<div role="group" className="kibanaNavDeployment__content">
65-
<EuiListGroup listItems={deploymentsList} flush />
66-
<EuiSpacer size="s" />
67-
<EuiButton color="ghost" fullWidth>
68-
Manage deployments
69-
</EuiButton>
66+
<EuiThemeProvider colorMode="dark">
67+
<EuiListGroup listItems={deploymentsList} flush />
68+
<EuiSpacer size="s" />
69+
<EuiButton fullWidth>Manage deployments</EuiButton>
70+
</EuiThemeProvider>
7071
</div>
7172
</EuiCollapsibleNavGroup>
7273
);

src-docs/src/views/list_group/list_group_example.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
EuiPinnableListGroup,
1010
EuiCode,
1111
} from '../../../../src/components';
12-
import { EuiPinnableListGroupItem } from './props';
12+
import { EuiPinnableListGroupItem, EuiListGroupItemExtraAction } from './props';
1313

1414
import ListGroup from './list_group';
1515
const listGroupSource = require('!!raw-loader!./list_group');
@@ -53,7 +53,11 @@ export const ListGroupExample = {
5353
</p>
5454
</>
5555
),
56-
props: { EuiListGroup, EuiListGroupItem },
56+
props: {
57+
EuiListGroup,
58+
EuiListGroupItem,
59+
EuiListGroupItemExtraAction,
60+
},
5761
demo: <ListGroup />,
5862
snippet: `<EuiListGroup flush={true} bordered={true}>
5963
<EuiListGroupItem onClick={handleOnClick} label="Item" />
@@ -103,7 +107,7 @@ export const ListGroupExample = {
103107
title: 'Secondary link actions',
104108
source: [
105109
{
106-
type: GuideSectionTypes.JS,
110+
type: GuideSectionTypes.TSX,
107111
code: listGroupLinkActionsSource,
108112
},
109113
],
@@ -129,6 +133,9 @@ export const ListGroupExample = {
129133
alwaysShow: pinned,
130134
}}
131135
/>`,
136+
props: {
137+
EuiListGroupItemExtraAction,
138+
},
132139
},
133140
{
134141
title: 'Text wrapping and tooltips',
@@ -172,13 +179,11 @@ export const ListGroupExample = {
172179
text: (
173180
<>
174181
<p>
175-
<strong>EuiListGroupItems</strong> will inherit the color from their
176-
element type whether it is a <EuiCode>button</EuiCode>,{' '}
177-
<EuiCode>anchor</EuiCode>, or <EuiCode>span</EuiCode>. You can
178-
enforce a different color of <EuiCode>primary</EuiCode>,{' '}
179-
<EuiCode>text</EuiCode>, or <EuiCode>subdued</EuiCode> with the{' '}
180-
<EuiCode>color</EuiCode> prop. Or provide the prop directly to{' '}
181-
<strong>EuiListGroup</strong>.
182+
<strong>EuiListGroupItems</strong> will get by default the color{' '}
183+
<EuiCode>text</EuiCode>. You can enforce a different color of{' '}
184+
<EuiCode>primary</EuiCode>, <EuiCode>text</EuiCode>, or{' '}
185+
<EuiCode>subdued</EuiCode> with the <EuiCode>color</EuiCode> prop.
186+
Or provide the prop directly to <strong>EuiListGroup</strong>.
182187
</p>
183188
<p>
184189
They also accept options for text size;{' '}

src-docs/src/views/list_group/list_group_item_color.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import React from 'react';
22

33
import {
4+
EuiSpacer,
5+
EuiPanel,
46
EuiListGroupItem,
57
EuiListGroup,
6-
} from '../../../../src/components/list_group';
7-
import { EuiSpacer } from '../../../../src/components/spacer';
8+
} from '../../../../src/components/';
9+
import { EuiThemeProvider } from '../../../../src/services';
810

911
export default () => (
1012
<>
1113
<EuiListGroup>
12-
<EuiListGroupItem href="#" label="Inherit by default (xs)" size="xs" />
14+
<EuiListGroupItem href="#" label="Text by default (xs)" size="xs" />
1315

1416
<EuiListGroupItem
1517
onClick={() => {}}
@@ -25,8 +27,12 @@ export default () => (
2527

2628
<EuiSpacer size="s" />
2729

28-
<EuiListGroup style={{ background: 'black' }}>
29-
<EuiListGroupItem href="#" label="Ghost" color="ghost" />
30-
</EuiListGroup>
30+
<EuiThemeProvider colorMode="dark">
31+
<EuiPanel borderRadius="none" hasShadow={false} color="subdued">
32+
<EuiListGroup>
33+
<EuiListGroupItem href="#" label="Ghost" />
34+
</EuiListGroup>
35+
</EuiPanel>
36+
</EuiThemeProvider>
3137
</>
3238
);

src-docs/src/views/list_group/list_group_link_actions.js renamed to src-docs/src/views/list_group/list_group_link_actions.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { EuiListGroup, EuiListGroupItem } from '../../../../src/components';
44
import { useGeneratedHtmlId } from '../../../../src/services';
55

66
export default () => {
7-
const [favorite1, setFavorite1] = useState(undefined);
8-
const [favorite2, setFavorite2] = useState('link2');
9-
const [favorite3, setFavorite3] = useState(undefined);
10-
const [favorite4, setFavorite4] = useState(undefined);
7+
const [favorite1, setFavorite1] = useState<string | undefined>(undefined);
8+
const [favorite2, setFavorite2] = useState<string | undefined>('link2');
9+
const [favorite3, setFavorite3] = useState<string | undefined>(undefined);
10+
const [favorite4, setFavorite4] = useState<string | undefined>(undefined);
1111

1212
const listGroupLinkId__1 = useGeneratedHtmlId({
1313
prefix: 'listGroupLink',
@@ -33,28 +33,28 @@ export default () => {
3333
const link1Clicked = () => {
3434
setFavorite1(favorite1 === 'link1' ? undefined : 'link1');
3535
if (favorite1 === undefined) {
36-
document.activeElement.blur();
36+
(document.activeElement as HTMLElement).blur();
3737
}
3838
};
3939

4040
const link2Clicked = () => {
4141
setFavorite2(favorite2 === 'link2' ? undefined : 'link2');
4242
if (favorite2 === undefined) {
43-
document.activeElement.blur();
43+
(document.activeElement as HTMLElement).blur();
4444
}
4545
};
4646

4747
const link3Clicked = () => {
4848
setFavorite3(favorite3 === 'link3' ? undefined : 'link3');
4949
if (favorite3 === undefined) {
50-
document.activeElement.blur();
50+
(document.activeElement as HTMLElement).blur();
5151
}
5252
};
5353

5454
const link4Clicked = () => {
5555
setFavorite4(favorite4 === 'link4' ? undefined : 'link4');
5656
if (favorite3 === undefined) {
57-
document.activeElement.blur();
57+
(document.activeElement as HTMLElement).blur();
5858
}
5959
};
6060

src-docs/src/views/list_group/list_group_links.js renamed to src-docs/src/views/list_group/list_group_links.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,31 @@ const myContent = [
77
label: 'First link',
88
href: '#/display/list-group',
99
iconType: 'calendar',
10-
size: 's',
1110
},
1211
{
1312
label: 'This is an active link with very long label that truncates',
1413
href: '#/display/list-group',
1514
isActive: true,
1615
iconType: 'clock',
17-
size: 's',
1816
},
1917
{
2018
label: 'Third link is disabled',
2119
href: '#/display/list-group',
2220
isDisabled: true,
2321
iconType: 'compute',
24-
size: 's',
2522
},
2623
{
2724
label: 'Fourth link',
2825
href: '#/display/list-group',
2926
iconType: 'copyClipboard',
30-
size: 's',
3127
},
3228
{
3329
label: 'Fifth link',
3430
href: '#/display/list-group',
3531
iconType: 'crosshairs',
36-
size: 's',
3732
},
3833
];
3934

4035
export default () => {
41-
return <EuiListGroup listItems={myContent} />;
36+
return <EuiListGroup listItems={myContent} color="primary" size="s" />;
4237
};

src-docs/src/views/list_group/pinnable_list_group.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const someListItems: EuiPinnableListGroupItemProps[] = [
99
{
1010
id: '1',
1111
label: 'Label with iconType',
12-
iconType: 'stop',
12+
iconType: 'home',
1313
pinned: false,
1414
},
1515
{
@@ -22,6 +22,7 @@ const someListItems: EuiPinnableListGroupItemProps[] = [
2222
label: 'Link with href and custom pin titles',
2323
href: '/#',
2424
pinned: false,
25+
color: 'primary',
2526
},
2627
{
2728
id: '3',
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import React, { FunctionComponent } from 'react';
22

3-
import { EuiPinnableListGroupItemProps } from '../../../../src/components/list_group';
3+
import {
4+
EuiPinnableListGroupItemProps,
5+
EuiListGroupItemExtraActionProps,
6+
} from '../../../../src/components/list_group';
47

58
export const EuiPinnableListGroupItem: FunctionComponent<EuiPinnableListGroupItemProps> = () => (
69
<div />
710
);
11+
12+
export const EuiListGroupItemExtraAction: FunctionComponent<EuiListGroupItemExtraActionProps> = () => (
13+
<div />
14+
);

0 commit comments

Comments
 (0)