Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
6 changes: 6 additions & 0 deletions .changeset/soft-banners-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@primer/react-brand': patch
---

- Restored rounded corners to `CTABanner` while preserving square edges when grid lines are enabled.
- Improved `ButtonGroup` to forward custom class names alongside its default styles.
15 changes: 14 additions & 1 deletion packages/react/src/ButtonGroup/ButtonGroup.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {render, cleanup} from '@testing-library/react'
import {render, cleanup} from '@testing-library/react'
import '@testing-library/jest-dom'

import {ButtonGroup} from './ButtonGroup'
Expand Down Expand Up @@ -26,6 +26,19 @@ describe('ButtonGroup', () => {
expect(buttonGroupEl.classList).toContain(expectedClass)
})

it('forwards a custom className alongside the default class', () => {
const {getByTestId} = render(
<ButtonGroup data-testid="test" className="custom-button-group">
<Button>Primary Action</Button>
<Button>Secondary Action</Button>
</ButtonGroup>,
)

const buttonGroupEl = getByTestId('test')
expect(buttonGroupEl).toHaveClass('ButtonGroup')
expect(buttonGroupEl).toHaveClass('custom-button-group')
})

it('renders buttons with the correct element type when buttonAs is set', () => {
const expectedTag = 'a'

Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/ButtonGroup/ButtonGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {forwardRef, type Ref} from 'react'
import {clsx} from 'clsx'
import type {BaseProps} from '../component-helpers'
import {Button, ButtonProps} from '../Button'
import styles from './ButtonGroup.module.css'
Expand Down Expand Up @@ -29,7 +30,7 @@ export const ButtonGroup = forwardRef(
.slice(0, 2)

return (
<section ref={ref} className={styles.ButtonGroup} {...props}>
<section ref={ref} {...props} className={clsx(styles.ButtonGroup, className)}>
{buttonsToRender as React.ReactElement[]}
</section>
)
Expand Down
11 changes: 8 additions & 3 deletions packages/react/src/CTABanner/CTABanner.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
box-sizing: border-box;
}

.CTABanner-container--rounded {
border-radius: var(--brand-borderRadius-xlarge);
Comment thread
danielguillan marked this conversation as resolved.
Outdated
}

.CTABanner--variant-balanced .CTABanner-container {
padding-inline: var(--base-size-20);
padding-block: var(--base-size-32);
Expand Down Expand Up @@ -170,9 +174,6 @@

/* Large breakpoint and up */
@media screen and (min-width: 63.25rem) {
.CTABanner-content {
gap: var(--base-size-24);
}
.CTABanner--variant-balanced .CTABanner-content {
gap: var(--base-size-32);
}
Expand Down Expand Up @@ -311,3 +312,7 @@
.CTABanner-description.CTABanner-description:has(code) {
line-height: calc(1lh * 1.25);
}

.CTABanner-buttonGroup {
padding-block-start: var(--base-size-12);
}
2 changes: 2 additions & 0 deletions packages/react/src/CTABanner/CTABanner.module.css.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ declare const styles: {
readonly "CTABanner--variant-balanced": string;
readonly "CTABanner--variant-default": string;
readonly "CTABanner--variant-minimal": string;
readonly "CTABanner-buttonGroup": string;
readonly "CTABanner-container": string;
readonly "CTABanner-container--background": string;
readonly "CTABanner-container--border": string;
readonly "CTABanner-container--border-gridlines": string;
readonly "CTABanner-container--rounded": string;
readonly "CTABanner-content": string;
readonly "CTABanner-content--center": string;
readonly "CTABanner-description": string;
Expand Down
20 changes: 20 additions & 0 deletions packages/react/src/CTABanner/CTABanner.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,25 @@ describe('CTABanner', () => {
expect(ctaBannerEl).toHaveClass('CTABanner--variant-minimal')
})

it.each(['default', 'balanced', 'minimal'] as const)(
'applies rounded corners to the %s variant by default',
variant => {
const {getByTestId} = render(
<CTABanner variant={variant} data-testid="test">
<CTABanner.Heading>This is your heading</CTABanner.Heading>
{variant === 'balanced' && <CTABanner.Image src="image.png" alt="test" />}
{variant === 'minimal' && (
<CTABanner.ButtonGroup>
<Button>Action</Button>
</CTABanner.ButtonGroup>
)}
</CTABanner>,
)

expect(getByTestId('test').firstChild).toHaveClass('CTABanner-container--rounded')
},
)

it('can render CTABanner.Image in the default variant alongside other children', () => {
const {getByAltText} = render(
<CTABanner>
Expand Down Expand Up @@ -383,6 +402,7 @@ describe('CTABanner', () => {
const sectionEl = getByTestId('test')
expect(sectionEl.parentElement).toHaveClass('CTABanner-outer-container--border')
expect(sectionEl.firstChild).toHaveClass('CTABanner-container--border-gridlines')
expect(sectionEl.firstChild).not.toHaveClass('CTABanner-container--rounded')
})

it('does not render the hasGridLines outer border wrapper by default', () => {
Expand Down
9 changes: 8 additions & 1 deletion packages/react/src/CTABanner/CTABanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ const Root = forwardRef(
styles['CTABanner-container'],
hasBorder && styles['CTABanner-container--border'],
hasGridLines && styles['CTABanner-container--border-gridlines'],
!hasGridLines && styles['CTABanner-container--rounded'],
hasBackground && styles['CTABanner-container--background'],
)}
>
Expand Down Expand Up @@ -319,7 +320,13 @@ const _ButtonGroup = forwardRef(
ref: Ref<HTMLDivElement>,
) => {
return (
<ButtonGroup buttonSize={buttonSize} buttonsAs={buttonsAs} className={className} ref={ref} {...props}>
<ButtonGroup
buttonSize={buttonSize}
buttonsAs={buttonsAs}
className={clsx(styles['CTABanner-buttonGroup'], className)}
ref={ref}
{...props}
>
{children}
</ButtonGroup>
)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Comment thread
danielguillan marked this conversation as resolved.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading