-
Notifications
You must be signed in to change notification settings - Fork 887
Add Suggest Item #2090
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
Merged
Merged
Add Suggest Item #2090
Changes from 9 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
64b2e95
basic version works
andreadelrio 1e5d2c9
props descriptions
andreadelrio 6f9bad3
added expandLongLabel
andreadelrio fe5f173
removed some quotes
andreadelrio 3185d9b
added layout to replace expandLongLabel
andreadelrio e23f429
tests passing
thompsongl 147487e
Merge pull request #1 from thompsongl/suggest-item
andreadelrio 4a2860f
placed suggestItem import and export in correct order
andreadelrio 0ab76c6
some css fixes
andreadelrio 091a19f
considering vis colors
andreadelrio 3e87f51
changes based on feedback
andreadelrio 08197bd
updated colors and added minor css changes
andreadelrio eb8e5e8
basic version works
andreadelrio 7ccf026
props descriptions
andreadelrio c21843b
added expandLongLabel
andreadelrio b68f805
removed some quotes
andreadelrio b582011
tests passing
thompsongl 418cba6
added layout to replace expandLongLabel
andreadelrio ac69d10
Merge pull request #1 from thompsongl/suggest-item
andreadelrio 7a0555b
placed suggestItem import and export in correct order
andreadelrio d850644
some css fixes
andreadelrio c0b57c7
considering vis colors
andreadelrio e6cabe4
changes based on feedback
andreadelrio 93f1e9b
updated colors and added minor css changes
andreadelrio 56e3751
Merge branch 'master' into suggest-item
andreadelrio 0a6f7c9
Merge branch 'suggest-item' of https://github.com/andreadelrio/eui in…
andreadelrio 0a42759
docs updates and small improvements
andreadelrio a776760
Merge remote-tracking branch 'upstream/master' into suggest-item
andreadelrio 49234df
removed duplicate class
andreadelrio 354f747
Merge remote-tracking branch 'upstream/master' into suggest-item
andreadelrio 2daba39
Merge remote-tracking branch 'upstream/master' into suggest-item
andreadelrio dd6c8e7
added cl and commented out component from routes
andreadelrio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { EuiSuggestItem } from '../../../../src/components/suggest_item'; | ||
|
|
||
| const shortDescription = 'This is the description'; | ||
|
|
||
| const sampleItems = [ | ||
| { | ||
| type: { icon: 'kqlField', color: 'warning' }, | ||
| label: 'Field sample', | ||
| description: shortDescription, | ||
| }, | ||
| { | ||
| type: { icon: 'kqlValue', color: 'secondary' }, | ||
| label: 'Value sample', | ||
| description: shortDescription, | ||
| }, | ||
| { | ||
| type: { icon: 'kqlSelector', color: '#7800A6' }, | ||
| label: 'Conjunction sample', | ||
| description: shortDescription, | ||
| }, | ||
| { | ||
| type: { icon: 'kqlOperand', color: 'primary' }, | ||
| label: 'Operator sample', | ||
| description: shortDescription, | ||
| }, | ||
| { | ||
| type: { icon: 'search', color: 'dark' }, | ||
| label: 'Recent search sample', | ||
| }, | ||
| { | ||
| type: { icon: 'save', color: '#DD0A73' }, | ||
| label: 'Saved search', | ||
| }, | ||
| ]; | ||
|
|
||
| export default () => ( | ||
| <div> | ||
| {sampleItems.map(item => ( | ||
| <EuiSuggestItem | ||
| type={item.type} | ||
| label={item.label} | ||
| description={item.description} | ||
| /> | ||
| ))} | ||
| </div> | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { renderToHtml } from '../../services'; | ||
|
|
||
| import { GuideSectionTypes } from '../../components'; | ||
|
|
||
| import { EuiCode, EuiSuggestItem } from '../../../../src/components'; | ||
|
|
||
| import SuggestItem from './suggest_item'; | ||
| const suggestItemSource = require('!!raw-loader!./suggest_item'); | ||
| const suggestItemHtml = renderToHtml(SuggestItem); | ||
|
|
||
| import SuggestItemLongLabel from './suggest_item_long_label'; | ||
| const suggestItemLongLabelSource = require('!!raw-loader!./suggest_item_long_label'); | ||
| const suggestItemLongLabelHtml = renderToHtml(SuggestItemLongLabel); | ||
|
|
||
| export const SuggestItemExample = { | ||
| title: 'Suggest Item', | ||
| sections: [ | ||
| { | ||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.JS, | ||
| code: suggestItemSource, | ||
| }, | ||
| { | ||
| type: GuideSectionTypes.HTML, | ||
| code: suggestItemHtml, | ||
| }, | ||
| ], | ||
| text: ( | ||
| <div> | ||
| <p> | ||
| <EuiCode>EuiSuggestItem</EuiCode> is a list item component useful to | ||
| suggestions when typing queries in input fields. | ||
| </p> | ||
| <ul> | ||
|
cchaos marked this conversation as resolved.
Outdated
|
||
| <li> | ||
| <EuiCode>type</EuiCode> is an object that takes{' '} | ||
| <EuiCode>icon</EuiCode> and <EuiCode>color</EuiCode>.{' '} | ||
| <EuiCode>icon</EuiCode> supports any of the icons available in | ||
| <EuiCode>EuiIcon</EuiCode>. <EuiCode>color</EuiCode> is the color | ||
| for the icon and its background. The background color is | ||
| automatically calculated and it is a ligther shade of | ||
| <EuiCode>color</EuiCode>. | ||
| </li> | ||
| <li> | ||
| <EuiCode>label</EuiCode> is the primary text for the suggestion. | ||
| </li> | ||
| <li> | ||
| <EuiCode>description</EuiCode> is the secondary text for the | ||
| suggestion and it is optional. | ||
| </li> | ||
| <li> | ||
| Use <EuiCode>layout</EuiCode> to change the distribution of the{' '} | ||
| <EuiCode>EuiSuggestItem</EuiCode> elements. The default{' '} | ||
| <EuiCode>layout</EuiCode> is <EuiCode>setColumns</EuiCode>. | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| ), | ||
| props: { EuiSuggestItem }, | ||
| demo: <SuggestItem />, | ||
|
cchaos marked this conversation as resolved.
Outdated
|
||
| }, | ||
| { | ||
| title: 'Expand long label', | ||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.JS, | ||
| code: suggestItemLongLabelSource, | ||
| }, | ||
| { | ||
| type: GuideSectionTypes.HTML, | ||
| code: suggestItemLongLabelHtml, | ||
| }, | ||
| ], | ||
| text: ( | ||
| <p> | ||
| By default <EuiCode>EuiSuggestItem</EuiCode>'s{' '} | ||
| <EuiCode>label</EuiCode> will have a fixed width and use ellipsis | ||
| whenever its content is too long. It is possible to show the full text | ||
| by setting <EuiCode>layout</EuiCode> to <EuiCode>inline</EuiCode>. | ||
| </p> | ||
| ), | ||
| props: { EuiSuggestItem }, | ||
|
cchaos marked this conversation as resolved.
Outdated
|
||
| demo: <SuggestItemLongLabel />, | ||
| }, | ||
| ], | ||
| }; | ||
27 changes: 27 additions & 0 deletions
27
src-docs/src/views/suggest_item/suggest_item_long_label.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { EuiSuggestItem } from '../../../../src/components/suggest_item'; | ||
|
|
||
| const shortDescription = 'This is the description'; | ||
|
|
||
| const sampleItem = { | ||
| type: { icon: 'kqlValue', color: 'secondary' }, | ||
| label: 'Charles de Gaulle International Airport', | ||
| description: shortDescription, | ||
| }; | ||
|
|
||
| export default () => ( | ||
| <div> | ||
| <EuiSuggestItem | ||
| type={sampleItem.type} | ||
| label={sampleItem.label} | ||
| description={sampleItem.description} | ||
| /> | ||
| <EuiSuggestItem | ||
| type={sampleItem.type} | ||
| layout="inline" | ||
| label={sampleItem.label} | ||
| description={sampleItem.description} | ||
| /> | ||
| </div> | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/components/suggest_item/__snapshots__/suggest_item.test.js.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // 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--primary" | ||
| > | ||
| <svg | ||
| class="euiIcon euiIcon--medium euiIcon--primary 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__layout--set" | ||
| /> | ||
| <span | ||
| class="euiSuggestItem__description" | ||
| /> | ||
| </div> | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @import 'suggest_item'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| @import '../loading/mixins'; | ||
|
cchaos marked this conversation as resolved.
Outdated
|
||
|
|
||
| $buttonTypes: ( | ||
|
cchaos marked this conversation as resolved.
Outdated
|
||
| primary: $euiColorPrimary, | ||
| secondary: $euiColorSecondary, | ||
| warning: $euiColorWarning, | ||
| danger: $euiColorDanger, | ||
| dark: $euiColorMediumShade, | ||
| ); | ||
|
|
||
| .euiSuggestItem { | ||
| display: flex; | ||
| flex-grow: 1; | ||
| align-items: center; | ||
| font-size: $euiFontSizeXS; | ||
| white-space: nowrap; | ||
|
|
||
| @each $name, $color in $buttonTypes { | ||
| .euiSuggestItem__type--#{$name} { | ||
| background-color: tintOrShade($color, 90%, 50%); | ||
| } | ||
| } | ||
|
|
||
| .euiSuggestItem__label, | ||
| .euiSuggestItem__type, | ||
| .euiSuggestItem__description { | ||
| flex-grow: 1; | ||
| flex-basis: 0%; | ||
| display: flex; | ||
| flex-direction: column; | ||
| } | ||
|
|
||
| .euiSuggestItem__type { | ||
| position: relative; | ||
| flex-grow: 0; | ||
| flex-basis: auto; | ||
| width: $euiSizeXL; | ||
| height: $euiSizeXL; | ||
| text-align: center; | ||
| overflow: hidden; | ||
| padding: $euiSizeXS; | ||
| justify-content: center; | ||
| align-items: center; | ||
|
|
||
| .customBackground { | ||
|
cchaos marked this conversation as resolved.
Outdated
|
||
| width: 32px; | ||
|
cchaos marked this conversation as resolved.
Outdated
|
||
| height: 32px; | ||
| position: absolute; | ||
| opacity: .2; | ||
| top: 0; | ||
| left: 0; | ||
| } | ||
| } | ||
|
|
||
| .euiSuggestItem__label { | ||
| flex-grow: 0; | ||
| flex-basis: auto; | ||
| font-family: $euiCodeFontFamily; | ||
| width: 250px; | ||
|
cchaos marked this conversation as resolved.
Outdated
|
||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| padding: $euiSizeXS $euiSizeS; | ||
| color: $euiTextColor; | ||
|
|
||
| &.euiSuggestItem__layout--inline { | ||
| width: auto; | ||
| } | ||
| } | ||
|
|
||
| .euiSuggestItem__description, | ||
| .euiSuggestItem__label { | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| display: block; | ||
|
cchaos marked this conversation as resolved.
|
||
| } | ||
|
|
||
| .euiSuggestItem__description { | ||
| color: $euiColorDarkShade; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { EuiSuggestItem } from './suggest_item'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.