Skip to content

Commit

Permalink
StyleSheet with styleq runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
necolas committed Jan 28, 2022
1 parent 081a128 commit c7cd907
Show file tree
Hide file tree
Showing 115 changed files with 3,678 additions and 5,453 deletions.
3 changes: 2 additions & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[version]
^0.148.0
0.148.0

[ignore]
<PROJECT_ROOT>/.*/__tests__/.*
<PROJECT_ROOT>/packages/.*/dist/.*
<PROJECT_ROOT>/packages/docs/.*
<PROJECT_ROOT>/packages/examples/.*
.*/node_modules/.*/.*.json
.*/node_modules/@emotion/css/*
.*/node_modules/babel-plugin-transform-react-remove-prop-types/*

Expand Down
34 changes: 34 additions & 0 deletions flow-typed/npm/styleq.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
type CompiledStyle = {
$$css: boolean,
[key: string]: string,
};

type InlineStyle = {
[key: string]: mixed,
};

type EitherStyle = CompiledStyle | InlineStyle;

type StylesArray<+T> = T | $ReadOnlyArray<StylesArray<T>>;
type Styles = StylesArray<CompiledStyle | InlineStyle | false>;
type Style<+T = EitherStyle> = StylesArray<false | ?T>;

type StyleqOptions = {
disableCache?: boolean,
disableMix?: boolean,
transform?: (CompiledStyle) => CompiledStyle,
};

type StyleqResult = [string, InlineStyle | null];
type Styleq = (styles: Styles) => StyleqResult;

type IStyleq = {
(...styles: $ReadOnlyArray<Styles>): StyleqResult,
factory: (options?: StyleqOptions) => Styleq,
};

declare module "styleq" {
declare module.exports: {
styleq: IStyleq
};
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"flow-bin": "^0.148.0",
"flow-bin": "0.148.0",
"gen-flow-files": "^0.4.11",
"glob": "^7.1.6",
"husky": "^4.3.8",
"inline-style-prefixer": "^6.0.0",
"jest": "^25.5.0",
"jest": "^27.2.4",
"jest-canvas-mock": "^2.3.1",
"lint-staged": "^10.5.4",
"npm-run-all": "^4.1.3",
"prettier": "^2.2.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-test-renderer": "^17.0.1"
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-test-renderer": "^17.0.2"
},
"workspaces": [
"packages/*"
Expand Down
6 changes: 2 additions & 4 deletions packages/benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
"build": "NODE_ENV=production yarn dev"
},
"dependencies": {
"aphrodite": "^2.4.0",
"classnames": "^2.2.6",
"d3-scale-chromatic": "^2.0.0",
"@emotion/css": "^11.1.3",
"react-jss": "^10.5.1",
"classnames": "^2.3.1",
"d3-scale-chromatic": "^2.0.0",
"react-native-web": "0.17.5",
"styled-components": "^5.2.1"
},
Expand Down
36 changes: 0 additions & 36 deletions packages/benchmarks/src/cases/TextTree.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/benchmarks/src/impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ type ComponentsType = {
Box: Component,
Dot: Component,
Provider: Component,
TextBox: Component,
View: Component
};

Expand Down
9 changes: 0 additions & 9 deletions packages/benchmarks/src/implementations/aphrodite/index.js

This file was deleted.

25 changes: 25 additions & 0 deletions packages/benchmarks/src/implementations/css-modules/Dot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import styles from './dot-styles.css';

const Dot = ({ size, x, y, children, color }) => (
<div
className={styles.root}
style={Object.assign(
{},
{
borderBottomColor: color,
borderRightWidth: `${size / 2}px`,
borderBottomWidth: `${size / 2}px`,
borderLeftWidth: `${size / 2}px`
},
{
marginLeft: `${x}px`,
marginTop: `${y}px`
}
)}
>
{children}
</div>
);

export default Dot;
10 changes: 10 additions & 0 deletions packages/benchmarks/src/implementations/css-modules/dot-styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.root {
position: absolute;
cursor: pointer;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-top-width: 0;
transform: translate(50%, 50%);
}
2 changes: 2 additions & 0 deletions packages/benchmarks/src/implementations/css-modules/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Box from './Box';
import Dot from './Dot';
import Provider from './Provider';
import View from './View';

export default {
Box,
Dot,
Provider,
View
};
13 changes: 8 additions & 5 deletions packages/benchmarks/src/implementations/inline-styles/Dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ import React from 'react';

const Dot = ({ size, x, y, children, color }) => (
<div
style={{
...styles.root,
...{
style={Object.assign(
{},
styles.root,
{
borderBottomColor: color,
borderRightWidth: `${size / 2}px`,
borderBottomWidth: `${size / 2}px`,
borderLeftWidth: `${size / 2}px`,
borderLeftWidth: `${size / 2}px`
},
{
marginLeft: `${x}px`,
marginTop: `${y}px`
}
}}
)}
>
{children}
</div>
Expand Down
50 changes: 0 additions & 50 deletions packages/benchmarks/src/implementations/react-jss/Box.js

This file was deleted.

25 changes: 0 additions & 25 deletions packages/benchmarks/src/implementations/react-jss/Dot.js

This file was deleted.

2 changes: 0 additions & 2 deletions packages/benchmarks/src/implementations/react-jss/Provider.js

This file was deleted.

31 changes: 0 additions & 31 deletions packages/benchmarks/src/implementations/react-jss/View.js

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import Box from './Box';
import Dot from './Dot';
import Provider from './Provider';
import TextBox from './TextBox';
import { View } from 'react-native';

export default {
Box,
Dot,
Provider,
TextBox,
View
};
Loading

0 comments on commit c7cd907

Please sign in to comment.