Skip to content

Commit

Permalink
fix(cta-section): ensure buttons are not allowed as cta types (#7782)
Browse files Browse the repository at this point in the history
### Related Ticket(s)
#7439

### Description
Currently the CTA Section story allowed Buttons as CTA types for the content items. With this new PR, I removed the ability to choose Buttons from the knob, as well as ensure that any slotted Button Group does not render if within a `cta-block-item` element.

### Changelog

**New**

- `ButtonGroup` will not rendered if used inside a `cta-block-item` element

**Removed**
- buttons option in CTA type knob for `CTASection`

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
  • Loading branch information
IgnacioBecerra authored Dec 3, 2021
1 parent 800f951 commit 61ea69e
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class DDSCTABlockItem extends StableSelectorMixin(DDSContentItem) {
const { name } = target as HTMLSlotElement;
const hasContent = (target as HTMLSlotElement)
.assignedNodes()
.filter(elem => !(elem as HTMLElement).matches?.((this.constructor as typeof DDSCTABlockItem).selectorButtonGroup))
.some(node => node.nodeType !== Node.TEXT_NODE || node!.textContent!.trim());
this[slotExistencePropertyNames[name] || '_hasStatistic'] = hasContent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import DDSCTABlockItemRow from '@carbon/ibmdotcom-web-components/es/components-r
import DDSCTABlockItem from '@carbon/ibmdotcom-web-components/es/components-react/cta-block/cta-block-item';
import DDSContentItemHeading from '@carbon/ibmdotcom-web-components/es/components-react/content-item/content-item-heading';
import DDSContentItemCopy from '@carbon/ibmdotcom-web-components/es/components-react/content-item/content-item-copy';
import DDSButtonGroup from '@carbon/ibmdotcom-web-components/es/components-react/button-group/button-group';
import DDSButtonCTA from '@carbon/ibmdotcom-web-components/es/components-react/cta/button-cta';
import Desktop from '@carbon/pictograms-react/es/desktop/index.js';
import DDSVideoPlayerContainer from '@carbon/ibmdotcom-web-components/es/components-react/video-player/video-player-container';
import DDSLinkList from '@carbon/ibmdotcom-web-components/es/components-react/link-list/link-list';
Expand All @@ -49,16 +47,6 @@ const contentItemTypeMap = {
))}
</DDSCTABlockItem>
),
button: ({ heading, copy }) => (
<DDSCTABlockItem>
<DDSContentItemHeading>{heading}</DDSContentItemHeading>
<DDSContentItemCopy>{copy}</DDSContentItemCopy>
<DDSButtonGroup slot="footer">
<DDSButtonCTA>Button 1</DDSButtonCTA>
<DDSButtonCTA>Button 2</DDSButtonCTA>
</DDSButtonGroup>
</DDSCTABlockItem>
),
statistics: ({ heading, copy, links }) => (
<DDSCTABlockItem>
<span slot="statistics">10%</span>
Expand Down Expand Up @@ -115,7 +103,6 @@ const renderItems = (item, count) => {

const contentItemTypeOptions = {
Text: 'text',
Button: 'button',
Statistics: 'statistics',
Pictogram: 'pictogram',
Media: 'media',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ const contentItemTypeMap = {
)}
</dds-cta-block-item>
`,
button: ({ heading, copy }) => html`
<dds-cta-block-item>
<dds-content-item-heading>${heading}</dds-content-item-heading>
<dds-content-item-copy>${copy}</dds-content-item-copy>
<dds-button-group slot="footer">
<dds-button-cta>Button 1</dds-button-cta>
<dds-button-cta>Button 2</dds-button-cta>
</dds-button-group>
</dds-cta-block-item>
`,
statistics: ({ heading, copy, links }) => html`
<dds-cta-block-item>
<span slot="statistics">10%</span>
Expand Down Expand Up @@ -109,7 +99,6 @@ const contentItemTypeMap = {

const contentItemTypeOptions = {
Text: 'text',
Button: 'button',
Statistics: 'statistics',
Pictogram: 'pictogram',
Media: 'media',
Expand Down

0 comments on commit 61ea69e

Please sign in to comment.