Skip to content
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

(css): Allow injecting UserTheme and typecheck colors against scale #1090

Closed
wants to merge 97 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
77eb36e
(css): Allow injecting UserTheme and typecheck colors against scale
hasparus Jul 26, 2020
2b167e9
(css): typecheck colors scale from the theme
hasparus Jul 26, 2020
7b5f850
(css): Support CSS.Globals alongside scale keys
hasparus Jul 26, 2020
faeeb8b
(css): update older test
hasparus Jul 26, 2020
734a60e
(theme-ui): reexport UserTheme
hasparus Aug 11, 2020
af3f76e
(css): move scales to separate file to colocate them with types
hasparus Aug 11, 2020
f5b18d1
(css): Add ResponsiveStyleTuple<T> interface
hasparus Aug 12, 2020
d28935f
WIP
hasparus Aug 17, 2020
6cef68d
add opacities, space (no comments yet)
nandorojo Sep 30, 2020
3b464be
let overwrite CSS properties supercede alias types
nandorojo Oct 1, 2020
cd0f14f
add remaining scales, make types optional
nandorojo Oct 1, 2020
7be1f96
add borders, sizes
nandorojo Oct 1, 2020
ecd2e0b
exclude array types
nandorojo Oct 1, 2020
1ccc26b
Merge pull request #1 from nandorojo/nandorojo/injection
hasparus Oct 1, 2020
bc3c96c
Update TypeScript to 4.0.3
hasparus Oct 1, 2020
65c179d
Test exact theme scales
hasparus Oct 1, 2020
3222d50
Fix errors-and-inference test
hasparus Oct 1, 2020
679d532
Reexport scales
hasparus Oct 1, 2020
35c87a2
Merge pull request #2 from hasparus/inject-exact-theme-2
hasparus Oct 1, 2020
cb17f20
added border widths, radii
nandorojo Oct 12, 2020
2be06c8
border styles
nandorojo Oct 12, 2020
c79e5d5
add missing border properties
nandorojo Oct 12, 2020
9973caf
fonts
nandorojo Oct 12, 2020
d869762
font weights
nandorojo Oct 12, 2020
b91688f
line heights
nandorojo Oct 12, 2020
f5f037b
add shadows, letter spacings, & optional fields
nandorojo Oct 12, 2020
94b2a4c
z indices
nandorojo Oct 12, 2020
4ef19ec
Add JSDoc comments to scale properties
hasparus Oct 16, 2020
ac8a4b1
Test exact theme scales
hasparus Oct 1, 2020
71fe2f1
Add JSDoc comments to SizesCSSProperties and BordersCSSProperties
hasparus Oct 16, 2020
ad12ae2
Annotate scales
hasparus Oct 16, 2020
30d65d9
Update comment
hasparus Oct 16, 2020
f3813f8
Accept number as fontFamily value in TypographyProps.value
hasparus Oct 16, 2020
bd15798
Add DottedPaths and ts-toolbelt
hasparus Nov 23, 2020
37dd31a
Merge branch 'master' into inject-exact-theme
hasparus Nov 23, 2020
e758c29
feat(css): support deep scale paths
hasparus Nov 23, 2020
3ee1a84
ref(css): clean up OverwritesCSSProperties
hasparus Nov 23, 2020
a6e6d5d
fix(css): add missing builtins values to scales
hasparus Nov 24, 2020
83283c2
wip: push scales work in progress in case my laptop explodes
hasparus Nov 29, 2020
7f88e52
chore: move each scale to separate file
hasparus Nov 30, 2020
63699f7
fix: rework borders scale types
hasparus Nov 30, 2020
806e2da
fix: change "as any" to "as ThemeUICSSObject"
hasparus Nov 30, 2020
17fa683
ref: remove todo comment
hasparus Nov 30, 2020
10a010e
feat: export scale value types in Scales namespace
hasparus Nov 30, 2020
083f994
feat: rename Theme to BaseTheme and FinalTheme to Theme
hasparus Nov 30, 2020
46688c3
feat: do not pass false, undefined and null to Emotion
hasparus Nov 30, 2020
a82ba6c
Merge branch 'master' into inject-exact-theme
hasparus Nov 30, 2020
6603ab4
wip: change allowStrings to noStrings
hasparus Dec 1, 2020
eabdae8
Merge branch 'master' into inject-exact-theme
hasparus Dec 1, 2020
3246314
Merge branch 'master' into inject-exact-theme
hasparus Dec 2, 2020
b84aa48
Bump ts-snippet to 5.0.1
hasparus Dec 2, 2020
f03a104
Allow holes in scales -- accept null and undefined as scale value
hasparus Dec 2, 2020
acc904e
Export makeTheme from @theme-ui/css
hasparus Dec 2, 2020
f22c7f4
Add more type-level tests for exact themes
hasparus Dec 2, 2020
74b1dd3
Import CSSObject from @emotion/react
hasparus Dec 3, 2020
6f1a6bf
Move multiples and aliases to separate files
hasparus Dec 3, 2020
a4cf32b
Always allow numbers
hasparus Dec 3, 2020
512bcdc
Colocate multiples with scales
hasparus Dec 3, 2020
5bc9b11
Add missing number to sizes scale
hasparus Dec 3, 2020
b915028
Update typography snapshots ('border: 0' to 'border: none')
hasparus Dec 3, 2020
544c270
GitHub Actions, why aren't you running?
hasparus Dec 3, 2020
7031547
This is why DevOps folks get paid so much
hasparus Dec 3, 2020
902e626
fix(editor): Add null | false to accepted props
hasparus Dec 3, 2020
c0e966e
Update TypeScript to next, because our getTypeFacts bug was fixed 8 d…
hasparus Dec 3, 2020
337efd1
Microbundle, why?
hasparus Dec 3, 2020
bb5aa05
fix: workflow/ci.yml
hasparus Dec 7, 2020
a6ede7b
Merge branch 'develop' into inject-exact-theme
hasparus Dec 22, 2020
d34e0dc
chore: update deps
hasparus Dec 23, 2020
6f94730
Merge branch 'develop' into inject-exact-theme
hasparus Dec 23, 2020
72ba710
Merge branch 'develop' into inject-exact-theme
hasparus Feb 25, 2021
4477a1f
chore: run husky install
hasparus Feb 25, 2021
db67443
fix(css): update options.ts to use BaseTheme
hasparus Feb 25, 2021
4c1747c
fix(css): fix merge conflict induced type errors
hasparus Feb 28, 2021
e86faba
fix(css): add transitions scale missing from merge
hasparus Feb 28, 2021
6328eb6
test(css): adapt tests to match new types
hasparus Feb 28, 2021
d3696a9
chore(tooling): install auto
hasparus Feb 28, 2021
e7b2560
chore: install auto
hasparus Mar 1, 2021
e4a8f01
docs: add all-contributors
hasparus Mar 1, 2021
8ce5809
docs: add @jxnblk as a contributor
hasparus Mar 1, 2021
5d3cea5
docs: add contributors
hasparus Mar 1, 2021
be693ac
chore: add all-contributors:add script
hasparus Mar 1, 2021
e20fb66
chore: add @auto-it/all-contributors plugin
hasparus Mar 1, 2021
6f63f36
chore: add @auto-it/conventional-commits plugin
hasparus Mar 1, 2021
1ecd5ec
chore: add @auto-it/first-time-contributor plugin
hasparus Mar 1, 2021
71c0226
chore: add @auto-it/released plugin
hasparus Mar 1, 2021
9b55d9a
chore: configure auto prerelease branches
hasparus Mar 1, 2021
9d1a251
Merge branch 'chores' into inject-exact-theme
hasparus Mar 1, 2021
c6760d1
chore: publish with deps on exact versions
hasparus Mar 1, 2021
823bff1
chore: add verifyAccess: false to omit 2FA on CI
hasparus Mar 1, 2021
9dbb0de
ci: run release job on GitHub Actions
hasparus Mar 1, 2021
9b02eb8
Merge branch 'chores' into inject-exact-theme
hasparus Mar 1, 2021
0ef947c
Merge branch 'develop' into inject-exact-theme
hasparus Mar 1, 2021
c5a716a
Merge branch 'develop' into inject-exact-theme
hasparus Mar 1, 2021
df2c70a
chore: canary version
hasparus Mar 1, 2021
410ac76
Merge branch 'chores' into inject-exact-theme
hasparus Mar 1, 2021
df21470
wip(css): leave todo comment
hasparus Mar 16, 2021
67fa03d
Merge branch 'develop' into inject-exact-theme
hasparus May 22, 2021
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
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,10 @@ Theme UI is now written in TypeScript, and the emitted types differ from
`ThemeUIStyleObject` instead.
- Fix: Add `sx` props types to all props accepting `className`. PR #1308
- Fix WithPoorAsProp to work with ComponentProps utility type. PR #1308
- Don't pass `false`, `undefined` and `null` to Emotion. Allow them as style values in TypeScript. PR #1090
- Allow to inject user's exact theme type. PR #1090
- Add `theme.options.strictMode` object with configuration for Theme UI strict mode.
- TODO short excerpt from the docs on how to use it

## v0.5.0-alpha.2 2020-11-30

Expand Down
2 changes: 1 addition & 1 deletion examples/gatsby-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"devDependencies": {
"@testing-library/react": "^9.1.3",
"husky": ">=4.0.7",
"husky": ">=5.1.1",
"jest": "^24.8.0",
"lint-staged": "10",
"react-test-renderer": "^17.0.1"
Expand Down
9 changes: 9 additions & 0 deletions packages/color-modes/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The MIT License (MIT)

Copyright (c) 2019 Brent Jackson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 1 addition & 1 deletion packages/color-modes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
"devDependencies": {
"react": "^17.0.1"
},
"gitHead": "621199460fa3bdb0100748441e62517b7529b8c8"
"gitHead": "c5a716a2e214d8c3762f917a57418bb995fb4c9a"
}
2 changes: 1 addition & 1 deletion packages/color-modes/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function copyRawColors(
if (typeof value === 'string' && !value.startsWith('var(')) {
outerThemeRawColors[key] = value
}
if (typeof value === 'object') {
if (typeof value === 'object' && value) {
outerThemeRawColors[key] = {
...(outerThemeRawColors[key] as object),
...copyRawColors(value, {}),
Expand Down
9 changes: 9 additions & 0 deletions packages/color/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The MIT License (MIT)

Copyright (c) 2019 Brent Jackson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 1 addition & 1 deletion packages/color/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"access": "public"
},
"license": "MIT",
"gitHead": "621199460fa3bdb0100748441e62517b7529b8c8"
"gitHead": "c5a716a2e214d8c3762f917a57418bb995fb4c9a"
}
6 changes: 3 additions & 3 deletions packages/color/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as P from 'polished'
import { ColorModesScale, get, Theme } from '@theme-ui/css'
import { ColorModesScale, get, Theme, ThemeUIEmpty } from '@theme-ui/css'

type Color = ColorModesScale['primary']

/**
* Get color from theme.colors
*/
export const getColor = (theme: Theme, color: Color) => {
export const getColor = (theme: Theme, color: Color): string => {
if (typeof color === 'object') {
color = Array.isArray(color)
? color[0]
: (color as Exclude<typeof color, string & {}>).__default
: (color as Exclude<typeof color, string & {}>)?.__default
}

if (process.env.NODE_ENV !== 'production') {
Expand Down
9 changes: 9 additions & 0 deletions packages/components/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The MIT License (MIT)

Copyright (c) 2019 Brent Jackson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4 changes: 2 additions & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "@theme-ui/components",
"version": "0.8.4",
"author": "Brent Jackson <jxnblk@gmail.com>",
"license": "MIT",
"main": "dist/theme-ui-components.cjs.js",
"module": "dist/theme-ui-components.esm.js",
"types": "index.d.ts",
Expand All @@ -21,8 +23,6 @@
"publishConfig": {
"access": "public"
},
"author": "Brent Jackson <jxnblk@gmail.com>",
"license": "MIT",
"devDependencies": {
"react": "^17.0.1"
}
Expand Down
9 changes: 9 additions & 0 deletions packages/core/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The MIT License (MIT)

Copyright (c) 2019 Brent Jackson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 2 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export type {
ThemeUIExtendedCSSProperties,
ThemeUIStyleObject,
VariantProperty,
BaseTheme,
UserTheme,
} from '@theme-ui/css'

export * from './types'
Expand Down
9 changes: 9 additions & 0 deletions packages/css/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The MIT License (MIT)

Copyright (c) 2019 Brent Jackson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 2 additions & 0 deletions packages/css/emotion-theme.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import '@emotion/react'

import { Theme } from '@theme-ui/css'

// TODO: This file is not include in user's project anyway.
// Consider removing it and advising to inject their exact theme into Emotion.
interface ThemeUITheme extends Theme {}

declare module '@emotion/react' {
Expand Down
5 changes: 3 additions & 2 deletions packages/css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
},
"dependencies": {
"@emotion/react": "^11.1.1",
"csstype": "^3.0.5"
"csstype": "^3.0.5",
"ts-toolbelt": "^8.0.7"
},
"gitHead": "621199460fa3bdb0100748441e62517b7529b8c8"
"gitHead": "c5a716a2e214d8c3762f917a57418bb995fb4c9a"
}
Loading