Skip to content

fix(sx): support Primer colors for border*Color properties #3619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions .changeset/angry-boats-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@primer/react': patch
---

Include `border*Color` properties in sx to support named Primer colors

<!-- Changed components: _none_ -->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I think _all_ might have been the better option. If you agree and see that happening frequently let me know and I'll add the option to the changesets CLI

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a few PRs that I thought "all" would make more sense but some were a bit vague 🤔 Similar to this case like it does affect almost all components but it doesn't really feel a component change to me maybe more of a system change that can be communicated with a different keyword? Curious to hear what you think!

4 changes: 3 additions & 1 deletion src/sx.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import css, {SystemCssProperties, SystemStyleObject} from '@styled-system/css'
import {ThemeColorPaths, ThemeShadowPaths} from './theme'
import {ColorProps, ShadowProps} from 'styled-system'
import {ColorProps, BorderColorProps, ShadowProps} from 'styled-system'
import merge from 'deepmerge'

export type BetterCssProperties = {
[K in keyof SystemCssProperties]: K extends keyof ColorProps
? ThemeColorPaths | SystemCssProperties[K]
: K extends keyof BorderColorProps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gr2m I know this is late, but I wonder if there's some tests we can use to ensure these don't regress, or to ensure they're fully expressive of options that work, and don't include options that don't work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a type-only change. Do you write tests for these with something like tsd?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I feel if we added tests, we would only test behavior of styled-system?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are some other type-tests in the repo. I think since we're exposing a type that used in many places, it would be good to have some way to validate it, and ensure it's inclusive of all possible options.

I don't think tsd is used in the repo, but might be valuable to add something like it for type only assertions?

right now I think most type tests just ensure functions compile correctly - there's a bunch of files with .types.test suffixes where we do type only tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay cheers I'll send a follow up pull request, but can't say when I get to it

? ThemeColorPaths | SystemCssProperties[K]
: K extends keyof ShadowProps
? ThemeShadowPaths | SystemCssProperties[K]
Expand Down