Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emotion Native #759

Merged
merged 37 commits into from
Jul 28, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6b9f575
Init commit
nitin42 Jul 9, 2018
91380c2
add emotion-native
nitin42 Jul 9, 2018
38d3012
remove unused imports
nitin42 Jul 9, 2018
db3d964
added basic types
nitin42 Jul 9, 2018
d545607
fix flow types
nitin42 Jul 9, 2018
6ec1ff3
add jsdom env when testing
nitin42 Jul 9, 2018
94b0c28
fixed import statement
nitin42 Jul 13, 2018
25d75bc
fixed import statement and updated package.json
nitin42 Jul 13, 2018
ae75fe3
added test for Emotion native css/css({})
nitin42 Jul 13, 2018
b80e73f
added new keywords
nitin42 Jul 13, 2018
fc1beb9
added documentation for @emotion/native
nitin42 Jul 13, 2018
ddb2dd2
added docs for @emotion/primitives-core
nitin42 Jul 13, 2018
ee2181c
fixed docs and flow types
nitin42 Jul 14, 2018
f839c70
fixed conflicts
nitin42 Jul 14, 2018
95c28d3
fixed conflicts
nitin42 Jul 14, 2018
47f5035
fixed conflicts
nitin42 Jul 15, 2018
fdc1876
update @emotion/primitives version
nitin42 Jul 15, 2018
abca5e7
Update package.json
emmatown Jul 15, 2018
c656626
Update package.json
emmatown Jul 15, 2018
b967b7d
Change package.json formatting
emmatown Jul 15, 2018
2cf1a06
Most things are fixed
emmatown Jul 15, 2018
1073a66
Update snapshots
emmatown Jul 15, 2018
341e192
added example for react-360
nitin42 Jul 15, 2018
f427e40
fixed flow types
nitin42 Jul 16, 2018
f8483e2
update react-native version
nitin42 Jul 16, 2018
fdaf228
added default value for options
nitin42 Jul 16, 2018
00881d1
update function signature in primitives
nitin42 Jul 16, 2018
df1d259
Update README.md
tkh44 Jul 16, 2018
be12b5c
add react to peerDependencies
nitin42 Jul 18, 2018
6a1b33b
Refactor: default export in native
nitin42 Jul 18, 2018
32b27c1
fix wording in docs
nitin42 Jul 18, 2018
f87c05d
Merge branch 'master' into emotion-native
emmatown Jul 21, 2018
975bc68
Fix snapshots
emmatown Jul 23, 2018
4f3f998
Merge remote-tracking branch 'upstream/master' into emotion-native
emmatown Jul 23, 2018
4e8ca76
Merge branch 'master' into emotion-native
emmatown Jul 27, 2018
8c6694e
Loosen peerDep on react-native
emmatown Jul 28, 2018
84c1bb9
Merge branch 'master' into emotion-native
emmatown Jul 28, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ module.exports = {
coveragePathIgnorePatterns: [
'/node_modules/',
'<rootDir>/packages/babel-plugin-emotion/test/util.js'
]
],
preset: 'react-native'
}
311 changes: 144 additions & 167 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,169 +1,146 @@
{
"private": true,
"version": "7.0.13",
"scripts": {
"build:watch": "node scripts/build/watch",
"build": "node scripts/build",
Copy link
Member

@emmatown emmatown Jul 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to revert these formatting changes in the package.jsons?

"test:size": "npm-run-all build size",
"test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --watch",
"test": "npm-run-all -p lint:check coverage test:size test:typescript flow && npm run test:prod",
"test:typescript": "lerna run test:typescript --parallel",
"coverage": "jest --coverage --no-cache --ci --runInBand",
"test:prod": "npm run build && jest -c jest.dist.js --no-cache --ci --runInBand",
"lint:check": "eslint .",
"test:watch": "jest --watch --no-cache",
"size": "bundlesize",
"release": "npm run build && lerna publish",
"lint": "eslint . --fix",
"benchmark": "lerna exec --scope benchmarks npm run benchmark",
"start:site": "lerna exec --scope emotion-site npm run start:site",
"build:site": "lerna exec --scope emotion-site npm run build:site",
"bootstrap": "lerna bootstrap",
"flow": "flow check"
},
"resolutions": {
"**/react": "^16.3.2",
"**/react-dom": "^16.3.2",
"**/browserslist": "^3.2.8"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.51",
"@babel/plugin-external-helpers": "7.0.0-beta.51",
"@babel/preset-env": "7.0.0-beta.51",
"@babel/preset-flow": "7.0.0-beta.51",
"@babel/preset-react": "7.0.0-beta.51",
"@babel/preset-stage-0": "7.0.0-beta.51",
"babel-check-duplicated-nodes": "^1.0.0",
"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"babel-eslint": "^8.2.3",
"babel-flow-types": "^1.2.3",
"babel-jest": "^23.2.0",
"babel-plugin-closure-elimination": "^1.3.0",
"babel-plugin-codegen": "^1.2.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-macros": "^2.0.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.5.1",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"bundlesize": "^0.13.2",
"codecov": "^2.3.1",
"css": "^2.2.1",
"cssjanus": "^1.2.0",
"enzyme": "^3.1.1",
"enzyme-adapter-react-16": "^1.0.4",
"enzyme-to-json": "^3.2.1",
"eslint": "^4.5.0",
"eslint-config-prettier": "^2.3.0",
"eslint-config-react": "^1.1.7",
"eslint-config-standard": "^10.2.1",
"eslint-config-standard-react": "^5.0.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-prettier": "^2.2.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.3.0",
"eslint-plugin-standard": "^3.0.1",
"flow-bin": "^0.73.0",
"gatsby-react-router-scroll": "^1.0.7",
"get-lerna-packages": "^0.1.0",
"hoist-non-react-statics": "^2.3.1",
"jest": "^23.2.0",
"jest-in-case": "^1.0.2",
"jest-serializer-html": "^4.0.1",
"jest-watch-typeahead": "^0.1.0",
"jsdom": "^11.3.0",
"lerna": "^2.2.0",
"lerna-alias": "^3.0.1",
"module-alias": "^2.0.1",
"npm-run-all": "^4.0.2",
"polished": "^1.2.1",
"prettier": "1.10.2",
"raf": "^3.4.0",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-router-dom": "^4.2.2",
"react-test-renderer": "^16.3.2"
},
"author": "Kye Hohenberger",
"homepage": "https://github.com/tkh44/emotion#readme",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/tkh44/emotion.git"
},
"directories": {
"test": "tests"
},
"keywords": [
"styles",
"emotion",
"react",
"css",
"css-in-js"
],
"eslintConfig": {
"extends": [
"standard",
"standard-react",
"prettier",
"prettier/react"
],
"plugins": [
"prettier"
],
"parser": "babel-eslint",
"rules": {
"prettier/prettier": "error",
"react/prop-types": 0,
"react/no-unused-prop-types": 0,
"standard/computed-property-even-spacing": 0,
"no-template-curly-in-string": 0,
"camelcase": 0,
"import/no-duplicates": 0
},
"env": {
"browser": true
},
"overrides": [
{
"files": [
"*.test.js",
"**/__tests__/*"
],
"env": {
"jest": true
}
},
{
"files": [
"**/packages/*/src/*",
"**/packages/*/src/**/*"
],
"rules": {
"import/no-commonjs": 2
}
}
]
},
"workspaces": [
"packages/*",
"site",
"scripts/*"
],
"bugs": {
"url": "https://github.com/tkh44/emotion/issues"
},
"bundlesize": [
{
"path": "./packages/emotion/dist/emotion.umd.min.js",
"threshold": "7 Kb"
},
{
"path": "./packages/react-emotion/dist/emotion.umd.min.js",
"threshold": "9.7 Kb"
}
]
"private": true,
"version": "7.0.13",
"scripts": {
"build:watch": "node scripts/build/watch",
"build": "node scripts/build",
"test:size": "npm-run-all build size",
"test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --watch",
"test": "npm-run-all -p lint:check coverage test:size test:typescript flow && npm run test:prod",
"test:typescript": "lerna run test:typescript --parallel --env=jsdom",
"coverage": "jest --coverage --no-cache --ci --runInBand",
"test:prod": "npm run build && jest -c jest.dist.js --no-cache --ci --runInBand --env=jsdom",
"lint:check": "eslint .",
"test:watch": "jest --watch --no-cache --env=jsdom",
"size": "bundlesize",
"release": "npm run build && lerna publish",
"lint": "eslint . --fix",
"benchmark": "lerna exec --scope benchmarks npm run benchmark",
"start:site": "lerna exec --scope emotion-site npm run start:site",
"build:site": "lerna exec --scope emotion-site npm run build:site",
"bootstrap": "lerna bootstrap",
"flow": "flow check"
},
"resolutions": {
"**/react": "^16.3.2",
"**/react-dom": "^16.3.2",
"**/browserslist": "^3.2.8"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.51",
"@babel/plugin-external-helpers": "7.0.0-beta.51",
"@babel/preset-env": "7.0.0-beta.51",
"@babel/preset-flow": "7.0.0-beta.51",
"@babel/preset-react": "7.0.0-beta.51",
"@babel/preset-stage-0": "7.0.0-beta.51",
"babel-check-duplicated-nodes": "^1.0.0",
"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"babel-eslint": "^8.2.3",
"babel-flow-types": "^1.2.3",
"babel-jest": "^23.2.0",
"babel-plugin-closure-elimination": "^1.3.0",
"babel-plugin-codegen": "^1.2.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-macros": "^2.0.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.5.1",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"bundlesize": "^0.13.2",
"codecov": "^2.3.1",
"css": "^2.2.1",
"cssjanus": "^1.2.0",
"enzyme": "^3.1.1",
"enzyme-adapter-react-16": "^1.0.4",
"enzyme-to-json": "^3.2.1",
"eslint": "^4.5.0",
"eslint-config-prettier": "^2.3.0",
"eslint-config-react": "^1.1.7",
"eslint-config-standard": "^10.2.1",
"eslint-config-standard-react": "^5.0.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-prettier": "^2.2.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.3.0",
"eslint-plugin-standard": "^3.0.1",
"flow-bin": "^0.73.0",
"gatsby-react-router-scroll": "^1.0.7",
"get-lerna-packages": "^0.1.0",
"hoist-non-react-statics": "^2.3.1",
"jest": "^23.2.0",
"jest-in-case": "^1.0.2",
"jest-serializer-html": "^4.0.1",
"jest-watch-typeahead": "^0.1.0",
"jsdom": "^11.3.0",
"lerna": "^2.2.0",
"lerna-alias": "^3.0.1",
"module-alias": "^2.0.1",
"npm-run-all": "^4.0.2",
"polished": "^1.2.1",
"prettier": "1.10.2",
"raf": "^3.4.0",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-router-dom": "^4.2.2",
"react-test-renderer": "^16.3.2"
},
"author": "Kye Hohenberger",
"homepage": "https://github.com/tkh44/emotion#readme",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/tkh44/emotion.git"
},
"directories": {
"test": "tests"
},
"keywords": ["styles", "emotion", "react", "css", "css-in-js"],
"eslintConfig": {
"extends": ["standard", "standard-react", "prettier", "prettier/react"],
"plugins": ["prettier"],
"parser": "babel-eslint",
"rules": {
"prettier/prettier": "error",
"react/prop-types": 0,
"react/no-unused-prop-types": 0,
"standard/computed-property-even-spacing": 0,
"no-template-curly-in-string": 0,
"camelcase": 0,
"import/no-duplicates": 0
},
"env": {
"browser": true
},
"overrides": [
{
"files": ["*.test.js", "**/__tests__/*"],
"env": {
"jest": true
}
},
{
"files": ["**/packages/*/src/*", "**/packages/*/src/**/*"],
"rules": {
"import/no-commonjs": 2
}
}
]
},
"workspaces": ["packages/*", "site", "scripts/*"],
"bugs": {
"url": "https://github.com/tkh44/emotion/issues"
},
"bundlesize": [
{
"path": "./packages/emotion/dist/emotion.umd.min.js",
"threshold": "7 Kb"
},
{
"path": "./packages/react-emotion/dist/emotion.umd.min.js",
"threshold": "9.7 Kb"
}
]
}
23 changes: 23 additions & 0 deletions packages/native/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "emotion-native",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emotion/native

"version": "1.0.0-beta.0",
"description": "Style and render React Native components using emotion",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"files": ["src", "dist"],
"devDependencies": {
"emotion-theming": "^9.2.5",
"react": "^16.4.1",
"react-native": "0.46.0"
},
"dependencies": {
"primitives-core": "1.0.0-beta"
},
"homepage": "https://emotion.sh",
"license": "MIT",
"repository": "https://github.com/emotion-js/emotion/tree/master/packages/native",
"keywords": ["styles", "emotion", "react", "css", "css-in-js"],
"bugs": {
"url": "https://github.com/emotion-js/emotion/issues"
}
}
28 changes: 28 additions & 0 deletions packages/native/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import reactNative from 'react-native'
import { createCss } from 'primitives-core'

import { styled } from './styled'

const css = createCss(reactNative.StyleSheet)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be annotated with PURE


const components = `ActivityIndicator ActivityIndicatorIOS ART Button DatePickerIOS DrawerLayoutAndroid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make this into an array since it's easier to read and there's no need to split

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! No issues.

Image ImageBackground ImageEditor ImageStore KeyboardAvoidingView ListView MapView Modal NavigatorIOS
Picker PickerIOS ProgressBarAndroid ProgressViewIOS ScrollView SegmentedControlIOS Slider
SliderIOS SnapshotViewIOS Switch RecyclerViewBackedScrollView RefreshControl SafeAreaView StatusBar
SwipeableListView SwitchAndroid SwitchIOS TabBarIOS Text TextInput ToastAndroid ToolbarAndroid
Touchable TouchableHighlight TouchableNativeFeedback TouchableOpacity TouchableWithoutFeedback
View ViewPagerAndroid WebView FlatList SectionList VirtualizedList`

components.split(/\s+/m).forEach(comp =>
Object.defineProperty(styled, comp, {
enumerable: true,
configurable: false,
get() {
return styled(reactNative[comp])
}
})
)

export { css }

export default /* #__PURE__ */ styled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesnt make much sense here, #__PURE__ comments are useful for call expressions, this is just exported identifier

Not sure what actual value it gives in context of react-native (it's not that much bytes-constrained as web), it certainly won't hurt, but would have to be used differently.

I would convert this to:

export default components.reduce((acc, comp) =>
  Object.defineProperty(acc, comp, {
    enumerable: true,
    configurable: false,
    get() {
      return styled(reactNative[comp])
    }
  })
, styled)

This would make it self contained expression that can be more safely annotated with PURE.

You could also use my plugin to insert those PURE annotations automatically - https://github.com/Andarist/babel-plugin-annotate-pure-calls , but ofc that's not obligatory 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I'll refactor the code to use your solution.

9 changes: 9 additions & 0 deletions packages/native/src/styled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { StyleSheet } from 'react-native'
import { createStyled } from 'primitives-core'

/**
* a function that returns a styled component which render styles in React Native
*/
let styled = createStyled(StyleSheet)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is also a good candidate for PURE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there any side-effects of using PURE here ?


export { styled }
Loading