Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vercel/styled-jsx
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a9167122eb72a824a866cd9f1bcf45fd50305610
Choose a base ref
...
head repository: vercel/styled-jsx
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 13bd38d93beeb08de053e926e377e996180e0b99
Choose a head ref
Loading
Showing with 9,189 additions and 12,719 deletions.
  1. +7 −10 .github/ISSUE_TEMPLATE.md
  2. +59 −0 .github/workflows/main.yml
  3. +15 −0 .github/workflows/prs.yml
  4. +1 −0 .gitignore
  5. +1 −0 .npmrc
  6. +1 −0 .prettierrc.json
  7. +0 −4 .travis.yml
  8. +79 −0 Changelog.md
  9. +2 −1 babel-test.js
  10. +11 −0 css.d.ts
  11. +4 −0 css.js
  12. +24 −0 index.d.ts
  13. +1 −0 index.js
  14. +1 −0 lib/style-transform.js
  15. +1 −1 license.md
  16. +1 −1 macro.js
  17. +0 −8,950 package-lock.json
  18. +76 −82 package.json
  19. +305 −204 readme.md
  20. +0 −1 server.js
  21. +8 −0 src/.babelrc
  22. +1 −2 src/_constants.js
  23. +136 −114 src/_utils.js
  24. +25 −26 src/babel-external.js
  25. +1 −1 src/babel-test.js
  26. +267 −220 src/babel.js
  27. +7 −0 src/index.js
  28. +46 −0 src/lib/hash.js
  29. +27 −10 src/lib/stylesheet.js
  30. +14 −15 src/macro.js
  31. +0 −29 src/server.js
  32. +32 −44 src/style.js
  33. +57 −62 src/stylesheet-registry.js
  34. +9 −4 src/webpack.js
  35. +1 −1 style.js
  36. +7 −0 test/.babelrc
  37. +19 −19 test/__snapshots__/attribute.js.snap
  38. +21 −21 test/__snapshots__/external.js.snap
  39. +36 −36 test/__snapshots__/index.js.snap
  40. +6 −6 test/__snapshots__/macro.js.snap
  41. +4 −4 test/__snapshots__/plugins.js.snap
  42. +2 −2 test/_read.js
  43. +19 −15 test/_transform.js
  44. +28 −4 test/external.js
  45. +11 −0 test/fixtures/attribute-generation-classname-rewriting.js
  46. +1 −3 test/fixtures/class.js
  47. +13 −0 test/fixtures/conflicts.js
  48. +10 −2 test/fixtures/different-jsx-ids.js
  49. +40 −0 test/fixtures/dynamic-this-value-in-arrow.js
  50. +16 −3 test/fixtures/expressions.js
  51. +2 −1 test/fixtures/external-stylesheet-global.js
  52. +3 −4 test/fixtures/external-stylesheet-multi-line.js
  53. +51 −0 test/fixtures/fragment.js
  54. +11 −4 test/fixtures/global.js
  55. +0 −1 test/fixtures/ignore.js
  56. +10 −3 test/fixtures/mixed-global-scoped.js
  57. +4 −2 test/fixtures/multiple-jsx.js
  58. +5 −5 test/fixtures/nested-style-tags.js
  59. +1 −1 test/fixtures/non-styled-jsx-style.js
  60. +8 −2 test/fixtures/not-styled-jsx-tagged-templates.js
  61. +10 −0 test/fixtures/simple-fragment.js
  62. +12 −3 test/fixtures/styles-external-invalid.js
  63. +11 −3 test/fixtures/styles-external-invalid2.js
  64. +5 −1 test/fixtures/styles.js
  65. +3 −1 test/fixtures/styles2.js
  66. +34 −25 test/fixtures/transform.css
  67. +1 −6 test/fixtures/whitespace.js
  68. +1 −0 test/helpers/with-mock.js
  69. +229 −44 test/index.js
  70. +8 −7 test/macro.js
  71. +14 −0 test/plugins.js
  72. +175 −0 test/snapshots/attribute.js.md
  73. BIN test/snapshots/attribute.js.snap
  74. +250 −0 test/snapshots/external.js.md
  75. BIN test/snapshots/external.js.snap
  76. +401 −0 test/snapshots/index.js.md
  77. BIN test/snapshots/index.js.snap
  78. +67 −0 test/snapshots/macro.js.md
  79. BIN test/snapshots/macro.js.snap
  80. +47 −0 test/snapshots/plugins.js.md
  81. BIN test/snapshots/plugins.js.snap
  82. +11 −0 test/snapshots/styles.js.md
  83. BIN test/snapshots/styles.js.snap
  84. +44 −51 test/stylesheet-registry.js
  85. +10 −3 test/stylesheet.js
  86. +6,308 −2,655 yarn.lock
17 changes: 7 additions & 10 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -2,31 +2,28 @@

⚠️ IMPORTANT ⚠️

If you need help or have a question about styled-jsx please ask it on Spectrum https://spectrum.chat/styled-jsx or join our Slack community at https://zeit.chat and ask it in the `#next` channel.
If you need help or have a question about styled-jsx please ask it on Spectrum https://spectrum.chat/styled-jsx or join our Slack community at https://vercel.chat and ask it in the `#next` channel.

Before you open a new issue please take a look at our [**Frequent Asked Questions**](https://github.com/zeit/styled-jsx#faq) and [**open issues**](https://github.com/zeit/styled-jsx/issues).
Before you open a new issue please take a look at our [**Frequent Asked Questions**](https://github.com/vercel/styled-jsx#faq) and [**open issues**](https://github.com/vercel/styled-jsx/issues).

Remember, often time asking in chat or looking at the FAQ/issues can be *faster than waiting for us to reply to a new issue**.
Remember, often time asking in chat or looking at the FAQ/issues can be \*faster than waiting for us to reply to a new issue\*\*.

If you are here to report a bug or request a feature please remove this introductory section and fill out the information below!

---

#### Do you want to request a *feature* or report a *bug*?
#### Do you want to request a _feature_ or report a _bug_?

#### What is the current behavior?

#### If the current behavior is a bug, please provide the steps to reproduce and possibly a minimal demo or testcase in the form of a Next.js app, CodeSandbox URL or similar

1.
2.

#### What is the expected behavior?

#### Environment (include versions)

* OS:
* Browser:
* styled-jsx (version):
- Version of styled-jsx (or next.js if it's being used):
- Browser:
- OS:

#### Did this work in previous versions?
59 changes: 59 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI

on:
push:
branches:
- master
- alpha
- beta
tags:
- '!*'
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Begin CI...
uses: actions/checkout@v2

- name: Use Node 12
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Use cached node_modules
uses: actions/cache@v1
with:
path: node_modules
key: nodeModules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
nodeModules-
- name: Install dependencies
run: yarn install --frozen-lockfile
env:
CI: true

- name: Build
run: yarn build
env:
CI: true

- name: Lint
run: yarn lint
env:
CI: true

- name: Test
run: yarn test
env:
CI: true

- name: Release
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/alpha' || github.ref == 'refs/heads/beta')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
run: yarn semantic-release
15 changes: 15 additions & 0 deletions .github/workflows/prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Lint PR'
on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v2.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ node_modules

# build output
dist
out

# logs
npm-debug.log
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
package-lock=false
save-exact = true
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "singleQuote": true, "semi": false }
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

79 changes: 79 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Changelog

## [5.0.0]

### Features

- Introduce contextual styles (#744)
- Opt-in react 18 insertion effect hook when available (#753)
- Fallback to module level registry in browser (#768)

### Improvements

- Make JSXStyle return a noop if the registry context is not provided (#749)
- Fix typings of `nonce` property
- Pre-compile dependencies to reduce install size/time (#770)

### BREAKING CHANGES

#### APIs

- `styled-jsx/server` import path is deprecated
- `flush` and `flushToHTML` from `styled-jsx/server` APIs are deprecated
- New component `<StyledRegistry>` is introduced
- New APIs `useStyleRegistry` and `createStyleRegistry` are introduced

#### Usage

If you're only using styled-jsx purely client side, nothing will effect you.
If you're using styled-jsx inside Next.js without customization, Next.js will automatically handle the changes for you.

If you have your own customization with styled-jsx in Next.js, for example you have a custom `_document`:
By default, doing this will let Next.js collect styles and pass them down.

```jsx
class Document extends React.Component {
static async getInitialProps(ctx) {
return await ctx.defaultGetInitialProps(ctx)
}
}
```

Or for instance you're passing `nonce` property in `getInitialProps` of `_document`, this will let you configure it:

```diff
class Document extends React.Component {
static async getInitialProps(ctx) {
- return await ctx.defaultGetInitialProps(ctx)
+ return await ctx.defaultGetInitialProps(ctx, { nonce })
}
}
```

If you're building the SSR solution yourself with other frameworks, please checkout the **Server-Side Rendering** section in readme.

## [4.0.1]

- Mark `@babel/core` as optional peer dependency

## [4.0.0]

- Use react hooks to manage styles injection (#720)

### BREAKING CHANGES

- Drop support for react versions < 16.8.0

### Improvements

- Drop babel 6 support (#730)
- Auto publish alpha/beta versions

## [3.4.x]

### Improvements

- Typing support
- Inject unique \_JSXStyle identifier
- Hide webpack loader warnings
- Refactor the import helpers
3 changes: 2 additions & 1 deletion babel-test.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
module.exports = require('./dist/babel-test')
/* eslint-ignore */
module.exports = require('./dist/babel').test()
11 changes: 11 additions & 0 deletions css.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Definitions by: @types/styled-jsx <https://www.npmjs.com/package/@types/styled-jsx>

declare function css(chunks: TemplateStringsArray, ...args: any[]): JSX.Element
declare namespace css {
function global(chunks: TemplateStringsArray, ...args: any[]): JSX.Element
function resolve(
chunks: TemplateStringsArray,
...args: any[]
): { className: string; styles: JSX.Element }
}
export = css
4 changes: 4 additions & 0 deletions css.js
Original file line number Diff line number Diff line change
@@ -5,15 +5,19 @@ function notTranspiledError(name) {
'` tagged template literals were not transpiled.'
)
}

function css() {
notTranspiledError('css')
}

css.global = function() {
notTranspiledError('global')
}

css.resolve = function() {
notTranspiledError('resolve')
}

module.exports = css
module.exports.global = css.global
module.exports.resolve = css.resolve
24 changes: 24 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react'

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

export type StyleRegistry = {
styles(options?: { nonce?: string }): 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/index')
1 change: 1 addition & 0 deletions lib/style-transform.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/* eslint-ignore */
module.exports = require('../dist/lib/style-transform')
2 changes: 1 addition & 1 deletion license.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 Zeit, Inc.
Copyright (c) 2016-present Vercel, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
2 changes: 1 addition & 1 deletion macro.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/macro')
module.exports = require('./dist/babel').macro()
Loading