Skip to content

Commit b2e0efd

Browse files
siddharthkpCopilot
andauthored
Mark useResponsiveValue as deprecated (#7760)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 9e3fe4b commit b2e0efd

7 files changed

Lines changed: 75 additions & 1 deletion

File tree

.changeset/cold-lions-listen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': minor
3+
---
4+
5+
Deprecate the `useResponsiveValue` hook.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: deprecations
3+
description: 'Use when: deprecating Primer React components or hooks. Covers source annotations, docs metadata, changesets, docs page updates, and validation for deprecations.'
4+
---
5+
6+
# Deprecating components and hooks in Primer React
7+
8+
Use this skill when a task involves marking a public Primer React API as deprecated.
9+
10+
## What to update
11+
12+
### Source code
13+
14+
- Add a JSDoc `@deprecated` annotation to the exported component, hook, prop, or type following existing patterns nearby.
15+
- Keep runtime behavior unchanged unless the task explicitly requires more than deprecation signaling.
16+
17+
### Docs metadata
18+
19+
- For components, mark the relevant `*.docs.json` file with `"status": "deprecated"`.
20+
- For hooks, mark the relevant `*.hookDocs.json` file with `"status": "deprecated"`.
21+
- If schema or build tooling does not yet support the docs metadata you need, update the corresponding schema/build files in `packages/react/script/*-json/`.
22+
23+
### Documentation content
24+
25+
- If the deprecated component has a docs page or JSON-backed docs content that supports deprecation guidance, add or update the deprecation guidance and recommended alternative.
26+
- Follow `contributor-docs/deprecating-components.md`.
27+
28+
### Versioning
29+
30+
- Add a changeset for public API deprecations.
31+
- Use the versioning guidance in `contributor-docs/versioning.md` to choose the correct bump.
32+
33+
## Validation
34+
35+
Prefer targeted validation first, then broader validation if needed:
36+
37+
- Format changed files with `npx prettier --write <paths>`
38+
- Lint changed TypeScript files with `npx eslint --fix <paths>`
39+
- Rebuild generated docs metadata when related schema or docs JSON changes:
40+
41+
```bash
42+
npm run build:hooks.json -w @primer/react
43+
```
44+
45+
```bash
46+
npm run build:components.json -w @primer/react
47+
```
48+
49+
- Run targeted tests for the affected API when available
50+
- Run broader repository validation before finalizing if the change touches shared build tooling
51+
52+
## Common files
53+
54+
- `packages/react/src/**/*.docs.json`
55+
- `packages/react/src/**/*.hookDocs.json`
56+
- `packages/react/script/components-json/*`
57+
- `packages/react/script/hooks-json/*`
58+
- `contributor-docs/deprecating-components.md`
59+
- `.changeset/*.md`

contributor-docs/deprecating-components.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ When Primer maintainers are to deprecate a component, they will issue `@deprecat
1111
Issuing a `@deprecated` notice in a minor/patch release includes:
1212

1313
- [ ] Adding a `@deprecated` annotation in the component's source code.
14-
- [ ] Adding a `Deprecation` section to the documentation of the component with the link of the recommended component and provide a diff. See [deprecated ActionList docs](https://primer.style/react/deprecated/ActionList#deprecation) as an example.
14+
- [ ] Marking the component or hook docs metadata as deprecated with `"status": "deprecated"` in the relevant `*.docs.json` or `*.hookDocs.json` file.
15+
- [ ] If the component has a docs page, adding a `Deprecation` section to the documentation with the link of the recommended component and provide a diff. See [deprecated ActionList docs](https://primer.style/react/deprecated/ActionList#deprecation) as an example.
1516

1617
## Developing a replacement component
1718

packages/react/script/hooks-json/build.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Ajv from 'ajv'
88
// Only includes fields we use in this script
99
type Hook = {
1010
name: string
11+
status?: 'deprecated'
1112
importPath: '@primer/react' | '@primer/react/experimental'
1213
stories: Array<{id: string}>
1314
}

packages/react/script/hooks-json/hook.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@
7878
"type": "string",
7979
"description": "The name of the hook."
8080
},
81+
"status": {
82+
"type": "string",
83+
"enum": ["ready", "deprecated"],
84+
"description": "The status of the hook."
85+
},
8186
"importPath": {
8287
"type": "string",
8388
"description": "The path to import the hook from. i.e. '@primer/react/experimental'"

packages/react/src/hooks/useResponsiveValue.hookDocs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "useResponsiveValue",
3+
"status": "deprecated",
34
"importPath": "@primer/react",
45
"stories": [],
56
"parameters": [

packages/react/src/hooks/useResponsiveValue.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export function isResponsiveValue(value: any): value is ResponsiveValue<any> {
4141
* Resolves responsive values based on the current viewport width.
4242
* For example, if the current viewport width is narrow (less than 768px), the value of `{regular: 'foo', narrow: 'bar'}` will resolve to `'bar'`.
4343
*
44+
* @deprecated Prefer responsive data attributes with `getResponsiveAttributes` and CSS media queries instead.
45+
*
4446
* @example
4547
* const value = useResponsiveValue({regular: 'foo', narrow: 'bar'})
4648
* console.log(value) // 'bar'

0 commit comments

Comments
 (0)