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

[Docs] Replace Static HTML Element IDs Generated IDs (Layout Section) #5220

Merged
merged 21 commits into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e07ed30
Revised element IDs within the Accordion section of src/docs to use I…
breehall Sep 15, 2021
d552d9e
Merge branch 'elastic:master' into breehall-htmlIdGenerator_docs
breehall Sep 15, 2021
647d8de
Merge branch 'master' of https://github.com/breehall/eui into breehal…
breehall Sep 15, 2021
df800ad
Revised element IDs within the Accordion section of src/docs to use I…
breehall Sep 16, 2021
f2cdc8e
Merge branch 'elastic:master' into breehall-htmlIdGenerator_docs
breehall Sep 16, 2021
553e630
Merge branch 'breehall-htmlIdGenerator_docs' of https://github.com/br…
breehall Sep 16, 2021
ee200d5
Revised element IDs within the Flyout section of src/docs to use IDs …
breehall Sep 16, 2021
ed9b467
Revised element IDs within the Header section of src/docs to use IDs …
breehall Sep 16, 2021
88b9f03
Revised element IDs within the Header section of src/docs to use IDs …
breehall Sep 16, 2021
2cf4626
Merge branch 'master' of https://github.com/breehall/eui into breehal…
breehall Sep 16, 2021
1f61f48
Revised element IDs within the Header section of src/docs to use IDs …
breehall Sep 16, 2021
67e6517
Revised element IDs within the Modal section of src/docs to use IDs g…
breehall Sep 16, 2021
8c13ff2
Merge branch 'master' of https://github.com/breehall/eui into breehal…
breehall Sep 20, 2021
fa2920f
Merge branch 'master' of https://github.com/breehall/eui into breehal…
breehall Sep 20, 2021
6915ebd
Test commit
breehall Sep 22, 2021
b80a14b
Revised element IDs within the Resizable Panel section of src/docs to…
breehall Sep 28, 2021
a8ab4c9
Merge branch 'master' of https://github.com/breehall/eui into breehal…
breehall Sep 28, 2021
f219516
Revised element IDs within the Resizable Panel section of src/docs to…
breehall Sep 28, 2021
4325089
Revisions from PR
breehall Sep 29, 2021
605247b
Update src-docs/src/views/resizable_container/resizable_container_res…
breehall Sep 29, 2021
6a33f13
Update accordion_example.js
breehall Oct 11, 2021
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
23 changes: 14 additions & 9 deletions src-docs/src/views/accordion/accordion.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import React from 'react';

import { EuiAccordion, EuiPanel } from '../../../../src/components';
import { useGeneratedHtmlId } from '../../../../src/services';

export default () => (
<div>
<EuiAccordion id="accordion1" buttonContent="Click me to toggle">
<EuiPanel color="subdued">
Any content inside of <strong>EuiAccordion</strong> will appear here.
</EuiPanel>
</EuiAccordion>
</div>
);
export default () => {
const simpleAccordionId = useGeneratedHtmlId({ prefix: 'simpleAccordion' });

return (
<div>
<EuiAccordion id={simpleAccordionId} buttonContent="Click me to toggle">
<EuiPanel color="subdued">
Any content inside of <strong>EuiAccordion</strong> will appear here.
</EuiPanel>
</EuiAccordion>
</div>
);
};
27 changes: 16 additions & 11 deletions src-docs/src/views/accordion/accordion_arrow.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import React from 'react';

import { EuiAccordion, EuiPanel } from '../../../../src/components';
import { useGeneratedHtmlId } from '../../../../src/services';

export default () => (
<EuiAccordion
id="accordion11"
arrowDisplay="none"
buttonContent="This one has it removed entirely"
>
<EuiPanel color="subdued">
Any content inside of <strong>EuiAccordion</strong> will appear here.
</EuiPanel>
</EuiAccordion>
);
export default () => {
const noArrowAccordionId = useGeneratedHtmlId({ prefix: 'noArrowAccordion' });

return (
<EuiAccordion
id={noArrowAccordionId}
arrowDisplay="none"
buttonContent="This one has it removed entirely"
>
<EuiPanel color="subdued">
Any content inside of <strong>EuiAccordion</strong> will appear here.
</EuiPanel>
</EuiAccordion>
);
};
29 changes: 18 additions & 11 deletions src-docs/src/views/accordion/accordion_arrow_right.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import React from 'react';

import { EuiAccordion, EuiPanel } from '../../../../src/components';
import { useGeneratedHtmlId } from '../../../../src/services';

export default () => (
<EuiAccordion
id="accordion10"
arrowDisplay="right"
buttonContent="This accordion has the arrow on the right"
>
<EuiPanel color="subdued">
Any content inside of <strong>EuiAccordion</strong> will appear here.
</EuiPanel>
</EuiAccordion>
);
export default () => {
const rightArrowAccordionId = useGeneratedHtmlId({
prefix: 'rightArrowAccordion',
});

return (
<EuiAccordion
id={rightArrowAccordionId}
arrowDisplay="right"
buttonContent="This accordion has the arrow on the right"
>
<EuiPanel color="subdued">
Any content inside of <strong>EuiAccordion</strong> will appear here.
</EuiPanel>
</EuiAccordion>
);
};
27 changes: 17 additions & 10 deletions src-docs/src/views/accordion/accordion_extra.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import React from 'react';

import { EuiAccordion, EuiButton } from '../../../../src/components';
import { useGeneratedHtmlId } from '../../../../src/services';

export default () => (
<EuiAccordion
id="accordionExtraWithLeftArrow"
buttonContent="Click to open"
extraAction={<EuiButton size="s">Extra action!</EuiButton>}
paddingSize="l"
>
<strong>Opened content.</strong>
</EuiAccordion>
);
export default () => {
const extraActionAccordionId = useGeneratedHtmlId({
prefix: 'extraActionAccordion',
});

return (
<EuiAccordion
id={extraActionAccordionId}
buttonContent="Click to open"
extraAction={<EuiButton size="s">Extra action!</EuiButton>}
paddingSize="l"
>
<strong>Opened content.</strong>
</EuiAccordion>
);
};
7 changes: 5 additions & 2 deletions src-docs/src/views/accordion/accordion_forceState.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import {
EuiButtonGroup,
EuiSpacer,
} from '../../../../src/components';
import { htmlIdGenerator } from '../../../../src/services';
import { htmlIdGenerator, useGeneratedHtmlId } from '../../../../src/services';

const idPrefix = htmlIdGenerator()();

export default () => {
const forcedStateAccordionId = useGeneratedHtmlId({
prefix: 'forcedStateAccordion',
});
const [trigger, setTrigger] = useState('closed');
const [toggleIdSelected, setID] = useState(`${idPrefix}--closed`);
const toggleButtons = [
Expand Down Expand Up @@ -45,7 +48,7 @@ export default () => {
/>
<EuiSpacer />
<EuiAccordion
id={htmlIdGenerator()()}
id={forcedStateAccordionId}
forceState={trigger}
onToggle={onToggle}
buttonContent="I am a controlled accordion"
Expand Down
60 changes: 36 additions & 24 deletions src-docs/src/views/accordion/accordion_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
EuiTitle,
EuiButtonIcon,
} from '../../../../src/components';
import { useGeneratedHtmlId } from '../../../../src/services';

const repeatableForm = (
<EuiForm component="form">
Expand Down Expand Up @@ -77,28 +78,39 @@ const extraAction = (
/>
);

export default () => (
<div>
<EuiAccordion
id="accordionForm1"
className="euiAccordionForm"
buttonClassName="euiAccordionForm__button"
buttonContent={buttonContent}
extraAction={extraAction}
paddingSize="l"
>
{repeatableForm}
</EuiAccordion>
export default () => {
const formAccordionId__1 = useGeneratedHtmlId({
prefix: 'formAccordion',
suffix: 'first',
});
const formAccordionId__2 = useGeneratedHtmlId({
prefix: 'formAccordion',
suffix: 'second',
});

<EuiAccordion
id="accordionForm2"
className="euiAccordionForm"
buttonClassName="euiAccordionForm__button"
buttonContent={buttonContent}
extraAction={extraAction}
paddingSize="l"
>
{repeatableForm}
</EuiAccordion>
</div>
);
return (
<div>
<EuiAccordion
id={formAccordionId__1}
className="euiAccordionForm"
buttonClassName="euiAccordionForm__button"
buttonContent={buttonContent}
extraAction={extraAction}
paddingSize="l"
>
{repeatableForm}
</EuiAccordion>

<EuiAccordion
id={formAccordionId__2}
className="euiAccordionForm"
buttonClassName="euiAccordionForm__button"
buttonContent={buttonContent}
extraAction={extraAction}
paddingSize="l"
>
{repeatableForm}
</EuiAccordion>
</div>
);
};
36 changes: 21 additions & 15 deletions src-docs/src/views/accordion/accordion_grow.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ import {
EuiScreenReaderOnly,
} from '../../../../src/components';
import { EuiPanel } from '../../../../src/components/panel';
import { htmlIdGenerator } from '../../../../src/services';
import { useGeneratedHtmlId } from '../../../../src/services';

const Rows = () => {
const [counter, setCounter] = useState(1);
const rows = [];
for (let i = 1; i <= counter; i++) {
rows.push(<li key={i}>Row {i}</li>);
}
const growingAccordianDescriptionId = htmlIdGenerator()();
const listId = htmlIdGenerator()();
const growingAccordianDescriptionId = useGeneratedHtmlId({
prefix: 'growingAccordianDescription',
});
const listId = useGeneratedHtmlId({ prefix: 'list' });
return (
<EuiText size="s">
<EuiScreenReaderOnly>
Expand Down Expand Up @@ -52,15 +54,19 @@ const Rows = () => {
);
};

export default () => (
<EuiAccordion
id={htmlIdGenerator()()}
buttonContent="Click me to toggle close / open"
initialIsOpen={true}
paddingSize="s"
>
<EuiPanel color="subdued">
<Rows />
</EuiPanel>
</EuiAccordion>
);
export default () => {
const dynamicAccordionId = useGeneratedHtmlId({ prefix: 'dynamicAccordion' });

return (
<EuiAccordion
id={dynamicAccordionId}
buttonContent="Click me to toggle close / open"
initialIsOpen={true}
paddingSize="s"
>
<EuiPanel color="subdued">
<Rows />
</EuiPanel>
</EuiAccordion>
);
};
7 changes: 5 additions & 2 deletions src-docs/src/views/accordion/accordion_isLoading.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '../../../../src/components';
import { EuiFormRow } from '../../../../src/components/form';

import { htmlIdGenerator } from '../../../../src/services';
import { htmlIdGenerator, useGeneratedHtmlId } from '../../../../src/services';

const idPrefix = htmlIdGenerator()();

Expand All @@ -31,6 +31,9 @@ const toggleButtons = [
export default () => {
const [label, setLabel] = useState('False');
const [toggleIdSelected, setToggleIdSelected] = useState(`${idPrefix}0`);
const isLoadingAccordionId = useGeneratedHtmlId({
prefix: 'isLoadingAccordion',
});

const onChange = (optionId) => {
setToggleIdSelected(optionId);
Expand Down Expand Up @@ -64,7 +67,7 @@ export default () => {
</EuiFormRow>
<EuiSpacer size="m" />
<EuiAccordion
id={htmlIdGenerator()()}
id={isLoadingAccordionId}
initialIsOpen={true}
paddingSize={isLoadingMessage ? 'm' : 'none'}
buttonContent="Accordion is loading, click to toggle"
Expand Down
Loading