-
Notifications
You must be signed in to change notification settings - Fork 843
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* dont set title attr if tooltip will be shown * useInnerText and EuiInnerText * use useInnerText for EuiListGroupItem; alter truncation rendering * docs * docs for innerText * shared snippet * useInnerText filterButton * docs updates * data-text * more docs * fallbacks: value and textContent * bump enzyme; tests * use mutationObserver and useState; docs * observe after update * clean up observer * add act util to MutationObserver test polyfill; uncomment test * CL
- Loading branch information
1 parent
4b06a38
commit abf4d52
Showing
18 changed files
with
601 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,123 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
import { EuiInnerText } from '../../../../src/components/inner_text'; | ||
|
||
import { | ||
EuiBadge, | ||
EuiCode, | ||
EuiFlexGroup, | ||
EuiHighlight, | ||
EuiFlexItem, | ||
EuiHorizontalRule, | ||
EuiPanel, | ||
EuiText, | ||
} from '../../../../src/components'; | ||
|
||
export default () => { | ||
const first = 'First'; | ||
const second = 'Second'; | ||
const [thing, setThing] = useState(first); | ||
const [[thing2, type], setThingAndType] = useState([first, 'span']); | ||
useEffect(() => { | ||
setTimeout(() => { | ||
const newThing = thing === second ? first : second; | ||
const newType = type === 'div' ? 'span' : 'div'; | ||
setThing(newThing); | ||
setThingAndType([newThing, newType]); | ||
}, 5000); | ||
}, [thing]); | ||
|
||
return ( | ||
<EuiText size="s"> | ||
<h5>Example:</h5> | ||
<EuiInnerText> | ||
{(ref, innerText) => ( | ||
<React.Fragment> | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={false}> | ||
<EuiPanel paddingSize="s" grow={false}> | ||
<span ref={ref} title={innerText}> | ||
Simple string content | ||
</span> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<h5 className="eui-displayInlineBlock">Output:</h5>{' '} | ||
<EuiCode>{innerText}</EuiCode> | ||
</React.Fragment> | ||
)} | ||
</EuiInnerText> | ||
|
||
<EuiHorizontalRule margin="xl" /> | ||
|
||
<h5>Example with complex children:</h5> | ||
<EuiInnerText> | ||
{(ref, innerText) => ( | ||
<React.Fragment> | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={false}> | ||
<EuiPanel paddingSize="s" grow={false}> | ||
<span ref={ref} title={innerText}> | ||
<EuiHighlight search="content"> | ||
EuiHighlight content | ||
</EuiHighlight>{' '} | ||
<EuiBadge>with EuiBadge</EuiBadge> | ||
</span> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<h5 className="eui-displayInlineBlock">Output:</h5>{' '} | ||
<EuiCode>{innerText}</EuiCode> | ||
</React.Fragment> | ||
)} | ||
</EuiInnerText> | ||
|
||
<EuiHorizontalRule margin="xl" /> | ||
|
||
<h5>Example with updating content:</h5> | ||
<EuiInnerText> | ||
{(ref, innerText) => ( | ||
<React.Fragment> | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={false}> | ||
<EuiPanel paddingSize="s" grow={false}> | ||
<span ref={ref} title={innerText}> | ||
{thing} | ||
</span> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<h5 className="eui-displayInlineBlock">Output:</h5>{' '} | ||
<EuiCode>{innerText}</EuiCode> | ||
</React.Fragment> | ||
)} | ||
</EuiInnerText> | ||
|
||
<EuiHorizontalRule margin="xl" /> | ||
|
||
<h5>Example with updating element:</h5> | ||
<EuiInnerText> | ||
{(ref, innerText) => ( | ||
<React.Fragment> | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={false}> | ||
<EuiPanel paddingSize="s" grow={false}> | ||
{React.createElement( | ||
type, | ||
{ | ||
ref, | ||
title: innerText, | ||
}, | ||
thing2 | ||
)} | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<h5 className="eui-displayInlineBlock">Output:</h5>{' '} | ||
<EuiCode>{innerText}</EuiCode> | ||
</React.Fragment> | ||
)} | ||
</EuiInnerText> | ||
</EuiText> | ||
); | ||
}; |
This file contains 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,71 @@ | ||
import React from 'react'; | ||
|
||
import { renderToHtml } from '../../services'; | ||
|
||
import { GuideSectionTypes } from '../../components'; | ||
|
||
import { EuiCode, EuiSpacer, EuiText } from '../../../../src/components'; | ||
|
||
import InnerText from './inner_text'; | ||
const innerTextSource = require('!!raw-loader!./inner_text'); | ||
const innerTextHtml = renderToHtml(InnerText); | ||
const useInnerTextSnippet = `const [ref, innerText] = useInnerText(); | ||
<span ref={ref} title={innerText}> | ||
Content | ||
</span>`; | ||
const euiInnerTextSnippet = `<EuiInnerText> | ||
{(ref, innerText) => ( | ||
<span ref={ref} title={innerText}> | ||
Content | ||
</span> | ||
)} | ||
</EuiInnerText>`; | ||
|
||
export const InnerTextExample = { | ||
title: 'Inner Text', | ||
intro: ( | ||
<React.Fragment> | ||
<EuiText> | ||
<p> | ||
For instances where accessing the text content of a component that may | ||
be wrapped or interspersed with other components, two utilities are | ||
available: | ||
</p> | ||
<ul> | ||
<li> | ||
<EuiCode>useInnerText</EuiCode> - A custom React hook, usable in | ||
function components | ||
</li> | ||
<li> | ||
<EuiCode>EuiInnerText</EuiCode> - A higher order{' '} | ||
<EuiCode>useInnerText</EuiCode> component for use in class | ||
components | ||
</li> | ||
</ul> | ||
<p> | ||
Both utilities make available a <EuiCode>ref</EuiCode> reference to | ||
add to the target DOM element, and the resulting{' '} | ||
<EuiCode>innerText</EuiCode> value to use as needed. | ||
</p> | ||
</EuiText> | ||
<EuiSpacer /> | ||
</React.Fragment> | ||
), | ||
sections: [ | ||
{ | ||
title: 'Rendered', | ||
source: [ | ||
{ | ||
type: GuideSectionTypes.JS, | ||
code: innerTextSource, | ||
}, | ||
{ | ||
type: GuideSectionTypes.HTML, | ||
code: innerTextHtml, | ||
}, | ||
], | ||
demo: <InnerText />, | ||
snippet: [useInnerTextSnippet, euiInnerTextSnippet], | ||
}, | ||
], | ||
}; |
This file contains 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 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 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,25 @@ | ||
import React from 'react'; | ||
|
||
import { EuiListGroup, EuiListGroupItem } from '../../../../src/components'; | ||
|
||
export default () => ( | ||
<EuiListGroup showToolTips> | ||
<EuiListGroupItem label="First item" /> | ||
|
||
<EuiListGroupItem label="Second item" /> | ||
|
||
<EuiListGroupItem | ||
label={ | ||
<span> | ||
Third very, very long item that <strong>will surely</strong> force | ||
truncation | ||
</span> | ||
} | ||
/> | ||
|
||
<EuiListGroupItem | ||
wrapText | ||
label="Fourth very, very long item with wrapping enabled that will not force truncation" | ||
/> | ||
</EuiListGroup> | ||
); |
This file contains 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 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 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
Oops, something went wrong.