-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c28019
commit 561ebc8
Showing
10 changed files
with
17,562 additions
and
6 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
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,25 @@ | ||
{ | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:react/recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier/@typescript-eslint", | ||
"plugin:prettier/recommended" | ||
], | ||
"plugins": ["react", "@typescript-eslint", "prettier"], | ||
"env": { | ||
"browser": true, | ||
"jasmine": true, | ||
"jest": true | ||
}, | ||
"rules": { | ||
"prettier/prettier": ["error", { "singleQuote": true }] | ||
}, | ||
"settings": { | ||
"react": { | ||
"pragma": "React", | ||
"version": "detect" | ||
} | ||
}, | ||
"parser": "@typescript-eslint/parser" | ||
} |
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,34 @@ | ||
import * as Stitches from '@stitches/react'; | ||
import * as React from 'react'; | ||
export const { config, styled } = Stitches.createStitches({ | ||
utils: { | ||
/** util to do stuff */ | ||
ml: (value) => ({ marginLeft: value }), | ||
}, | ||
theme: { | ||
colors: { | ||
red100: '#ff0000', | ||
}, | ||
}, | ||
}); | ||
const Text = styled('span', {}); | ||
const DEFAULT_TAG = 'h1'; | ||
export const Heading = React.forwardRef((props, forwardedRef) => { | ||
return (<> | ||
{/* types here will be fast */} | ||
<Text as={DEFAULT_TAG} onClick={(e) => { console.log(e.altKey); }} ref={forwardedRef}/> | ||
<Text onClick={(e) => { console.log(e.altKey); }} ref={forwardedRef}/> | ||
<Text onClick={(e) => { console.log(e.altKey); }} ref={forwardedRef} css={{ backgroundColor: '$red100' }}/> | ||
<Text onClick={(e) => { console.log(e.altKey); }} ref={forwardedRef} css={{ ...props.css, backgroundColor: '$red100' }}/> | ||
<Text as="a" href="" onClick={(e) => { console.log(e.altKey); }} ref={forwardedRef} css={{ ...props.css, backgroundColor: '$red100' }}/> | ||
{/* | ||
types here will be correct but autocompletion is going to be painfully slow when you add a new prop. | ||
This is the only case where the autocompletion is slow | ||
*/} | ||
<Text as={DEFAULT_TAG} {...props} ref={forwardedRef}/> | ||
</>); | ||
}); | ||
const App = () => { | ||
// when consuming the component it should be very fast | ||
return <Heading />; | ||
}; |
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,45 @@ | ||
import * as Stitches from '@stitches/react' | ||
import * as React from 'react' | ||
|
||
export const { config, styled } = Stitches.createStitches({ | ||
utils: { | ||
/** util to do stuff */ | ||
ml: (value: Stitches.PropertyValue<'margin'>) => ({ marginLeft: value }), | ||
}, | ||
theme: { | ||
colors: { | ||
red100: '#ff0000', | ||
}, | ||
}, | ||
}) | ||
|
||
export type StitchesCss = Stitches.CSS<typeof config> | ||
|
||
const Text = styled('span', {}) | ||
|
||
const DEFAULT_TAG = 'h1' | ||
|
||
type HeadingProps = React.ComponentProps<typeof DEFAULT_TAG> & { css?: StitchesCss } | ||
|
||
export const Heading = React.forwardRef<React.ElementRef<typeof DEFAULT_TAG>, HeadingProps>((props, forwardedRef) => { | ||
return ( | ||
<> | ||
{/* types here will be fast */} | ||
<Text as={DEFAULT_TAG} onClick={(e) => {console.log(e.altKey)}} ref={forwardedRef} /> | ||
<Text onClick={(e) => {console.log(e.altKey)}} ref={forwardedRef} /> | ||
<Text onClick={(e) => {console.log(e.altKey)}} ref={forwardedRef} css={{ backgroundColor: '$red100' }} /> | ||
<Text onClick={(e) => {console.log(e.altKey)}} ref={forwardedRef} css={{ ...props.css, backgroundColor: '$red100' }} /> | ||
<Text as="a" href="" onClick={(e) => {console.log(e.altKey)}} css={{ ...props.css, backgroundColor: '$red100' }} /> | ||
{/* | ||
types here will be correct but autocompletion is going to be painfully slow when you add a new prop. | ||
This is the only case where the autocompletion is slow | ||
*/} | ||
<Text as={DEFAULT_TAG} {...props} onClick={(e) => {console.log(e.altKey)}} ref={forwardedRef} /> | ||
</> | ||
) | ||
}) | ||
|
||
const App = () => { | ||
// when consuming the component it should be very fast too | ||
return <Heading /> | ||
} |
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,27 @@ | ||
{ | ||
"name": "@stitches/test", | ||
"version": "1.0.0-canary.7", | ||
"type": "module", | ||
"files": [ | ||
"dist/*.cjs", | ||
"dist/*.js", | ||
"dist/*.map", | ||
"dist/*.mjs", | ||
"types/*.d.ts" | ||
], | ||
"devDependencies": { | ||
"@stitches/react": "^1.0.0-canary.10", | ||
"@typescript-eslint/eslint-plugin": "^1.6.0", | ||
"@typescript-eslint/parser": "^1.6.0", | ||
"eslint-config-prettier": "^4.1.0", | ||
"eslint-config-react": "^1.1.7", | ||
"eslint-plugin-prettier": "^3.0.1", | ||
"prettier": "^1.16.4", | ||
"typescript": "^4.3.5", | ||
"react": "17.0.2" | ||
}, | ||
"private": true, | ||
"dependencies": { | ||
"@radix-ui/react-polymorphic": "0.0.13" | ||
} | ||
} |
Oops, something went wrong.