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

Add Suggest Item #2090

Merged
merged 32 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
64b2e95
basic version works
andreadelrio Jun 21, 2019
1e5d2c9
props descriptions
andreadelrio Jun 24, 2019
6f9bad3
added expandLongLabel
andreadelrio Jun 27, 2019
fe5f173
removed some quotes
andreadelrio Jul 2, 2019
3185d9b
added layout to replace expandLongLabel
andreadelrio Jul 2, 2019
e23f429
tests passing
thompsongl Jul 3, 2019
147487e
Merge pull request #1 from thompsongl/suggest-item
andreadelrio Jul 3, 2019
4a2860f
placed suggestItem import and export in correct order
andreadelrio Jul 3, 2019
0ab76c6
some css fixes
andreadelrio Jul 3, 2019
091a19f
considering vis colors
andreadelrio Jul 9, 2019
3e87f51
changes based on feedback
andreadelrio Jul 11, 2019
08197bd
updated colors and added minor css changes
andreadelrio Jul 13, 2019
eb8e5e8
basic version works
andreadelrio Jun 21, 2019
7ccf026
props descriptions
andreadelrio Jun 24, 2019
c21843b
added expandLongLabel
andreadelrio Jun 27, 2019
b68f805
removed some quotes
andreadelrio Jul 2, 2019
b582011
tests passing
thompsongl Jul 3, 2019
418cba6
added layout to replace expandLongLabel
andreadelrio Jul 2, 2019
ac69d10
Merge pull request #1 from thompsongl/suggest-item
andreadelrio Jul 3, 2019
7a0555b
placed suggestItem import and export in correct order
andreadelrio Jul 3, 2019
d850644
some css fixes
andreadelrio Jul 3, 2019
c0b57c7
considering vis colors
andreadelrio Jul 9, 2019
e6cabe4
changes based on feedback
andreadelrio Jul 11, 2019
93f1e9b
updated colors and added minor css changes
andreadelrio Jul 13, 2019
56e3751
Merge branch 'master' into suggest-item
andreadelrio Jul 15, 2019
0a6f7c9
Merge branch 'suggest-item' of https://github.com/andreadelrio/eui in…
andreadelrio Jul 15, 2019
0a42759
docs updates and small improvements
andreadelrio Jul 18, 2019
a776760
Merge remote-tracking branch 'upstream/master' into suggest-item
andreadelrio Jul 18, 2019
49234df
removed duplicate class
andreadelrio Jul 18, 2019
354f747
Merge remote-tracking branch 'upstream/master' into suggest-item
andreadelrio Jul 18, 2019
2daba39
Merge remote-tracking branch 'upstream/master' into suggest-item
andreadelrio Jul 19, 2019
dd6c8e7
added cl and commented out component from routes
andreadelrio Jul 19, 2019
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
3 changes: 3 additions & 0 deletions src-docs/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ import { StatExample } from './views/stat/stat_example';

import { StepsExample } from './views/steps/steps_example';

import { SuggestExample } from './views/suggest/suggest_example';

import { TableExample } from './views/tables/tables_example';

import { TabsExample } from './views/tabs/tabs_example';
Expand Down Expand Up @@ -349,6 +351,7 @@ const navigation = [
RangeControlExample,
SearchBarExample,
SelectableExample,
SuggestExample,
].map(example => createExample(example)),
},
{
Expand Down
3 changes: 3 additions & 0 deletions src-docs/src/views/suggest/suggest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import React from 'react';

export default () => <div />;
81 changes: 81 additions & 0 deletions src-docs/src/views/suggest/suggest_example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import React from 'react';

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

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

import { EuiCode, EuiSuggestItem } from '../../../../src/components';

import Suggest from './suggest';
const suggestSource = require('!!raw-loader!./suggest');
const suggestHtml = renderToHtml(Suggest);

import SuggestItem from './suggest_item';
const suggestItemSource = require('!!raw-loader!./suggest_item');
const suggestItemHtml = renderToHtml(SuggestItem);
const suggestItemSnippet = [
`<EuiSuggestItem
type={sampleItem.type}
label={sampleItem.label}
description={sampleItem.description}
/>
`,
`<EuiSuggestItem
type={sampleItem.type}
label={sampleItem.label}
description={sampleItem.description}
labelDisplay="expand"
/>`,
];

export const SuggestExample = {
title: 'Suggest',
sections: [
{
source: [
{
type: GuideSectionTypes.JS,
code: suggestSource,
},
{
type: GuideSectionTypes.HTML,
code: suggestHtml,
},
],
text: (
<div>
<p>
<EuiCode>EuiSuggest</EuiCode> description goes here.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is merging into master, can we comment out this first section or update it with a coming soon message?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea is just to comment it out from the routes file for now instead.

</p>
</div>
),
},
{
title: 'Suggest Item',
source: [
{
type: GuideSectionTypes.JS,
code: suggestItemSource,
},
{
type: GuideSectionTypes.HTML,
code: suggestItemHtml,
},
],
text: (
<div>
<p>
<EuiCode>EuiSuggestItem</EuiCode> is a list item component to
display suggestions when typing queries in{' '}
<EuiCode>EuiSuggestInput</EuiCode>. Use{' '}
<EuiCode>labelDisplay</EuiCode> to set whether the{' '}
<EuiCode>label</EuiCode> has a fixed width or not.
</p>
</div>
),
props: { EuiSuggestItem },
snippet: suggestItemSnippet,
demo: <SuggestItem />,
},
],
};
71 changes: 71 additions & 0 deletions src-docs/src/views/suggest/suggest_item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React from 'react';

import { EuiSuggestItem, EuiSpacer } from '../../../../src/components';

const shortDescription = 'This is the description';

const sampleItems = [
{
type: { iconType: 'kqlField', color: 'tint4' },
label: 'Field sample',
description: shortDescription,
},
{
type: { iconType: 'kqlValue', color: 'tint0' },
label: 'Value sample',
description: shortDescription,
},
{
type: { iconType: 'kqlSelector', color: 'tint3' },
label: 'Conjunction sample',
description: shortDescription,
},
{
type: { iconType: 'kqlOperand', color: 'tint1' },
label: 'Operator sample',
description: shortDescription,
},
{
type: { iconType: 'search', color: 'tint8' },
cchaos marked this conversation as resolved.
Show resolved Hide resolved
label: 'Recent search',
},
{
type: { iconType: 'save', color: 'tint5' },
label: 'Saved query',
},
];

const typeObj = { iconType: 'kqlValue', color: 'tint0' };

const longLabel =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ut quam eget augue pulvinar.';

export default () => (
<div>
{sampleItems.map((item, index) => (
<EuiSuggestItem
type={item.type}
key={index}
label={item.label}
description={item.description}
/>
))}
<EuiSpacer size="m" />
<EuiSuggestItem
type={typeObj}
label={longLabel}
description="This item has a fixed width label"
/>
<EuiSuggestItem
type={typeObj}
labelDisplay="expand"
label={longLabel}
description="This item will expand its label if needed"
/>
<EuiSpacer size="m" />
<EuiSuggestItem
type={{ iconType: 'search', color: 'tint8' }}
label="Items with no description will expand their label"
/>
</div>
);
2 changes: 2 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ export { EuiStat } from './stat';

export { EuiStep, EuiSteps, EuiSubSteps, EuiStepsHorizontal } from './steps';

export { EuiSuggestItem } from './suggest_item';

export {
EuiTable,
EuiTableBody,
Expand Down
1 change: 1 addition & 0 deletions src/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
@import 'selectable/index';
@import 'stat/index';
@import 'steps/index';
@import 'suggest_item/index';
@import 'table/index';
@import 'tabs/index';
@import 'title/index';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiSuggestItem is rendered 1`] = `
<div
aria-label="aria-label"
class="euiSuggestItem testClass1 testClass2"
data-test-subj="test subject string"
>
<span
class="euiSuggestItem__type euiSuggestItem__type--tint1"
>
<svg
class="euiIcon euiIcon--medium euiIcon-isLoading"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/>
</span>
<span
class="euiSuggestItem__label euiSuggestItem__label euiSuggestItem__labelDisplay--fixed euiSuggestItem__labelDisplay--expand"
>
Test label
</span>
<span
class="euiSuggestItem__description"
/>
</div>
`;

exports[`props item with no description has expanded label is rendered 1`] = `
<div
class="euiSuggestItem"
>
<span
class="euiSuggestItem__type euiSuggestItem__type--tint2"
>
<svg
class="euiIcon euiIcon--medium euiIcon-isLoading"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/>
</span>
<span
class="euiSuggestItem__label euiSuggestItem__label euiSuggestItem__labelDisplay--fixed euiSuggestItem__labelDisplay--expand"
>
This is the description
</span>
<span
class="euiSuggestItem__description"
/>
</div>
`;

exports[`props labelDisplay as expand is rendered 1`] = `
<div
class="euiSuggestItem"
>
<span
class="euiSuggestItem__type euiSuggestItem__type--tint2"
>
<svg
class="euiIcon euiIcon--medium euiIcon-isLoading"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/>
</span>
<span
class="euiSuggestItem__label euiSuggestItem__label euiSuggestItem__labelDisplay--expand"
>
This is the description
</span>
<span
class="euiSuggestItem__description"
>
This is the description
</span>
</div>
`;
3 changes: 3 additions & 0 deletions src/components/suggest_item/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import 'variables';

@import 'suggest_item';
68 changes: 68 additions & 0 deletions src/components/suggest_item/_suggest_item.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
.euiSuggestItem {
display: flex;
flex-grow: 1;
align-items: center;
font-size: $euiFontSizeXS;
white-space: nowrap;

@each $name, $color in $itemColors {
.euiSuggestItem__type--#{$name} {
$backgroundColor: tintOrShade($color, 90%, 50%);
background-color: $backgroundColor;
color: makeHighContrastColor($color, $backgroundColor);
}
}

.euiSuggestItem__label,
.euiSuggestItem__type,
.euiSuggestItem__description {
flex-grow: 0;
display: flex;
flex-direction: column;
}

.euiSuggestItem__type {
position: relative;
flex-shrink: 0;
flex-basis: auto;
width: $euiSizeXL;
height: $euiSizeXL;
text-align: center;
overflow: hidden;
padding: $euiSizeXS;
justify-content: center;
align-items: center;
}

.euiSuggestItem__label {
flex-basis: 50%;
min-width: 50%;
font-family: $euiCodeFontFamily;
overflow: hidden;
text-overflow: ellipsis;
padding: $euiSizeXS $euiSizeS;
color: $euiTextColor;

&.euiSuggestItem__labelDisplay--expand {
flex-basis: auto;
flex-shrink: 1;
}
}

.euiSuggestItem__description,
.euiSuggestItem__label {
@include euiTextTruncate;
display: block;
cchaos marked this conversation as resolved.
Show resolved Hide resolved
}

.euiSuggestItem__description {
color: $euiColorDarkShade;
flex-basis: auto;
padding-top: $euiSizeXS * .5;

&:empty {
flex-grow: 0;
margin-left: 0;
}
}
}
11 changes: 11 additions & 0 deletions src/components/suggest_item/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$itemColors: (
tint0: $euiColorVis0,
tint1: $euiColorVis1,
tint2: $euiColorVis2,
tint3: $euiColorVis3,
tint4: $euiColorVis5,
tint5: $euiColorVis7,
tint6: $euiColorVis8,
tint7: $euiColorVis9,
tint8: $euiColorDarkShade,
);
1 change: 1 addition & 0 deletions src/components/suggest_item/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { EuiSuggestItem } from './suggest_item';
Loading