Skip to content

Commit

Permalink
feat: contextual styled-jsx (#721)
Browse files Browse the repository at this point in the history
* contextual styles

* extract compute computeSelector

* fix styles mapping

* fix missing file, add new types

* update readme

* fix typing

* fix registry.add

* support passing regitry manually

* update tests

* adopt codereview comments

* rm useless comments

* update readme
  • Loading branch information
huozhi authored Sep 3, 2021
1 parent 69a76f2 commit c2cbe52
Show file tree
Hide file tree
Showing 17 changed files with 449 additions and 357 deletions.
20 changes: 17 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
// Definitions by: @types/styled-jsx <https://www.npmjs.com/package/@types/styled-jsx>

import 'react'
import React from 'react'

declare module 'react' {
interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
jsx?: boolean
global?: boolean
}
}

export type StyleRegistry = {
styles(options?: { nonce?: boolean }): JSX.Element
flush(): void
add(props: any): void
remove(props: any): void
}
export function useStyleRegistry(): StyleRegistry
export function StyleRegistry({
children,
registry
}: {
children: JSX.Element | React.ReactNode
registry?: StyleRegistry
}): JSX.Element
export function createStyleRegistry(): StyleRegistry
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist')
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"dist",
"lib",
"index.d.ts",
"server.js",
"server.d.ts",
"index.js",
"babel.js",
"babel-test.js",
"style.js",
Expand All @@ -25,7 +24,7 @@
"test": "ava",
"lint": "eslint ./src",
"format": "prettier --write \"./{src,test}/**/*.{js,css}\"",
"prepublishOnly": "yarn build && yarn test && yarn lint --quiet"
"prepublishOnly": "rm -rf dist && yarn build && yarn test && yarn lint --quiet"
},
"husky": {
"hooks": {
Expand Down
Loading

0 comments on commit c2cbe52

Please sign in to comment.