Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Working on CSS type shape * got it working! * omg fixed the keyof issue * maybe broke things, but got the csstype suggestion working... may need to revert * fix some things * fix some bugs, things seem to work * clean up types and demos * clean up examples * some more clean-up * v0.19.0-0 * fix type issue with array token scales * v0.19.0-1 * switch and to or * v0.19.0-2 * fix css function types * v0.19.0-3 * fix system return types incompatible with styled-components * v0.19.0-4 * save work * save work * clean up types * Revert "clean up types" This reverts commit 50c4b89. * remove commented code * fix more type issues * v0.19.0-5 * small cleanup * clean up
- Loading branch information
1 parent
2244920
commit 24588be
Showing
28 changed files
with
2,435 additions
and
4,653 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": ['babel-plugin-styled-components'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
node_modules | ||
.cache | ||
.DS_Store | ||
dist | ||
dist-ssr | ||
*.local |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
{ | ||
"name": "example", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"name": "styled-components-vite", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"start": "parcel index.html", | ||
"build": "parcel build index.html", | ||
"lint": "tsc" | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"serve": "vite preview" | ||
}, | ||
"dependencies": { | ||
"react": "^16", | ||
"react-dom": "^16", | ||
"react-is": "^16", | ||
"styled-components": "^5", | ||
"system-props": "latest" | ||
"react": "^17.0.0", | ||
"react-dom": "^17.0.0", | ||
"styled-components": "^5.2.1", | ||
"system-props": "^0.18.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^16", | ||
"@types/react-dom": "^16", | ||
"@types/styled-components": "^5.1.4", | ||
"csstype": "^3.0.5", | ||
"parcel": "^1.12.3", | ||
"typescript": "^4.1.0" | ||
"@types/react": "^17.0.0", | ||
"@types/react-dom": "^17.0.0", | ||
"@types/styled-components": "^5.1.9", | ||
"@vitejs/plugin-react-refresh": "^1.3.1", | ||
"csstype": "^3.0.7", | ||
"typescript": "^4.1.2", | ||
"vite": "^2.1.0", | ||
"vite-babel-plugin": "^0.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { ReactNode } from 'react'; | ||
import { | ||
createSystem, | ||
color, | ||
border, | ||
space, | ||
layout, | ||
position, | ||
shadow, | ||
background, | ||
flexbox, | ||
grid, | ||
typography, | ||
shouldForwardProp, | ||
createCss, | ||
PseudoProps, | ||
AllSystemProps, | ||
SystemProp, | ||
Theme, | ||
CSSObject, | ||
} from 'system-props'; | ||
import styled, { CSSProp } from 'styled-components'; | ||
import * as CSS from 'csstype'; | ||
|
||
const system = createSystem(); | ||
|
||
const extraProps = { | ||
transform: true, | ||
textDecoration: true, | ||
transition: true, | ||
} as const; | ||
|
||
type BaseProps = AllSystemProps<'all'> & | ||
{ | ||
[k in keyof typeof extraProps]?: SystemProp<CSS.Properties[k]>; | ||
}; | ||
|
||
interface BoxProps extends BaseProps, PseudoProps<BaseProps> { | ||
cx?: CSSObject<'all'> | ((theme: Theme) => CSSObject<'all'>); | ||
children?: ReactNode; | ||
css?: CSSProp; | ||
} | ||
|
||
const config = { | ||
...color, | ||
...border, | ||
...background, | ||
...flexbox, | ||
...grid, | ||
...shadow, | ||
...position, | ||
...layout, | ||
...space, | ||
...typography, | ||
...extraProps, | ||
}; | ||
|
||
export const css = createCss(config, { tokenPrefix: 'all' }); | ||
|
||
export const Box = styled('div').withConfig({ | ||
shouldForwardProp: (prop, defaultValidtorFn) => | ||
shouldForwardProp(prop) && | ||
defaultValidtorFn(prop) && | ||
!Object.keys(extraProps).includes(prop), | ||
})<BoxProps>({ boxSizing: 'border-box' }, system(config)); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import App from './App'; | ||
|
||
ReactDOM.render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode>, | ||
document.getElementById('root') | ||
); |
1 change: 1 addition & 0 deletions
1
examples/styled-components/styled.d.ts → examples/styled-components/src/styled.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.