Skip to content

Commit

Permalink
feat: contextual styles (#744)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: new context api for concurrent mode

* 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 committed Sep 3, 2021
1 parent 8b585d5 commit 492649f
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
@@ -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
@@ -0,0 +1 @@
module.exports = require('./dist')
5 changes: 2 additions & 3 deletions package.json
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

0 comments on commit 492649f

Please sign in to comment.