Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: primer/react
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @primer/react@37.13.0
Choose a base ref
...
head repository: primer/react
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @primer/react@37.14.0
Choose a head ref
  • 10 commits
  • 38 files changed
  • 8 contributors

Commits on Feb 13, 2025

  1. Blankslate: Add button support to PrimaryAction (#5687)

    * Add button support to `PrimaryAction` in `BlankSlate`
    
    * Improve story, spread props, fix types
    
    * Add changeset
    
    * Small typo
    
    * Change types
    
    * Update packages/react/src/Blankslate/Blankslate.tsx
    
    Co-authored-by: Josh Black <joshblack@github.com>
    
    * Update packages/react/src/Blankslate/Blankslate.tsx
    
    ---------
    
    Co-authored-by: Josh Black <joshblack@github.com>
    TylerJDev and joshblack authored Feb 13, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2bbc5a0 View commit details
  2. Add noTitle to all stories, add new stories (#5685)

    TylerJDev authored Feb 13, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9318734 View commit details
  3. chore(UnderlinePanels): Adding the option to pass in className (#5686)

    * chore(UnderlinePanels): Adding the option to pass in className
    
    * Create fifty-deers-applaud.md
    jonrohan authored Feb 13, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    64f183b View commit details
  4. Add preventOverflow prop to ActionMenu example; add newline to do…

    …cs for `Overlay` (#5654)
    TylerJDev authored Feb 13, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    102b523 View commit details
  5. SubNav: Add aria-current to SubNav (#5661)

    * Add `aria-current` to `SubNav`
    
    * Add changeset
    
    * Update snapshot
    TylerJDev authored Feb 13, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1262f5a View commit details

Commits on Feb 14, 2025

  1. Fix LinkButton types (#5655)

    * Fix LinkButton and ButtonBase Typescript types
    
    * Use LinkButton in LinkButton stories
    
    * Add changeset
    
    * Remove export
    hectahertz authored Feb 14, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    56baa0a View commit details
  2. chore(Header): Remove CSS modules feature flag from Header (#5510)

    * Remove CSS modules feature flag from Header
    
    * Adjust Header for as prop
    
    * Create shaggy-comics-whisper.md
    
    * Remove FeatureFlagElement from Header tests
    
    * Remove unused FeatureFlags import in Header test
    jonrohan authored Feb 14, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    37a91b5 View commit details
  3. fix(SelectPanel): Correctly recalculate position on overflow (#5562)

    * wip: SelectPanel overflow
    
    * fix(useAnchoredPosition): refine reposition logic
    
    * Create silent-cameras-care.md
    
    * fix: lint
    
    * test(AnchoredOverlay): update snapshot
    
    * reorganize stories
    
    * fix(Overlay): add default max height
    
    * fix(SelectPanel): revert preventOverflow changes
    
    * test(vrt): update snapshots
    
    * Revert "test(vrt): update snapshots"
    
    This reverts commit 9a0fb5a.
    
    * test(vrt): update snapshots
    
    * fix(useResizeObserver): SSR compatibility
    
    * Revert "test(vrt): update snapshots"
    
    This reverts commit 08a9f9c.
    
    * test(vrt): update snapshots
    
    * fix(SelectPanel): fix flashing race condition and cleanup code
    
    * docs(AnchoredOverlay): document new pinPosition pro
    
    * fix tests
    
    * fix tests
    
    * fix tests
    
    * test(vrt): update snapshots
    
    * Revert "test(vrt): update snapshots"
    
    This reverts commit 8c1e8cf.
    
    * remove test code
    
    ---------
    
    Co-authored-by: francinelucca <francinelucca@users.noreply.github.com>
    francinelucca and francinelucca authored Feb 14, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    947b59d View commit details

Commits on Feb 19, 2025

  1. bugfix(SelectPanel): Set border-top-color on selectpanel footer (#5712)

    * Set border-top-color on selectpanel footer
    
    * Create clean-planets-sleep.md
    jonrohan authored Feb 19, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    22508b7 View commit details

Commits on Feb 21, 2025

  1. Version Packages (#5694)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    primer[bot] and github-actions[bot] authored Feb 21, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    3c45251 View commit details
Showing with 527 additions and 232 deletions.
  1. BIN ...ight/snapshots/components/Overlay.test.ts-snapshots/Overlay-SX-Props-dark-high-contrast-linux.png
  2. BIN ...ght/snapshots/components/Overlay.test.ts-snapshots/Overlay-SX-Props-light-high-contrast-linux.png
  3. +1 −1 examples/codesandbox/package.json
  4. +1 −1 examples/nextjs/package.json
  5. +1 −1 examples/theming/package.json
  6. +20 −0 packages/react/CHANGELOG.md
  7. +1 −1 packages/react/package.json
  8. +1 −1 packages/react/src/ActionMenu/ActionMenu.examples.stories.tsx
  9. +110 −0 packages/react/src/AnchoredOverlay/AnchoredOverlay.dev.stories.tsx
  10. +6 −0 packages/react/src/AnchoredOverlay/AnchoredOverlay.docs.json
  11. +7 −1 packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx
  12. +6 −2 packages/react/src/Blankslate/Blankslate.docs.json
  13. +31 −1 packages/react/src/Blankslate/Blankslate.features.stories.tsx
  14. +11 −6 packages/react/src/Blankslate/Blankslate.tsx
  15. +0 −3 packages/react/src/Button/ButtonBase.tsx
  16. +30 −30 packages/react/src/Button/LinkButton.features.stories.tsx
  17. +5 −13 packages/react/src/Button/LinkButton.stories.tsx
  18. +3 −10 packages/react/src/Button/LinkButton.tsx
  19. +1 −2 packages/react/src/Button/index.ts
  20. +46 −104 packages/react/src/Header/Header.tsx
  21. +1 −1 packages/react/src/Overlay/Overlay.docs.json
  22. +1 −0 packages/react/src/Overlay/Overlay.module.css
  23. +1 −1 packages/react/src/Overlay/Overlay.tsx
  24. +42 −1 packages/react/src/RelativeTime/RelativeTime.examples.stories.tsx
  25. +3 −3 packages/react/src/RelativeTime/RelativeTime.features.stories.tsx
  26. +1 −1 packages/react/src/RelativeTime/RelativeTime.stories.tsx
  27. +95 −0 packages/react/src/SelectPanel/SelectPanel.examples.stories.tsx
  28. +1 −1 packages/react/src/SelectPanel/SelectPanel.module.css
  29. +5 −2 packages/react/src/SelectPanel/SelectPanel.tsx
  30. +1 −0 packages/react/src/SubNav/SubNav.tsx
  31. +1 −41 packages/react/src/__tests__/Header.test.tsx
  32. +16 −0 packages/react/src/__tests__/SubNav.test.tsx
  33. +1 −0 packages/react/src/__tests__/__snapshots__/AnchoredOverlay.test.tsx.snap
  34. +1 −0 packages/react/src/__tests__/__snapshots__/SubNavLink.test.tsx.snap
  35. +25 −0 packages/react/src/experimental/UnderlinePanels/UnderlinePanels.test.tsx
  36. +8 −1 packages/react/src/experimental/UnderlinePanels/UnderlinePanels.tsx
  37. +42 −2 packages/react/src/hooks/useAnchoredPosition.ts
  38. +1 −1 packages/react/src/hooks/useResizeObserver.ts
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.
2 changes: 1 addition & 1 deletion examples/codesandbox/package.json
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.3.1",
"@vitejs/plugin-react": "^4.3.3",
"@primer/react": "37.13.0",
"@primer/react": "37.14.0",
"eslint": "^8.56.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.18",
2 changes: 1 addition & 1 deletion examples/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@primer/react": "37.13.0",
"@primer/react": "37.14.0",
"next": "^15.1.4",
"react": "^19.0.0",
"react-dom": "^19.0.0",
2 changes: 1 addition & 1 deletion examples/theming/package.json
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
},
"dependencies": {
"@primer/octicons-react": "^19.14.0",
"@primer/react": "37.13.0",
"@primer/react": "37.14.0",
"clsx": "^1.2.1",
"next": "^14.2.15",
"react": "^18.3.1",
20 changes: 20 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# @primer/react

## 37.14.0

### Minor Changes

- [#5687](https://github.com/primer/react/pull/5687) [`2bbc5a0`](https://github.com/primer/react/commit/2bbc5a036bc5e57d25aa559e88b16a6063e27646) Thanks [@TylerJDev](https://github.com/TylerJDev)! - Blankslate: Add support for button in `Blankslate.PrimaryAction`

- [#5510](https://github.com/primer/react/pull/5510) [`37a91b5`](https://github.com/primer/react/commit/37a91b51569bc4be92c6994ec6fe433584328911) Thanks [@jonrohan](https://github.com/jonrohan)! - Remove CSS modules feature flag from Header

### Patch Changes

- [#5712](https://github.com/primer/react/pull/5712) [`22508b7`](https://github.com/primer/react/commit/22508b7ceb10638d983c68a800d691aed812d724) Thanks [@jonrohan](https://github.com/jonrohan)! - bugfix(SelectPanel): Set border-top-color on selectpanel footer

- [#5686](https://github.com/primer/react/pull/5686) [`64f183b`](https://github.com/primer/react/commit/64f183bb028cd1072af2c7e2892ad21bdadf882c) Thanks [@jonrohan](https://github.com/jonrohan)! - The `UnderlinePanels` component wasn't supporting passing in `className`. Adding to the prop list

- [#5661](https://github.com/primer/react/pull/5661) [`1262f5a`](https://github.com/primer/react/commit/1262f5affa84330c917b964fa0cd8d907b398afc) Thanks [@TylerJDev](https://github.com/TylerJDev)! - SubNav: Adds `aria-current` to selected links

- [#5562](https://github.com/primer/react/pull/5562) [`947b59d`](https://github.com/primer/react/commit/947b59d43079003f5be6eea60b7dc2025fb21a4e) Thanks [@francinelucca](https://github.com/francinelucca)! - fix(SelectPanel): Correctly recalculate position on overflow

- [#5655](https://github.com/primer/react/pull/5655) [`56baa0a`](https://github.com/primer/react/commit/56baa0a791ba8a714fec28e3794e471358ddfde3) Thanks [@hectahertz](https://github.com/hectahertz)! - Fix LinkButton types and stories

## 37.13.0

### Minor Changes
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@primer/react",
"version": "37.13.0",
"version": "37.14.0",
"description": "An implementation of GitHub's Primer Design System using React",
"main": "lib/index.js",
"module": "lib-esm/index.js",
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ export const CustomOverlayProps = () => {
<Box sx={{display: 'flex', justifyContent: 'center'}}>
<ActionMenu open={open} onOpenChange={setOpen}>
<ActionMenu.Button>Menu</ActionMenu.Button>
<ActionMenu.Overlay width="large" align="center">
<ActionMenu.Overlay width="large" align="center" preventOverflow={false}>
<ActionList>
<ActionList.Item>Option 1</ActionList.Item>
<ActionList.Item>Option 2</ActionList.Item>
110 changes: 110 additions & 0 deletions packages/react/src/AnchoredOverlay/AnchoredOverlay.dev.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import type {Meta} from '@storybook/react'
import React, {useState} from 'react'

import {Button} from '../Button'
import {AnchoredOverlay} from '.'
import {Stack} from '../Stack'
import {Dialog, Spinner} from '..'

const meta = {
title: 'Components/AnchoredOverlay/Dev',
component: AnchoredOverlay,
} satisfies Meta<typeof AnchoredOverlay>

export default meta

export const RepositionAfterContentGrows = () => {
const [open, setOpen] = useState(false)

const [loading, setLoading] = useState(true)

React.useEffect(() => {
window.setTimeout(() => {
if (open) setLoading(false)
}, 2000)
}, [open])

return (
<Stack direction="vertical" justify="space-between" style={{height: 'calc(100vh - 200px)'}}>
<div>
What to expect:
<ul>
<li>The anchored overlay should open below the anchor (default position)</li>
<li>After 2000ms, the amount of content in the overlay grows</li>
<li>the overlay should reposition itself above the anchor so that it stays inside the window</li>
</ul>
</div>
<AnchoredOverlay
renderAnchor={props => (
<Button {...props} sx={{width: 'fit-content'}}>
Button
</Button>
)}
open={open}
onOpen={() => setOpen(true)}
onClose={() => {
setOpen(false)
setLoading(true)
}}
>
{loading ? (
<>
<Spinner />
loading for 2000ms
</>
) : (
<div style={{height: '300px'}}>content with 300px height</div>
)}
</AnchoredOverlay>
</Stack>
)
}

export const RepositionAfterContentGrowsWithinDialog = () => {
const [open, setOpen] = useState(false)

const [loading, setLoading] = useState(true)

React.useEffect(() => {
window.setTimeout(() => {
if (open) setLoading(false)
}, 2000)
}, [open])

return (
<Dialog onClose={() => {}}>
<Stack direction="vertical" justify="space-between" style={{height: 'calc(100vh - 300px)'}}>
<div>
What to expect:
<ul>
<li>The anchored overlay should open below the anchor (default position)</li>
<li>After 2000ms, the amount of content in the overlay grows</li>
<li>the overlay should reposition itself above the anchor so that it stays inside the window</li>
</ul>
</div>
<AnchoredOverlay
renderAnchor={props => (
<Button {...props} sx={{width: 'fit-content'}}>
Button
</Button>
)}
open={open}
onOpen={() => setOpen(true)}
onClose={() => {
setOpen(false)
setLoading(true)
}}
>
{loading ? (
<>
<Spinner />
loading for 2000ms
</>
) : (
<div style={{height: '300px'}}>content with 300px height</div>
)}
</AnchoredOverlay>
</Stack>
</Dialog>
)
}
6 changes: 6 additions & 0 deletions packages/react/src/AnchoredOverlay/AnchoredOverlay.docs.json
Original file line number Diff line number Diff line change
@@ -147,6 +147,12 @@
"required": false,
"description": "",
"defaultValue": ""
}, {
"name": "pinPosition",
"type": "boolean",
"required": false,
"description": "If true, the overlay will attempt to prevent position shifting when sitting at the top of the anchor.",
"defaultValue": "false"
}
]
}
8 changes: 7 additions & 1 deletion packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx
Original file line number Diff line number Diff line change
@@ -89,6 +89,10 @@ interface AnchoredOverlayBaseProps extends Pick<OverlayProps, 'height' | 'width'
* If `preventOverflow` is `true`, the width of the `Overlay` will not be adjusted.
*/
preventOverflow?: boolean
/**
* If true, the overlay will attempt to prevent position shifting when sitting at the top of the anchor.
*/
pinPosition?: boolean
}

export type AnchoredOverlayProps = AnchoredOverlayBaseProps &
@@ -112,11 +116,12 @@ export const AnchoredOverlay: React.FC<React.PropsWithChildren<AnchoredOverlayPr
overlayProps,
focusTrapSettings,
focusZoneSettings,
side = 'outside-bottom',
side = overlayProps?.['anchorSide'] || 'outside-bottom',
align = 'start',
alignmentOffset,
anchorOffset,
className,
pinPosition,
preventOverflow = true,
}) => {
const anchorRef = useProvidedRefOrCreate(externalAnchorRef)
@@ -155,6 +160,7 @@ export const AnchoredOverlay: React.FC<React.PropsWithChildren<AnchoredOverlayPr
{
anchorElementRef: anchorRef,
floatingElementRef: overlayRef,
pinPosition,
side,
align,
alignmentOffset,
8 changes: 6 additions & 2 deletions packages/react/src/Blankslate/Blankslate.docs.json
Original file line number Diff line number Diff line change
@@ -11,7 +11,10 @@
"id": "experimental-components-blankslate-features--with-visual"
},
{
"id": "experimental-components-blankslate-features--with-primary-action"
"id": "experimental-components-blankslate-features--with-primary-action-as-link"
},
{
"id": "experimental-components-blankslate-features--with-primary-action-as-button"
},
{
"id": "experimental-components-blankslate-features--with-secondary-action"
@@ -74,7 +77,8 @@
{
"name": "href",
"type": "string",
"description": "Link to complete primary action"
"required": false,
"description": "Link to complete primary action. If defined, will render as an anchor instead of a button."
}
]
},
32 changes: 31 additions & 1 deletion packages/react/src/Blankslate/Blankslate.features.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {BookIcon} from '@primer/octicons-react'
import React from 'react'
import {Blankslate} from '../Blankslate'
import {ConfirmationDialog} from '../ConfirmationDialog/ConfirmationDialog'

export default {
title: 'Experimental/Components/Blankslate/Features',
@@ -24,7 +25,7 @@ export const WithVisual = () => (
</Blankslate>
)

export const WithPrimaryAction = () => (
export const WithPrimaryActionAsLink = () => (
<Blankslate>
<Blankslate.Visual>
<BookIcon size="medium" />
@@ -35,6 +36,35 @@ export const WithPrimaryAction = () => (
</Blankslate>
)

export const WithPrimaryActionAsButton = () => {
const [isOpen, setIsOpen] = React.useState(false)
const onDialogClose = React.useCallback(() => setIsOpen(false), [])

return (
<>
<Blankslate>
<Blankslate.Visual>
<BookIcon size="medium" />
</Blankslate.Visual>
<Blankslate.Heading>Blankslate heading</Blankslate.Heading>
<Blankslate.Description>Use it to provide information when no dynamic content exists.</Blankslate.Description>
<Blankslate.PrimaryAction onClick={() => setIsOpen(true)}>Primary action</Blankslate.PrimaryAction>
</Blankslate>
{isOpen ? (
<ConfirmationDialog
title="Delete universe?"
onClose={onDialogClose}
confirmButtonContent="Delete it!"
confirmButtonType="danger"
>
Deleting the universe could have disastrous effects, including but not limited to destroying all life on
Earth.
</ConfirmationDialog>
) : null}
</>
)
}

export const WithSecondaryAction = () => (
<Blankslate>
<Blankslate.Visual>
17 changes: 11 additions & 6 deletions packages/react/src/Blankslate/Blankslate.tsx
Original file line number Diff line number Diff line change
@@ -58,14 +58,19 @@ function Description({children}: DescriptionProps) {
return <p className={clsx('Blankslate-Description', classes.Description)}>{children}</p>
}

export type PrimaryActionProps = React.PropsWithChildren<{
href: string
}>

function PrimaryAction({children, href}: PrimaryActionProps) {
export type PrimaryActionProps =
| (React.PropsWithChildren<{
href?: never
}> &
React.ComponentPropsWithoutRef<'button'>)
| React.PropsWithChildren<{
href: string
}>

function PrimaryAction({children, href, ...props}: PrimaryActionProps) {
return (
<div className={clsx('Blankslate-Action', classes.Action)}>
<Button as="a" href={href} variant="primary">
<Button {...props} as={href ? 'a' : 'button'} href={href} variant="primary">
{children}
</Button>
</div>
3 changes: 0 additions & 3 deletions packages/react/src/Button/ButtonBase.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type {ComponentPropsWithRef} from 'react'
import React, {forwardRef} from 'react'
import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'
import Box from '../Box'
@@ -320,6 +319,4 @@ const ButtonBase = forwardRef(
},
) as PolymorphicForwardRefComponent<'button' | 'a', ButtonProps>

export type ButtonBaseProps = ComponentPropsWithRef<typeof ButtonBase>

export {ButtonBase}
Loading