Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

[terra-show-hide] prop to focus on the element added #3838

Merged
merged 107 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from 96 commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
3696633
[terra-show-hide] Shift keyboard focus to newly revealed content with…
adoroshk Jun 30, 2023
94d6602
prop to focus on the element added
adoroshk Jul 7, 2023
8a20716
changelogs updated
adoroshk Jul 7, 2023
b18c84a
terra-core-docs changelog fix
adoroshk Jul 7, 2023
89be1c4
dox changelog removed
adoroshk Jul 7, 2023
5f0bf23
text edits, comments added
adoroshk Jul 7, 2023
b1cb04c
text edits
adoroshk Jul 7, 2023
c3ece59
text edits
adoroshk Jul 7, 2023
9a5deff
extra line removed
adoroshk Jul 7, 2023
072099c
changelog in terra-core-docs updated
adoroshk Jul 7, 2023
b230366
docs, tests and examples updated
adoroshk Jul 10, 2023
52bcd8f
wdio snapshots updated
adoroshk Jul 10, 2023
848c29f
better wording
adoroshk Jul 10, 2023
ccf7a43
removed extra 'props' before focusRef
adoroshk Jul 10, 2023
b28173d
wdio tests enhanced coverage
adoroshk Jul 11, 2023
a8e457b
[terra-show-hide] Shift keyboard focus to newly revealed content with…
adoroshk Jun 30, 2023
c7a4f09
prop to focus on the element added
adoroshk Jul 7, 2023
f21df4a
changelogs updated
adoroshk Jul 7, 2023
d506978
terra-core-docs changelog fix
adoroshk Jul 7, 2023
41f2664
text edits, comments added
adoroshk Jul 7, 2023
af989d2
text edits
adoroshk Jul 7, 2023
bf7a1c8
text edits
adoroshk Jul 7, 2023
65bd67e
extra line removed
adoroshk Jul 7, 2023
ec8e2fe
changelog in terra-core-docs updated
adoroshk Jul 7, 2023
aed44ee
docs, tests and examples updated
adoroshk Jul 10, 2023
afa2305
wdio snapshots updated
adoroshk Jul 10, 2023
eb321d7
better wording
adoroshk Jul 10, 2023
8329d69
removed extra 'props' before focusRef
adoroshk Jul 10, 2023
7331103
wdio tests enhanced coverage
adoroshk Jul 11, 2023
0cca372
changelog fix
adoroshk Jul 11, 2023
db8474e
Merge branch 'terra-show-hide-focusing' of https://github.com/cerner/…
adoroshk Jul 11, 2023
a73b621
removed unused css for focusing span, propType for focusRef fixed
adoroshk Jul 11, 2023
76da4f0
jest test update
adoroshk Jul 12, 2023
aebb65b
focus css lighter border
adoroshk Jul 12, 2023
1058492
css styles for focus combined
adoroshk Jul 12, 2023
b87f7ad
removed data-focus-styles-enabled attribute
adoroshk Jul 12, 2023
6d1d090
activeElement added to state
adoroshk Jul 13, 2023
25e6d2b
conditional role for container
adoroshk Jul 13, 2023
74d9818
Merge branch 'main' into terra-show-hide-focusing
adoroshk Jul 13, 2023
7e33876
test and lint updates
adoroshk Jul 13, 2023
efbb870
Merge branch 'terra-show-hide-focusing' of https://github.com/cerner/…
adoroshk Jul 13, 2023
535dadd
wdio screenshot updates per style changed
adoroshk Jul 14, 2023
170f7cb
checks for role before replacing it, replaces activeElement with 3 op…
adoroshk Jul 14, 2023
22a779d
import fix, isModified variable added
adoroshk Jul 15, 2023
831987f
fix for forgotten role
adoroshk Jul 15, 2023
4d398fe
focus border inherits color
adoroshk Jul 18, 2023
d6b8635
fusion theme dashed outline
adoroshk Jul 18, 2023
3db7955
Merge branch 'main' of https://github.com/cerner/terra-core into terr…
adoroshk Jul 19, 2023
39e028f
snapshots updated
adoroshk Jul 20, 2023
3cc0b6f
Merge branch 'main' into terra-show-hide-focusing
adoroshk Jul 20, 2023
ae25222
divider for JAWS reading line-by-line
adoroshk Jul 20, 2023
b37422c
Merge branch 'terra-show-hide-focusing' of https://github.com/cerner/…
adoroshk Jul 20, 2023
1be999d
bottom divided test with JAWS
adoroshk Jul 20, 2023
6ecb098
new approach testing
adoroshk Jul 20, 2023
94850b3
test case for long paragraph
adoroshk Jul 20, 2023
c68c5b5
no focus ref example for testing
adoroshk Jul 20, 2023
abc4eda
paragraph component, examples and docs updated
adoroshk Jul 24, 2023
936edf6
doc text update
adoroshk Jul 25, 2023
6c7525b
tabIndex moved to Paragraph, Link Show Hide example added
adoroshk Jul 25, 2023
6e47ea6
role back as it doesn't work without role
adoroshk Jul 25, 2023
7b4be27
check if Paragraph incorporates p resolves the problem with JAWS
adoroshk Jul 25, 2023
8a4a7f9
p incorporation reverted, paragraph max length experiment
adoroshk Jul 25, 2023
74096b1
paragraph snapshots added
adoroshk Jul 25, 2023
d49e829
docs and tests updates
adoroshk Jul 25, 2023
ec0f3e7
check if <p> fixes JAWS confusion in <li>
adoroshk Jul 25, 2023
0156351
Doc text fixes and <p> reverted
adoroshk Jul 25, 2023
c605fd9
test if active container is the reason of JAWS confusion
adoroshk Jul 25, 2023
1835ec8
check if problem is specific to <li> element
adoroshk Jul 26, 2023
b29f4c6
id and aria-controls added
adoroshk Jul 26, 2023
cc85388
test if display fixes jaws confusion
adoroshk Jul 26, 2023
e77057f
test short sentences in li
adoroshk Jul 26, 2023
4357670
test li with display block
adoroshk Jul 26, 2023
ca05167
multiple children example added
adoroshk Jul 26, 2023
7181971
Paragrahp renamed to be focuser, examples and docs updated
adoroshk Jul 27, 2023
85736f7
text edits
adoroshk Jul 28, 2023
0db375b
wording change
adoroshk Jul 28, 2023
e8c4f6d
button accessible, no focusRef description removed
adoroshk Jul 28, 2023
e894289
Update packages/terra-core-docs/src/terra-dev-site/doc/show-hide/Abou…
adoroshk Jul 28, 2023
d341177
Update packages/terra-core-docs/src/terra-dev-site/doc/show-hide/Abou…
adoroshk Jul 28, 2023
d662383
Update packages/terra-core-docs/src/terra-dev-site/doc/show-hide/Abou…
adoroshk Jul 28, 2023
00d860f
Update packages/terra-core-docs/src/terra-dev-site/doc/show-hide/Abou…
adoroshk Jul 28, 2023
9ca3ff7
Update packages/terra-core-docs/src/terra-dev-site/doc/show-hide/Abou…
adoroshk Jul 28, 2023
7d0d3fb
Update packages/terra-core-docs/src/terra-dev-site/doc/show-hide/Abou…
adoroshk Jul 28, 2023
09d4e45
h4 changed to h3, typo fix
adoroshk Jul 28, 2023
eb4d10d
tabindex for button reverted, prop required fix
adoroshk Jul 28, 2023
0d1dbe5
fixes button being not accessible with VO Down Arrow
adoroshk Jul 29, 2023
11668ab
revert removing user-select property untill future investigation
adoroshk Jul 31, 2023
0986b97
Merge branch 'main' into terra-show-hide-focusing
adoroshk Jul 31, 2023
ef2f17d
id for focus ref added, test if helps avoid VO confusion
adoroshk Jul 31, 2023
35bfc7e
Merge branch 'terra-show-hide-focusing' of https://github.com/cerner/…
adoroshk Jul 31, 2023
fff0ad2
test list example
adoroshk Aug 1, 2023
877b70a
list example test with p
adoroshk Aug 1, 2023
eecfd9a
list example removed, caution placeholder
adoroshk Aug 1, 2023
a742c20
Merge branch 'main' into terra-show-hide-focusing
adoroshk Aug 2, 2023
f7d993c
Focuser renamed to ShowHideFocuser
adoroshk Aug 2, 2023
a616917
documentation update
adoroshk Aug 4, 2023
fce63fe
Update docs with suggested wording
adoroshk Aug 9, 2023
1813b07
comment to example added
adoroshk Aug 9, 2023
67dcc73
typo fix
adoroshk Aug 9, 2023
c8f17c0
str renamed, prop description fixed
adoroshk Aug 11, 2023
8493e05
Merge branch 'main' into terra-show-hide-focusing
adoroshk Aug 11, 2023
aa41c4b
uuid version and mock reset changed
adoroshk Aug 11, 2023
a47b7a6
doc edits
adoroshk Aug 11, 2023
2e998eb
test update for noPreview change
adoroshk Aug 11, 2023
822fe03
index file added for exports
adoroshk Aug 11, 2023
41cac25
index jsx changed to js
adoroshk Aug 11, 2023
6ad93a1
comment to explain the id added to focusable span
adoroshk Aug 11, 2023
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
1 change: 1 addition & 0 deletions packages/terra-core-docs/CHANGELOG.md
adoroshk marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Updated
* Updated an example for `terra-dropdown-button`.
* Updated email field validation for `terra-form-field`.
* Updated `terra-show-hide` examples for new focusRef prop, description for the new prop usage.

* Added
* Added documentation updates for `terra-form-input`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import { Badge } from 'terra-show-hide/package.json?dev-site-package';
import { Notice } from "@cerner/terra-docs";

import DefaultShowHide from './example/DefaultShowHide?dev-site-example';
import CustomButtonTextShowHide from './example/CustomButtonTextShowHide?dev-site-example';
import LinkShowHide from './example/LinkShowHide?dev-site-example';
import InitiallyOpenShowHide from './example/InitiallyOpenShowHide?dev-site-example';
import ButtonAlignCenterShowHide from './example/ButtonAlignCenterShowHide?dev-site-example';
import ButtonAlignRightShowHide from './example/ButtonAlignRightShowHide?dev-site-example';
import NoPreviewShowHide from './example/NoPreviewShowHide?dev-site-example';
import NoFocusRefShowHide from './example/NoFocusRefShowHide?dev-site-example';

import ShowHidePropsTable from 'terra-show-hide/src/ShowHide?dev-site-props-table';
import ShowHideFocuserPropsTable from 'terra-show-hide/src/ShowHideFocuser?dev-site-props-table';

<Badge />

# Terra Show Hide

Show Hide Component that will show a preview of content and then expand it with a Show More button.
Show Hide Component - is a disclosure widget that enables content to be either collapsed (hidden) or expanded (visible). It has two elements: a disclosure [button][1] and a section of content whose visibility is controlled by the button. When the controlled content is hidden, the button is often styled as a typical push button with a down-pointing caret to hint that activating the button will display additional content. When the content is visible, the content displays above the button and the caret points up.
adoroshk marked this conversation as resolved.
Show resolved Hide resolved

Another Terra component, [Toggle Button][2], is available and preferred to Show/Hide because it better adheres to accessibility best practices for disclosure components. It differs from Show Hide by displaying the content below the button when it is activated.
adoroshk marked this conversation as resolved.
Show resolved Hide resolved

[1]: https://www.w3.org/WAI/ARIA/apg/patterns/button/
[2]: https://engineering.cerner.com/terra-core/components/cerner-terra-core-docs/toggle-button/about

## Getting Started

Expand Down Expand Up @@ -42,9 +51,127 @@ The Show-Hide component must be composed inside the [Base][1] component with a l
## Usage

```jsx
import ShowHide from 'terra-show-hide';
import ShowHide, { ShowHideFocuser } from 'terra-show-hide';
```

## Accessibility
Copy link
Contributor

@smason0 smason0 Jul 28, 2023

Choose a reason for hiding this comment

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

Wonder if this section would be better placed after the "Examples" section that explains the basic usage.

Edit: Nvm I see we have it this way in the "Alert" component page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I am also not sure where to place that block. We might want to re-visit that question after the rest of documentation is approved.


<Notice variant="important" ariaLevel="3">

To make the Show/Hide component accessible, you must use the `focusRef` prop. This prop allows assistive technologies such as screen readers to move user focus backward to hidden text and announce it when it is disclosed. For backward compatibility, the `focusRef` prop is optional, but is required to meet accessibility requirements.
adoroshk marked this conversation as resolved.
Show resolved Hide resolved

</Notice>

<Notice variant="caution" ariaLevel="3">

This component is not recommended for use in Safari due to VoiceOver focus limitations with Show Hide. Consider using Terra Toggle Button instead.
adoroshk marked this conversation as resolved.
Show resolved Hide resolved

</Notice>

### Keyboard Interactions
When the disclosure control has focus:
- Enter key activates the disclosure control and toggles the visibility of the disclosure content.
- Space key activates the disclosure control and toggles the visibility of the disclosure content.
Comment on lines +77 to +78
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this correct? They both say the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess @mjpalazzo put it that way in purpose. He can answer that better than me.


### Truncate a paragraph of text
adoroshk marked this conversation as resolved.
Show resolved Hide resolved

- At the top level of your component declare a `ref`, pass it as `focusRef` prop to `ShowHide` component.
adoroshk marked this conversation as resolved.
Show resolved Hide resolved
- Pass a node with the preview portion of the text as a prop to `ShowHide` component.
- Use the `ShowHideFocuser` component inside `<p>` tag. A `ShowHideFocuser` component allows `ShowHide` component to set focus on the beginning of the focusable text upon opening.
- The text split in the prefix and focusable text portions must be passed as string props. The prefix prop should contain the portion of the text that was a part of the preview prop, passed to `ShowHide`.
- Forward `focusRef` to `ShowHideFocuser` component.

```jsx
import React, { useRef, useState } from 'react';
import ShowHide, { ShowHideFocuser } from 'terra-show-hide';

const MyComponent = () => {
const focusRef = useRef(null);
const [isOpen, setIsOpen] = useState(false);
const toggleShowHide = () => setIsOpen(!isOpen);

const prefix = 'Patients are requesting greater affordability and efficiency in healthcare. With procedures performed in an ambulatory surgery center costing up to 60% less compared to a hospital outpatient department (1), the demand for these facilities is increasing.';
const focusableText = 'In fact, the U.S. ambulatory surgery center market is expected to see a 6.9 % compound annual growth rate, reaching $33 billion by 2028. (2) Cerner understands the urgency to grow in the ambulatory surgery center market while continuing to deliver excellent care. Healthcare IT products can help improve clinician efficiency and patient outcomes, as well as enhance communication and data exchange between ambulatory surgery center providers and patients. Read';
adoroshk marked this conversation as resolved.
Show resolved Hide resolved

return (
<ShowHide focusRef={focusRef} preview={ <p>{prefix}</p> } isOpen={isOpen} onChange={toggleShowHide} >
<p>
<ShowHideFocuser ref={this.focusRef} prefix={prefix} focusableText={focusableText} />
</p>
</ShowHide>
);
}
```

### Multiple children
Even though the main purpose of the `ShowHide` component is to truncate long paragraps of texts, the content of the `ShowHide` does not have to be one paragraph. It can include links, lists, and any kind of HTML tags as long as the first line of the hidden text is passed as a string prop to `ShowHideFocuser` component rather than an HTML element.
adoroshk marked this conversation as resolved.
Show resolved Hide resolved

Please note:
- Links can be placed inside the `p` tag that wraps `ShowHideFocuser` component both preceding and following it. The prop `prefix` can be omitted if content has been passed as an HTML element preceding `ShowHideFocuser`.
adoroshk marked this conversation as resolved.
Show resolved Hide resolved
- Everything that precedes `ShowHideFocuser` component must be also included into the `ShowHide` preview prop.
adoroshk marked this conversation as resolved.
Show resolved Hide resolved
- Do not break lists placing `ShowHideFocuser` inside `li`, as it might cause assistive technologies to read the content incorrectly.
adoroshk marked this conversation as resolved.
Show resolved Hide resolved

```jsx
import React, { useState, useRef } from 'react';
import ShowHide, { ShowHideFocuser } from 'terra-show-hide';

const MyComponent = () => {
const focusRef = useRef(null);
const [isOpen, setIsOpen] = useState(false);
const toggleShowHide = () => setIsOpen(!isOpen);

const header = 'Bringing clarity to life sciences and healthcare decision-making ';
const prefix = 'When we accelerate the discovery, development and deployment of life-enhancing insights and therapies, clinicians and patients benefit.';
const preview = [
<h3>{header}</h3>,
<p>{prefix}</p>,
];

return (
<ShowHide focusRef={focusRef} preview={preview} isOpen={isOpen} onChange={toggleShowHide} >
<h3>{header}</h3>
<p>
<ShowHideFocuser ref={this.focusRef} prefix={prefix} focusableText="Several factors help bring clarity to life sciences, researchers and clinicians and " />
Copy link
Contributor

Choose a reason for hiding this comment

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

this could use a comment describing exactly what the resulting behavior of this would be.

Copy link
Contributor Author

@adoroshk adoroshk Aug 9, 2023

Choose a reason for hiding this comment

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

Added in 1813b07

<a href="#">guide better care</a>
</p>
<ul>
<li>Data-driven research solutions for commercial and real-world evidence collaborators and health providers</li>
<li>Support to move from simply accumulating and analyzing data to linking and generating deeper insights </li>
<li>Combined life sciences knowledge, healthcare innovation and collaborative research expertise</li>
</ul>
</ShowHide>
);
}
```

### First hidden child is an interactive element (link, button, etc)
- At the top level of your component declare a `ref`.
adoroshk marked this conversation as resolved.
Show resolved Hide resolved
- In this case there is no need to use `ShowHideFocuser`. Forward `focusRef` to the interactive element directly.

```jsx
import React, { useState, useRef } from 'react';
import ShowHide from 'terra-show-hide';

const MyComponent = () => {
const focusRef = useRef(null);
const [isOpen, setIsOpen] = useState(false);
const toggleShowHide = () => setIsOpen(!isOpen);

const previewText = 'Although the process is complex and will vary greatly based on regional and economic factors, it’s clear that healthcare entities must start planning their transitions now.';
const text = 'it expects all Medicare Parts A and B beneficiaries and most Medicaid beneficiaries to be in a value-based care relationship with accountability for quality and total cost of care by 2030.';

return (
<ShowHide focusRef={focusRef} preview={<p>{previewText}</p>} isOpen={isOpen} onChange={toggleShowHide} >
<p>
{previewText}
<a ref={this.focusRef} href="#">CMS recently announced</a>
{text}
</p>
</ShowHide>
);
}
```

## Component Features

* [Cross-Browser Support](https://engineering.cerner.com/terra-ui/about/terra-ui/component-standards#cross-browser-support)
Expand All @@ -57,10 +184,17 @@ import ShowHide from 'terra-show-hide';
## Examples
<DefaultShowHide title="Default ShowHide" />
<CustomButtonTextShowHide title="Custom Button Text ShowHide" />
<LinkShowHide title="ShowHide with a Link" />
<MultipleChildrenShowHide title="ShowHide with Multiple Children" />
<ListShowHide title="ShowHide with a List Content" />
<InitiallyOpenShowHide title="Initially Open ShowHide" />
<ButtonAlignCenterShowHide title="Button Align Center ShowHide" />
<ButtonAlignRightShowHide title="Button Align Right ShowHide" />
<NoPreviewShowHide title="No Preview ShowHide" />
<NoFocusRefShowHide title="No focusRef ShowHide (see Accessibility note for information about the focusRef prop)" />

## Show Hide Props
<ShowHidePropsTable />

## Show Hide Focuser Props
<ShowHideFocuserPropsTable />
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import React from 'react';
import ShowHide from 'terra-show-hide';
import ShowHide, { ShowHideFocuser } from 'terra-show-hide';

const fullText = 'According to the Journal of Healthcare Management/American College of Healthcare Executives, a 500-bed hospital loses over $4 million annually due to clinical communication inefficiencies. A unified clinical communication strategy can help health systems begin to close the gap and improve efficiency at every level. Enable your clinical care team with real-time health communication tools and workflows that help them to collaborate more effectively on the go and provide a quality patient care experience. A unified strategy and improved communication tools can help address many challenges including identification of patient care team members, mobile clinical workflows, secure and timely critical alerts, and more.';
const previewText = fullText.substring(0, 280);
const prefix = 'According to the Journal of Healthcare Management/American College of Healthcare Executives, a 500-bed hospital loses over $4 million annually due to clinical communication inefficiencies. A unified clinical communication strategy can help health systems begin to close the gap';
const focusableText = 'and improve efficiency at every level. Enable your clinical care team with real-time health communication tools and workflows that help them to collaborate more effectively on the go and provide a quality patient care experience. A unified strategy and improved communication tools can help address many challenges including identification of patient care team members, mobile clinical workflows, secure and timely critical alerts, and more.';

class ButtonAlignCenterShowHide extends React.Component {
constructor(props) {
super(props);

this.state = { isOpen: false };
this.toggleShowHide = this.toggleShowHide.bind(this);
this.focusRef = React.createRef();
}

toggleShowHide() {
Expand All @@ -21,8 +22,8 @@ class ButtonAlignCenterShowHide extends React.Component {
render() {
return (
<div>
<ShowHide buttonAlign="center" preview={<p>{previewText}</p>} isOpen={this.state.isOpen} onChange={this.toggleShowHide}>
<p>{fullText}</p>
<ShowHide focusRef={this.focusRef} buttonAlign="center" preview={<p>{prefix}</p>} isOpen={this.state.isOpen} onChange={this.toggleShowHide}>
<p><ShowHideFocuser ref={this.focusRef} prefix={prefix} focusableText={focusableText} /></p>
</ShowHide>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import React from 'react';
import ShowHide from 'terra-show-hide';
import ShowHide, { ShowHideFocuser } from 'terra-show-hide';

const fullText = 'A connected care team starts with an integrated communication strategy. CareAware ConnectTM is a healthcare communication tool that leverages the use of intuitive technology to help associate the right care team members with the right patients and provides a way to effectively communicate and collaborate while on the go through a smart, mobile device. Integration with Cerner Millennium® enables care teams to streamline bedside workflows including medication administration, device association, and specimen collection.';
const previewText = fullText.substring(0, 280);
const prefix = 'A connected care team starts with an integrated communication strategy. CareAware ConnectTM is a healthcare communication tool that leverages the use of intuitive technology to help associate the right care team members with the right patients and provides a way to effectively';
const focusableText = 'communicate and collaborate while on the go through a smart, mobile device. Integration with Cerner Millennium® enables care teams to streamline bedside workflows including medication administration, device association, and specimen collection.';

class ButtonAlignRightShowHideTest extends React.Component {
constructor(props) {
super(props);

this.state = { isOpen: false };
this.toggleShowHide = this.toggleShowHide.bind(this);
this.focusRef = React.createRef();
}

toggleShowHide() {
Expand All @@ -21,8 +22,8 @@ class ButtonAlignRightShowHideTest extends React.Component {
render() {
return (
<div>
<ShowHide buttonAlign="end" preview={<p>{previewText}</p>} isOpen={this.state.isOpen} onChange={this.toggleShowHide}>
<p>{fullText}</p>
<ShowHide focusRef={this.focusRef} buttonAlign="end" preview={<p>{prefix}</p>} isOpen={this.state.isOpen} onChange={this.toggleShowHide}>
<p><ShowHideFocuser ref={this.focusRef} prefix={prefix} focusableText={focusableText} /></p>
</ShowHide>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from 'react';
import ShowHide from 'terra-show-hide';

const sentences = [
<h3 key="sentence1">Key Benefits of Cerner Cardiovascular Solutions</h3>,
<p key="sentence2">Eliminates silos of information and the resulting inefficiencies with a unified EHR and cardiovascular system</p>,
<p key="sentence3">Creates efficient diagnostic workflows, image management and analysis</p>,
<p key="sentence4">Enhances clinical, financial and performance outcomes with comprehensive procedural documentation</p>,
<p key="sentence5">Promotes cardiac disease management through health maintenance protocols</p>,
// <p key="sentence6">Lorem ipsum dolor sit amet consectetur adipiscing elit.</p>,
// <p key="sentence7">Lorem ipsum dolor sit amet consectetur adipiscing elit.</p>,
// <p key="sentence8">Lorem ipsum dolor sit amet consectetur adipiscing elit.</p>,
// <p key="sentence9">Lorem ipsum dolor sit amet consectetur adipiscing elit.</p>
import ShowHide, { ShowHideFocuser } from 'terra-show-hide';

const header = 'Bringing clarity to life sciences and healthcare decision-making ';
const text = [
'When we accelerate the discovery, development and deployment of life-enhancing insights and therapies, clinicians and patients benefit. Connecting data and breaking down silos',
'across the healthcare innovation ecosystem must be our collective focus to help improve everyday health for all people. Several factors help bring clarity to life sciences, researchers and clinicians and',
'guide better care,',
'including:',
];
const listItems = [
<li key="item1">Data-driven research solutions for commercial and real-world evidence collaborators and health providers</li>,
<li key="item2">Support to move from simply accumulating and analyzing data to linking and generating deeper insights </li>,
<li key="item3">Combined life sciences knowledge, healthcare innovation and collaborative research expertise</li>,
<li key="item4">Access to an expansive network of diverse research-ready health systems; as well as de-identified, real-world data from the EHR that also includes patient-reported outcomes</li>,
];
const conclusion = 'Through data and technology, we have the power to help life sciences, clinicians and researchers expand therapeutic areas of research and generate better evidence to solve healthcare challenges around the world. Together, we can accelerate groundbreaking research and trial opportunities that have the potential to transform everyday healthcare and improve people’s lives.';

const preview = [
<h3 key="header">{header}</h3>,
<p key="prefix">{text[0]}</p>,
];

class CustomButtonTextShowHide extends React.Component {
Expand All @@ -19,6 +28,7 @@ class CustomButtonTextShowHide extends React.Component {

this.state = { isOpen: false };
this.toggleShowHide = this.toggleShowHide.bind(this);
this.focusRef = React.createRef();
}

toggleShowHide() {
Expand All @@ -31,19 +41,29 @@ class CustomButtonTextShowHide extends React.Component {
let customText = '';

if (this.state.isOpen) {
customText = `Hide ${sentences.length - 3} Sentences`;
customText = 'Hide Composit Content';
} else {
customText = `Show ${sentences.length - 3} More Sentences`;
customText = 'Show Composit Content';
}

return (
<ShowHide
preview={[sentences[0], sentences[1], sentences[2]]}
preview={preview}
onChange={this.toggleShowHide}
isOpen={this.state.isOpen}
buttonText={customText}
focusRef={this.focusRef}
>
{sentences}
<h3>{header}</h3>
<p>
<ShowHideFocuser ref={this.focusRef} prefix={text[0]} focusableText={text[1]} />
{' '}
<a href="#">{text[2]}</a>
{' '}
{text[3]}
</p>
<ul>{listItems}</ul>
<p>{conclusion}</p>
</ShowHide>
);
}
Expand Down
Loading
Loading