-
Notifications
You must be signed in to change notification settings - Fork 887
Added documentation for htmlIdGenerator #3076
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
Changes from 3 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
6e250ab
added documentation for htmlIdGenerator
anishagg17 e3dafb2
use lables and formRow
anishagg17 5235577
only one exapmle per section
anishagg17 5320d37
Update src-docs/src/views/html_id_generator/html_id_generator_example.js
anishagg17 b57fbea
Update src-docs/src/views/html_id_generator/bothPrefixSuffix.js
anishagg17 3a73690
Update src-docs/src/views/html_id_generator/html_id_generator_example.js
anishagg17 d370ccb
Update src-docs/src/views/html_id_generator/html_id_generator_example.js
anishagg17 78ac3cb
Update src-docs/src/views/html_id_generator/html_id_generator_example.js
anishagg17 49d23f2
Update src-docs/src/views/html_id_generator/html_id_generator_example.js
anishagg17 d3bbc57
Update src-docs/src/views/html_id_generator/html_id_generator_example.js
anishagg17 bdb0935
Update src-docs/src/views/html_id_generator/html_id_generator_example.js
anishagg17 34633f1
Update src-docs/src/views/html_id_generator/htmlIdGeneratorPrefix.js
anishagg17 e196fec
Update src-docs/src/views/html_id_generator/htmlIdGeneratorSuffix.js
anishagg17 259d564
added snippets
anishagg17 ace212e
improved description
anishagg17 ba7472a
updated description
anishagg17 a1a90ea
Update src-docs/src/views/html_id_generator/html_id_generator_example.js
anishagg17 40b74c0
Update src-docs/src/views/html_id_generator/html_id_generator_example.js
anishagg17 f983ea1
Update src-docs/src/views/html_id_generator/html_id_generator_example.js
anishagg17 84dda40
updated ID generattor
anishagg17 ae5fbe5
added _ to prefix
anishagg17 a86ca30
updated generator
anishagg17 77cec44
Update src-docs/src/views/html_id_generator/html_id_generator_example.js
cchaos 831a8ca
added change Log
anishagg17 ec6f469
Merge branch 'master' into util
anishagg17 271111b
Merge branch 'master' into util
anishagg17 ff2451f
Merge branch 'master' into util
anishagg17 eee7099
Merge branch 'master' into util
anishagg17 138862f
Merge branch 'master' into util
cchaos 4051cac
Merge branch 'master' into util
cchaos 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,77 @@ | ||
| import React, { Component, Fragment } from 'react'; | ||
|
|
||
| import { | ||
| EuiFieldText, | ||
| EuiFlexGroup, | ||
| EuiFlexItem, | ||
| EuiSpacer, | ||
| EuiCode, | ||
| EuiFormRow, | ||
| } from '../../../../src/components'; | ||
| import { htmlIdGenerator } from '../../../../src/services'; | ||
|
|
||
| export class PrefixSufix extends Component { | ||
| constructor(props) { | ||
| super(props); | ||
|
|
||
| this.state = { | ||
| prefix: 'Some', | ||
| suffix: 'Id', | ||
| id1: htmlIdGenerator('Some')('Id'), | ||
| }; | ||
| } | ||
|
|
||
| onPrefixChange = e => { | ||
| const prefix = e.target.value; | ||
| const { suffix } = this.state; | ||
|
|
||
| this.setState({ | ||
| prefix, | ||
| id1: htmlIdGenerator(prefix)(suffix), | ||
| }); | ||
| }; | ||
|
|
||
| onSuffixChange = e => { | ||
| const suffix = e.target.value; | ||
| const { prefix } = this.state; | ||
|
|
||
| this.setState({ | ||
| suffix, | ||
| id1: htmlIdGenerator(prefix)(suffix), | ||
| }); | ||
| }; | ||
|
|
||
| render() { | ||
| const { prefix, suffix, id1 } = this.state; | ||
| return ( | ||
| <Fragment> | ||
| <EuiFlexGroup | ||
| justifyContent="flexStart" | ||
| gutterSize="m" | ||
| alignItems="center"> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiFormRow label="Prefix"> | ||
| <EuiFieldText | ||
| value={prefix} | ||
| onChange={this.onPrefixChange} | ||
| placeholder="Enter prefix" | ||
| /> | ||
| </EuiFormRow> | ||
| </EuiFlexItem> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiFormRow label="Suffix"> | ||
| <EuiFieldText | ||
| value={suffix} | ||
| onChange={this.onSuffixChange} | ||
| placeholder="Enter suffix" | ||
| /> | ||
| </EuiFormRow> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| <EuiSpacer size="m" /> | ||
| <EuiSpacer size="m" /> | ||
| <EuiCode>{id1} </EuiCode> | ||
| </Fragment> | ||
| ); | ||
| } | ||
| } | ||
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,43 @@ | ||
| import React, { Component, Fragment } from 'react'; | ||
|
|
||
| import { | ||
| EuiFlexGroup, | ||
| EuiFlexItem, | ||
| EuiButton, | ||
| EuiCode, | ||
| } from '../../../../src/components'; | ||
|
|
||
| import { htmlIdGenerator } from '../../../../src/services'; | ||
|
|
||
| export default class extends Component { | ||
| constructor(props) { | ||
| super(props); | ||
|
|
||
| this.state = { | ||
| value: htmlIdGenerator()(), | ||
| }; | ||
| } | ||
|
|
||
| reGenerate = () => { | ||
| this.setState({ value: htmlIdGenerator()() }); | ||
| }; | ||
|
|
||
| render() { | ||
| const { value } = this.state; | ||
| return ( | ||
| <Fragment> | ||
| <EuiFlexGroup | ||
| justifyContent="flexStart" | ||
| gutterSize="m" | ||
| alignItems="center"> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiCode>{value}</EuiCode> | ||
| </EuiFlexItem> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiButton onClick={this.reGenerate}>Regenerate</EuiButton> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| </Fragment> | ||
| ); | ||
| } | ||
| } |
55 changes: 55 additions & 0 deletions
55
src-docs/src/views/html_id_generator/htmlIdGeneratorPrefix.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,55 @@ | ||
| import React, { Component, Fragment } from 'react'; | ||
|
|
||
| import { | ||
| EuiFieldText, | ||
| EuiFlexGroup, | ||
| EuiFlexItem, | ||
| EuiSpacer, | ||
| EuiCode, | ||
| EuiFormRow, | ||
| } from '../../../../src/components'; | ||
| import { htmlIdGenerator } from '../../../../src/services'; | ||
|
|
||
| export class HtmlIdGeneratorPrefix extends Component { | ||
| constructor(props) { | ||
| super(props); | ||
|
|
||
| this.state = { | ||
| prefix: 'Id', | ||
| id1: htmlIdGenerator('Id')(), | ||
| }; | ||
| } | ||
|
|
||
| onSearchChange = e => { | ||
| const prefix = e.target.value; | ||
| this.setState({ | ||
| prefix, | ||
| id1: htmlIdGenerator(prefix)(), | ||
| }); | ||
| }; | ||
|
|
||
| render() { | ||
| const { prefix, id1 } = this.state; | ||
| return ( | ||
| <Fragment> | ||
| <EuiFlexGroup | ||
| justifyContent="flexStart" | ||
| gutterSize="m" | ||
| alignItems="center"> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiFormRow label="Prefix"> | ||
| <EuiFieldText | ||
| value={prefix} | ||
| onChange={this.onSearchChange} | ||
| placeholder="Enter prefix" | ||
| /> | ||
| </EuiFormRow> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| <EuiSpacer size="m" /> | ||
| <EuiSpacer size="m" /> | ||
|
anishagg17 marked this conversation as resolved.
Outdated
|
||
| <EuiCode>{id1} </EuiCode> | ||
| </Fragment> | ||
| ); | ||
| } | ||
| } | ||
55 changes: 55 additions & 0 deletions
55
src-docs/src/views/html_id_generator/htmlIdGeneratorSuffix.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,55 @@ | ||
| import React, { Component, Fragment } from 'react'; | ||
|
|
||
| import { | ||
| EuiFieldText, | ||
| EuiFlexGroup, | ||
| EuiFlexItem, | ||
| EuiSpacer, | ||
| EuiCode, | ||
| EuiFormRow, | ||
| } from '../../../../src/components'; | ||
| import { htmlIdGenerator } from '../../../../src/services'; | ||
|
|
||
| export class HtmlIdGeneratorSuffix extends Component { | ||
| constructor(props) { | ||
| super(props); | ||
|
|
||
| this.state = { | ||
| suffix: 'Id', | ||
| id1: htmlIdGenerator()('Id'), | ||
| }; | ||
| } | ||
|
|
||
| onSuffixChange = e => { | ||
| const suffix = e.target.value; | ||
| this.setState({ | ||
| suffix, | ||
| id1: htmlIdGenerator()(suffix), | ||
| }); | ||
| }; | ||
|
|
||
| render() { | ||
| const { suffix, id1 } = this.state; | ||
| return ( | ||
| <Fragment> | ||
| <EuiFlexGroup | ||
| justifyContent="flexStart" | ||
| gutterSize="m" | ||
| alignItems="center"> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiFormRow label="Suffix"> | ||
| <EuiFieldText | ||
| value={suffix} | ||
| onChange={this.onSuffixChange} | ||
| placeholder="Enter suffix" | ||
| /> | ||
| </EuiFormRow> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| <EuiSpacer size="m" /> | ||
| <EuiSpacer size="m" /> | ||
|
anishagg17 marked this conversation as resolved.
Outdated
|
||
| <EuiCode>{id1} </EuiCode> | ||
| </Fragment> | ||
| ); | ||
| } | ||
| } | ||
109 changes: 109 additions & 0 deletions
109
src-docs/src/views/html_id_generator/html_id_generator_example.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,109 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { renderToHtml } from '../../services'; | ||
|
|
||
| import { GuideSectionTypes } from '../../components'; | ||
| import { EuiCode } from '../../../../src/components'; | ||
|
|
||
| import IdGenerator from './htmlIdGenerator'; | ||
| import { HtmlIdGeneratorPrefix } from './htmlIdGeneratorPrefix'; | ||
| import { HtmlIdGeneratorSuffix } from './htmlIdGeneratorSuffix'; | ||
| import { PrefixSufix } from './bothPrefixSuffix'; | ||
|
|
||
| const htmlIdGeneratorSource = require('!!raw-loader!./htmlIdGenerator'); | ||
| const htmlIdGeneratorHtml = renderToHtml(IdGenerator); | ||
|
|
||
| const htmlIdGeneratorPrefixSource = require('!!raw-loader!./htmlIdGeneratorPrefix'); | ||
| const htmlIdGeneratorPrefixHtml = renderToHtml(HtmlIdGeneratorPrefix); | ||
|
|
||
| const HtmlIdGeneratorSuffixSource = require('!!raw-loader!./htmlIdGeneratorSuffix'); | ||
| const HtmlIdGeneratorSuffixHtml = renderToHtml(HtmlIdGeneratorSuffix); | ||
|
|
||
| const PrefixSufixSource = require('!!raw-loader!./bothPrefixSuffix'); | ||
| const PrefixSufixHtml = renderToHtml(PrefixSufix); | ||
|
|
||
| export const HtmlIdGeneratorExample = { | ||
|
anishagg17 marked this conversation as resolved.
|
||
| title: 'Html Id Generator', | ||
| sections: [ | ||
| { | ||
| title: 'Id Generator', | ||
|
anishagg17 marked this conversation as resolved.
Outdated
|
||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.JS, | ||
| code: htmlIdGeneratorSource, | ||
| }, | ||
| { | ||
| type: GuideSectionTypes.HTML, | ||
| code: htmlIdGeneratorHtml, | ||
| }, | ||
| ], | ||
| text: ( | ||
| <p> | ||
| Use <EuiCode>HtmlIdGenerator</EuiCode> to generate unique ID and avoid | ||
| accessibility issues. | ||
| </p> | ||
|
anishagg17 marked this conversation as resolved.
anishagg17 marked this conversation as resolved.
|
||
| ), | ||
| demo: <IdGenerator />, | ||
| }, | ||
| { | ||
| title: 'Id Generator with prefix', | ||
|
anishagg17 marked this conversation as resolved.
Outdated
|
||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.JS, | ||
| code: htmlIdGeneratorPrefixSource, | ||
| }, | ||
| { | ||
| type: GuideSectionTypes.HTML, | ||
| code: htmlIdGeneratorPrefixHtml, | ||
| }, | ||
| ], | ||
| text: ( | ||
| <p> | ||
| Provide <EuiCode>prefix</EuiCode> to generator to get ID with a | ||
| specific prefix. | ||
|
anishagg17 marked this conversation as resolved.
Outdated
|
||
| </p> | ||
| ), | ||
| demo: <HtmlIdGeneratorPrefix />, | ||
| }, | ||
| { | ||
| title: 'Id Generator with suffix', | ||
|
anishagg17 marked this conversation as resolved.
Outdated
|
||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.JS, | ||
| code: HtmlIdGeneratorSuffixSource, | ||
| }, | ||
| { | ||
| type: GuideSectionTypes.HTML, | ||
| code: HtmlIdGeneratorSuffixHtml, | ||
| }, | ||
| ], | ||
| text: ( | ||
| <p> | ||
| Provide <EuiCode>suffix</EuiCode> to generator to get ID with a | ||
| specific suffix. | ||
|
anishagg17 marked this conversation as resolved.
Outdated
|
||
| </p> | ||
| ), | ||
| demo: <HtmlIdGeneratorSuffix />, | ||
| }, | ||
| { | ||
| title: 'Id Generator with both prefix and sufix', | ||
|
anishagg17 marked this conversation as resolved.
Outdated
|
||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.JS, | ||
| code: PrefixSufixSource, | ||
| }, | ||
| { | ||
| type: GuideSectionTypes.HTML, | ||
| code: PrefixSufixHtml, | ||
| }, | ||
| ], | ||
| text: ( | ||
| <p> | ||
| HtmlIdGenerator is caplable of generating ID with specific prefix and | ||
| suffix. | ||
|
anishagg17 marked this conversation as resolved.
Outdated
|
||
| </p> | ||
| ), | ||
| demo: <PrefixSufix />, | ||
| }, | ||
| ], | ||
| }; | ||
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.