diff --git a/.eslintrc.yml b/.eslintrc.yml index d2f4ec6b0ac..2c166b21137 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -2,3 +2,10 @@ extends: "@cerner/terra" globals: enzyme: readonly enzymeIntl: readonly +overrides: + - files: + - packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/OnClickSectionHeader.jsx + - packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/TransparentSectionHeader.jsx + rules: + no-alert: off + diff --git a/packages/terra-core-docs/CHANGELOG.md b/packages/terra-core-docs/CHANGELOG.md index abf845e7a91..2875a1759b8 100644 --- a/packages/terra-core-docs/CHANGELOG.md +++ b/packages/terra-core-docs/CHANGELOG.md @@ -5,6 +5,9 @@ * Added * Added examples and tests for `terra-dropdown-button` `SplitButton` with icons. +* Changed + * Updated `terra-section-header` examples to be more consumer friendly by removing templates. + ## 1.70.0 - (April 4, 2024) * Changed @@ -15,6 +18,7 @@ * Added * Added an example for `terra-hyperlink` to demonstrate text ellipses when its content should overflow. + * Changed * Fixed typos and imports in `terra-list` docs. * Updated `terra-signature` example to include text and image signature. @@ -30,13 +34,12 @@ * Changed * Changed `terra responsive element` docs to include reflow details. * Updated `terra-alert` example to use `titleID` prop. - * Updated usage documentation for terra-form-checkbox, terra-form-input, terra-form-radio & terra-form-textarea. + * Updated usage documentation for `terra-form-checkbox`, `terra-form-input`, `terra-form-radio` & `terra-form-textarea`. ## 1.66.0 - (March 12, 2024) -* Updated - * Updated terra list examples. * Changed + * Updated `terra list` examples. * Updated documentation for `terra-form-select`. ## 1.65.0 - (March 8, 2024) diff --git a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/AccordionExampleTemplate.jsx b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/AccordionExampleTemplate.jsx deleted file mode 100644 index 123a65766cc..00000000000 --- a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/AccordionExampleTemplate.jsx +++ /dev/null @@ -1,111 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import SectionHeader from 'terra-section-header'; -import Toggle from 'terra-toggle'; - -const propTypes = { - /** - * Content in the body of the section header component that will be expanded or hidden. - */ - children: PropTypes.node, - /** - * Text to be displayed in the section header. - */ - heading: PropTypes.string, - /** - * Text to be displayed in the section header. - */ - text: PropTypes.string, - /** - * Used to set props and HTML attributes on the underlying section-header. - */ - // eslint-disable-next-line react/forbid-prop-types - sectionHeaderAttrs: PropTypes.object, - /** - * Sets the section-header to be animated when it is opened or closed. - */ - isAnimated: PropTypes.bool, - /** - * Programmatically the section-header component. - */ - isOpen: PropTypes.bool, -}; - -const defaultProps = { - sectionHeaderAttrs: {}, - isAnimated: false, - isOpen: undefined, -}; - -class AccoordianExampleTemplate extends React.Component { - constructor(props) { - super(props); - - this.state = { isOpen: false }; - - this.handleOnClick = this.handleOnClick.bind(this); - this.wrapOnClick = this.wrapOnClick.bind(this); - } - - static getDerivedStateFromProps(nextProps, prevState) { - if (nextProps.isOpen !== undefined && prevState.isOpen !== nextProps.isOpen) { - return { isOpen: nextProps.isOpen }; - } - return { isOpen: prevState.isOpen }; - } - - handleOnClick(event) { - event.preventDefault(); - const { isOpen } = this.props; - if (isOpen === undefined) { - this.setState(prevState => ({ - isOpen: !prevState.isOpen, - })); - } - } - - wrapOnClick(onClick) { - return ((event) => { - this.handleOnClick(event); - - if (onClick) { - onClick(event); - } - }); - } - - render() { - const { - children, - heading, - text, - isAnimated, - isOpen, - sectionHeaderAttrs, - ...customProps - } = this.props; - - const sectionHeaderProps = { ...sectionHeaderAttrs }; - sectionHeaderProps.onClick = this.wrapOnClick(sectionHeaderAttrs.onClick); - - return ( -
-

{heading}

- - - {children} - -
- ); - } -} - -AccoordianExampleTemplate.propTypes = propTypes; -AccoordianExampleTemplate.defaultProps = defaultProps; - -export default AccoordianExampleTemplate; diff --git a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/AccordionSectionHeader.jsx b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/AccordionSectionHeader.jsx index d2c303c2d1b..728d7790589 100644 --- a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/AccordionSectionHeader.jsx +++ b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/AccordionSectionHeader.jsx @@ -1,5 +1,6 @@ import React, { useState } from 'react'; -import AccoordianExampleTemplate from './AccordionExampleTemplate'; +import SectionHeader from 'terra-section-header'; +import Toggle from 'terra-toggle'; const AccordionSectionHeader = () => { const [isOpen, setIsOpen] = useState(false); @@ -8,19 +9,23 @@ const AccordionSectionHeader = () => { setIsOpen(!isOpen); }; - const sectionHeaderProps = { - isOpen, - onClick: handleClick, - }; - return ( - -

Allergic to Cats

-

Allergic to Dogs

-

Allergic to Dust

-

Allergic to Mold

-

Allergic to Latex

-
+
+

Accordion Section Header

+ + +

Allergic to Cats

+

Allergic to Dogs

+

Allergic to Dust

+

Allergic to Mold

+

Allergic to Latex

+
+
); }; diff --git a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/AccordionSectionHeaderAccess.jsx b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/AccordionSectionHeaderAccess.jsx index ea1efb1ff0d..8915a3c59e6 100644 --- a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/AccordionSectionHeaderAccess.jsx +++ b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/AccordionSectionHeaderAccess.jsx @@ -1,6 +1,7 @@ import React, { useState } from 'react'; import Card from 'terra-card'; -import AccoordianExampleTemplate from './AccordionExampleTemplate'; +import SectionHeader from 'terra-section-header'; +import Toggle from 'terra-toggle'; const AccordionSectionHeaderAccess = () => { const [isOpen, setIsOpen] = useState(false); @@ -9,23 +10,25 @@ const AccordionSectionHeaderAccess = () => { setIsOpen(!isOpen); }; - const sectionHeaderProps = { - isOpen, - level: 3, - onClick: handleClick, - }; - return (
- +

Documented Allergies

+ +

Cats

Dogs

Dust

Mold

Latex

-
+
diff --git a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/ClosedSectionHeader.jsx b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/ClosedSectionHeader.jsx index cf955519da2..005381c20be 100644 --- a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/ClosedSectionHeader.jsx +++ b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/ClosedSectionHeader.jsx @@ -1,11 +1,16 @@ import React from 'react'; -import SectionHeaderExampleTemplate from './SectionHeaderExampleTemplate'; +import SectionHeader from 'terra-section-header'; const sectionHeaderProps = { text: 'Closed', onClick: () => {}, }; -const ClosedSectionHeader = () => ; +const ClosedSectionHeader = () => ( +
+

Closed Section Header

+ +
+); export default ClosedSectionHeader; diff --git a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/DefaultSectionHeader.jsx b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/DefaultSectionHeader.jsx index 4522817ac15..5289cc2522d 100644 --- a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/DefaultSectionHeader.jsx +++ b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/DefaultSectionHeader.jsx @@ -1,6 +1,11 @@ import React from 'react'; -import SectionHeaderExampleTemplate from './SectionHeaderExampleTemplate'; +import SectionHeader from 'terra-section-header'; -const DefaultSectionHeader = () => ; +const DefaultSectionHeader = () => ( +
+

Default

+ +
+); export default DefaultSectionHeader; diff --git a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/LongTitleAccordionSectionHeader.jsx b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/LongTitleAccordionSectionHeader.jsx index 1404d86cdf6..5bd21e0483d 100644 --- a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/LongTitleAccordionSectionHeader.jsx +++ b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/LongTitleAccordionSectionHeader.jsx @@ -1,5 +1,6 @@ import React, { useState } from 'react'; -import AccoordianExampleTemplate from './AccordionExampleTemplate'; +import SectionHeader from 'terra-section-header'; +import Toggle from 'terra-toggle'; const LongTitleAccordionSectionHeader = () => { const [isOpen, setIsOpen] = useState(false); @@ -8,15 +9,23 @@ const LongTitleAccordionSectionHeader = () => { setIsOpen(!isOpen); }; - const sectionHeaderProps = { - isOpen, - onClick: handleClick, - }; - return ( - -

Keystone Accountable Care Organization (ACO), a collaboration between Geisinger Health System and three other health systems, entered the Medicare Shared Savings Program (MSSP) in 2013 and transitioned to an MSSP Track 1+ in 2018, qualifying Keystone ACO as an advanced payment model. According to the Centers for Medicaid and Medicare Services (CMS) benchmark minus expenditures formula, the ACO saved Medicare nearly $10 million in 2018. Hear how Keystone ACO is using the Cerner HealtheIntent® platform to garner insights across more than 72,000 ACO beneficiaries and multiple EHRs.

-
+
+

Long Title Accordion Section Header

+ + +

+ Keystone Accountable Care Organization (ACO), a collaboration between Geisinger Health System and three other health systems, entered the Medicare Shared Savings Program (MSSP) in 2013 and transitioned to an MSSP Track 1+ in 2018, qualifying Keystone ACO as an advanced payment model. + According to the Centers for Medicaid and Medicare Services (CMS) benchmark minus expenditures formula, the ACO saved Medicare nearly $10 million in 2018. + Hear how Keystone ACO is using the Cerner HealtheIntent® platform to garner insights across more than 72,000 ACO beneficiaries and multiple EHRs. +

+
+
); }; diff --git a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/LongTitleSectionHeader.jsx b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/LongTitleSectionHeader.jsx index 164137db5e8..bda03d08794 100644 --- a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/LongTitleSectionHeader.jsx +++ b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/LongTitleSectionHeader.jsx @@ -1,6 +1,11 @@ import React from 'react'; -import SectionHeaderExampleTemplate from './SectionHeaderExampleTemplate'; +import SectionHeader from 'terra-section-header'; -const LongTitleSectionHeader = () => ; +const LongTitleSectionHeader = () => ( +
+

Long Title

+ +
+); export default LongTitleSectionHeader; diff --git a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/OnClickSectionHeader.jsx b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/OnClickSectionHeader.jsx index 182df24725a..a46dad69579 100644 --- a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/OnClickSectionHeader.jsx +++ b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/OnClickSectionHeader.jsx @@ -1,14 +1,18 @@ import React from 'react'; -import SectionHeaderExampleTemplate from './SectionHeaderExampleTemplate'; +import SectionHeader from 'terra-section-header'; const sectionHeaderProps = { text: 'I\'m clickable, click me', onClick: () => { - // eslint-disable-next-line no-alert window.alert('The accordion has been clicked!'); }, }; -const OnClickSectionHeader = () => ; +const OnClickSectionHeader = () => ( +
+

OnClick Section Header

+ +
+); export default OnClickSectionHeader; diff --git a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/OpenSectionHeader.jsx b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/OpenSectionHeader.jsx index 23b37d05137..1aba3fddfab 100644 --- a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/OpenSectionHeader.jsx +++ b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/OpenSectionHeader.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import SectionHeaderExampleTemplate from './SectionHeaderExampleTemplate'; +import SectionHeader from 'terra-section-header'; const sectionHeaderProps = { text: 'Open', @@ -7,6 +7,11 @@ const sectionHeaderProps = { onClick: () => {}, }; -const OpenSectionheader = () => ; +const OpenSectionheader = () => ( +
+

Open Section Header

+ +
+); export default OpenSectionheader; diff --git a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/SectionHeaderExampleTemplate.jsx b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/SectionHeaderExampleTemplate.jsx deleted file mode 100644 index 2e7a5bdaa5e..00000000000 --- a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/SectionHeaderExampleTemplate.jsx +++ /dev/null @@ -1,26 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import SectionHeader from 'terra-section-header'; - -const propTypes = { - /** - * Title of the example - */ - title: PropTypes.string.isRequired, - /** - * Props to be spread onto SectionHeader - */ - // eslint-disable-next-line react/forbid-prop-types - exampleProps: PropTypes.object.isRequired, -}; - -const SectionHeaderExampleTemplate = ({ title, exampleProps }) => ( -
-

{title}

- -
-); - -SectionHeaderExampleTemplate.propTypes = propTypes; - -export default SectionHeaderExampleTemplate; diff --git a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/TransparentSectionHeader.jsx b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/TransparentSectionHeader.jsx index d19acdda44c..c66b2fe0b91 100644 --- a/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/TransparentSectionHeader.jsx +++ b/packages/terra-core-docs/src/terra-dev-site/doc/section-header/example/TransparentSectionHeader.jsx @@ -1,15 +1,19 @@ import React from 'react'; -import SectionHeaderExampleTemplate from './SectionHeaderExampleTemplate'; +import SectionHeader from 'terra-section-header'; const sectionHeaderProps = { - text: 'I\'m clickable, click me', + text: "I'm clickable, click me", onClick: () => { - // eslint-disable-next-line no-alert window.alert('The accordion has been clicked!'); }, isTransparent: true, }; -const TransparentSectionHeader = () => ; +const TransparentSectionHeader = () => ( +
+

Transparent Section Header

+ +
+); export default TransparentSectionHeader;