Skip to content

Commit 90f5af6

Browse files
committed
2 parents 8e40290 + b0f25bf commit 90f5af6

File tree

10 files changed

+2805
-2145
lines changed

10 files changed

+2805
-2145
lines changed

CHANGELOG.md

+41
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
# [1.0.0-alpha.6](https://github.com/dash-ui/responsive/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2022-06-25)
2+
3+
### Bug Fixes
4+
5+
- remove alpha version from peer deps ([16e6247](https://github.com/dash-ui/responsive/commit/16e6247256322d9edc7b4ce27e415d58f8f9d4ad))
6+
7+
# [1.0.0-alpha.5](https://github.com/dash-ui/responsive/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2021-10-31)
8+
9+
### Performance Improvements
10+
11+
- improve variants/one/lazy perf ([0a14e27](https://github.com/dash-ui/responsive/commit/0a14e27f5c39fba77f7bf4f00f1e374035f920c4))
12+
13+
# [1.0.0-alpha.4](https://github.com/dash-ui/responsive/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2021-10-31)
14+
15+
### Bug Fixes
16+
17+
- fix key setting ([d6defc7](https://github.com/dash-ui/responsive/commit/d6defc7804b4b4e2f1e25afc2ea108308f3a8f3d))
18+
19+
# [1.0.0-alpha.3](https://github.com/dash-ui/responsive/compare/v1.0.0-alpha.2...v1.0.0-alpha.3) (2021-10-30)
20+
21+
### Bug Fixes
22+
23+
- update mq dependency ([b0401d0](https://github.com/dash-ui/responsive/commit/b0401d0212d9e7e9db0986666d42cbd9b4a5b2d8))
24+
25+
# [1.0.0-alpha.2](https://github.com/dash-ui/responsive/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2021-10-30)
26+
27+
### Bug Fixes
28+
29+
- add numeric variants ([9d071ca](https://github.com/dash-ui/responsive/commit/9d071ca6ea56563489bbec51e89a2a17cf14016e))
30+
31+
# [1.0.0-alpha.1](https://github.com/dash-ui/responsive/compare/v0.2.3...v1.0.0-alpha.1) (2021-10-29)
32+
33+
### Features
34+
35+
- update api and types to match latest dash alpha ([d04ec1d](https://github.com/dash-ui/responsive/commit/d04ec1d467d9f74e294798ed1e6fe1e48172abdb))
36+
37+
### BREAKING CHANGES
38+
39+
- responsive() no longer returns a function, it returns an object. The function it
40+
used to return is now on the "variants" property.
41+
142
# Changelog
243

344
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const responsiveStyle = responsive(styles, {
4343
desktop: 'only screen and (min-width: 50em)'
4444
})
4545

46-
const myResponsiveStyle = responsiveStyle({
46+
const myResponsiveStyle = responsiveStyle.variants({
4747
default: {
4848
display: 'block'
4949
},
@@ -61,7 +61,7 @@ const MyComponent = ({display}) => {
6161

6262
## API
6363

64-
### responsive()
64+
### responsive.variants()
6565

6666
#### Arguments
6767

benchmark/index.ts

+47-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
import { styles } from "@dash-ui/styles";
2-
import bench from "@essentials/benchmark";
2+
import bench_ from "@essentials/benchmark";
33
// eslint-disable-next-line
44
import responsive from "../dist/module";
55

6+
function bench(name: string, callback: () => void) {
7+
bench_(name, ({ duration }) => {
8+
duration(1000);
9+
return callback;
10+
});
11+
}
12+
613
const responsiveStyle = responsive(styles, {
714
sm: "only screen and (min-width: 20em)",
815
md: "only screen and (min-width: 50em)",
916
});
1017

11-
const responsiveA = responsiveStyle({
18+
const responsiveA = responsiveStyle.variants({
19+
md: {
20+
width: 400,
21+
height: 800,
22+
},
23+
});
24+
25+
const responsiveAD = responsiveStyle.variants({
1226
default: {
1327
width: 200,
1428
height: 600,
@@ -19,15 +33,23 @@ const responsiveA = responsiveStyle({
1933
},
2034
});
2135

22-
bench("normal variant", () => {
36+
bench("normal variant w/o default", () => {
2337
responsiveA("md");
2438
});
2539

40+
bench("normal variant w/ default", () => {
41+
responsiveAD("md");
42+
});
43+
2644
bench(`responsive variant`, () => {
2745
responsiveA({ sm: "md" });
2846
});
2947

30-
const responsiveB = responsiveStyle({
48+
bench("responsive variant w/ default", () => {
49+
responsiveAD({ sm: "md" });
50+
});
51+
52+
const responsiveB = responsiveStyle.variants({
3153
default: `
3254
width: 200px;
3355
height: 600px;
@@ -46,7 +68,7 @@ bench(`responsive variant [string]`, () => {
4668
responsiveB({ sm: "md" });
4769
});
4870

49-
const responsiveC = responsiveStyle((queryValue) => {
71+
const responsiveC = responsiveStyle.lazy((queryValue) => {
5072
if (queryValue === "md") {
5173
return `
5274
width: 400px;
@@ -60,15 +82,15 @@ const responsiveC = responsiveStyle((queryValue) => {
6082
`;
6183
});
6284

63-
bench("normal variant [callback]", () => {
85+
bench("normal lazy [callback]", () => {
6486
responsiveC("md");
6587
});
6688

67-
bench(`responsive variant [callback]`, () => {
89+
bench(`responsive lazy [callback]`, () => {
6890
responsiveC({ sm: "md" });
6991
});
7092

71-
const responsiveD = responsiveStyle((queryValue) => {
93+
const responsiveD = responsiveStyle.lazy((queryValue) => {
7294
if (queryValue === "md") {
7395
return {
7496
width: 400,
@@ -82,10 +104,25 @@ const responsiveD = responsiveStyle((queryValue) => {
82104
};
83105
});
84106

85-
bench("normal variant [callback obj]", () => {
107+
bench("lazy variant [callback obj]", () => {
86108
responsiveD("md");
87109
});
88110

89-
bench(`responsive variant [callback obj]`, () => {
111+
bench(`responsive lazy variant [callback obj]`, () => {
90112
responsiveD({ sm: "md" });
91113
});
114+
115+
const responsiveE = responsiveStyle.one(() => {
116+
return {
117+
width: 200,
118+
height: 600,
119+
};
120+
});
121+
122+
bench("normal one [callback obj]", () => {
123+
responsiveE();
124+
});
125+
126+
bench(`responsive one [callback obj]`, () => {
127+
responsiveE({ sm: true });
128+
});

package.json

+84-74
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,14 @@
11
{
22
"name": "@dash-ui/responsive",
3-
"version": "0.2.3",
3+
"version": "1.0.0-alpha.6",
44
"description": "A library for adding responsive style props to components with @dash-ui",
5-
"keywords": [
6-
"responsive prop",
7-
"dash",
8-
"dash ui",
9-
"dash responsive props",
10-
"dash media query props",
11-
"media query props"
12-
],
13-
"homepage": "https://github.com/dash-ui/responsive#readme",
14-
"bugs": "https://github.com/dash-ui/responsive/issues",
15-
"repository": "github:dash-ui/responsive",
165
"license": "MIT",
176
"author": "Jared Lunde <[email protected]> (https://jaredlunde.com/)",
18-
"sideEffects": false,
19-
"exports": {
20-
".": {
21-
"browser": "./dist/module/index.js",
22-
"import": "./dist/esm/index.mjs",
23-
"require": "./dist/main/index.js",
24-
"umd": "./dist/umd/responsive.js",
25-
"source": "./src/index.ts",
26-
"types": "./types/index.d.ts",
27-
"default": "./dist/main/index.js"
28-
},
29-
"./package.json": "./package.json",
30-
"./": "./"
31-
},
7+
"homepage": "https://github.com/dash-ui/responsive#readme",
8+
"repository": "github:dash-ui/responsive",
9+
"bugs": "https://github.com/dash-ui/responsive/issues",
3210
"main": "dist/main/index.js",
33-
"unpkg": "dist/umd/responsive.js",
3411
"module": "dist/module/index.js",
35-
"source": "src/index.ts",
36-
"types": "types/index.d.ts",
3712
"files": [
3813
"/dist",
3914
"/src",
@@ -50,25 +25,56 @@
5025
"test": "jest",
5126
"validate": "lundle check-types && pnpm run lint && jest --coverage"
5227
},
53-
"commitlint": {
54-
"extends": [
55-
"@commitlint/config-conventional"
56-
]
57-
},
58-
"lint-staged": {
59-
"**/*.{ts,js}": [
60-
"eslint --ext .ts,.js --fix",
61-
"prettier --write"
62-
],
63-
"**/*.{md,yml,json}": [
64-
"prettier --write"
65-
]
66-
},
6728
"config": {
6829
"commitizen": {
6930
"path": "./node_modules/cz-conventional-changelog"
7031
}
7132
},
33+
"sideEffects": false,
34+
"types": "types/index.d.ts",
35+
"peerDependencies": {
36+
"@dash-ui/styles": ">=1.0.1"
37+
},
38+
"devDependencies": {
39+
"@babel/node": "^7.15.4",
40+
"@commitlint/cli": "latest",
41+
"@commitlint/config-conventional": "latest",
42+
"@dash-ui/jest": "^2.1.2",
43+
"@dash-ui/styles": "^1.0.1",
44+
"@essentials/benchmark": "^1.0.7",
45+
"@semantic-release/changelog": "^6.0.0",
46+
"@semantic-release/git": "^10.0.0",
47+
"@swc-node/core": "^1.6.0",
48+
"@swc-node/jest": "^1.3.2",
49+
"@testing-library/jest-dom": "^5.14.1",
50+
"@types/jest": "latest",
51+
"@types/node": "^18.0.0",
52+
"@typescript-eslint/typescript-estree": "^5.29.0",
53+
"cli-confirm": "latest",
54+
"cz-conventional-changelog": "latest",
55+
"eslint": "^7.32.0",
56+
"eslint-config-lunde": "^0.7.1",
57+
"husky": "latest",
58+
"jest": "latest",
59+
"jest-environment-jsdom": "^28.1.1",
60+
"lint-staged": "latest",
61+
"lundle": "latest",
62+
"prettier": "latest",
63+
"typescript": "latest"
64+
},
65+
"keywords": [
66+
"dash",
67+
"dash media query props",
68+
"dash responsive props",
69+
"dash ui",
70+
"media query props",
71+
"responsive prop"
72+
],
73+
"commitlint": {
74+
"extends": [
75+
"@commitlint/config-conventional"
76+
]
77+
},
7278
"eslintConfig": {
7379
"extends": [
7480
"lunde"
@@ -82,6 +88,19 @@
8288
"test",
8389
"*.config.js"
8490
],
91+
"exports": {
92+
".": {
93+
"browser": "./dist/module/index.js",
94+
"import": "./dist/esm/index.mjs",
95+
"require": "./dist/main/index.js",
96+
"umd": "./dist/umd/responsive.js",
97+
"source": "./src/index.ts",
98+
"types": "./types/index.d.ts",
99+
"default": "./dist/main/index.js"
100+
},
101+
"./package.json": "./package.json",
102+
"./": "./"
103+
},
85104
"jest": {
86105
"collectCoverageFrom": [
87106
"**/src/**/*.ts"
@@ -102,41 +121,36 @@
102121
"testMatch": [
103122
"<rootDir>/src/**/?(*.)test.ts"
104123
],
124+
"transformIgnorePatterns": [],
105125
"transform": {
106126
"^.+\\.(t|j)s?$": [
107127
"@swc-node/jest"
108128
]
109129
}
110130
},
111-
"devDependencies": {
112-
"@babel/node": "^7.15.4",
113-
"@commitlint/cli": "latest",
114-
"@commitlint/config-conventional": "latest",
115-
"@dash-ui/jest": "^2.1.2",
116-
"@dash-ui/styles": "^0.8.6",
117-
"@essentials/benchmark": "^1.0.7",
118-
"@semantic-release/changelog": "^6.0.0",
119-
"@semantic-release/git": "^10.0.0",
120-
"@swc-node/core": "^1.6.0",
121-
"@swc-node/jest": "^1.3.2",
122-
"@testing-library/jest-dom": "^5.14.1",
123-
"@types/jest": "latest",
124-
"cli-confirm": "latest",
125-
"cz-conventional-changelog": "latest",
126-
"eslint": "latest",
127-
"eslint-config-lunde": "latest",
128-
"husky": "latest",
129-
"jest": "latest",
130-
"lint-staged": "latest",
131-
"lundle": "latest",
132-
"prettier": "latest",
133-
"typescript": "latest"
131+
"lint-staged": {
132+
"package.json": [
133+
"pnpm dlx prettier-package-json --write"
134+
],
135+
"**/*.{ts,js}": [
136+
"eslint --ext .ts,.js --fix",
137+
"prettier --write"
138+
],
139+
"**/*.{md,yml,json}": [
140+
"prettier --write"
141+
]
134142
},
135143
"release": {
136144
"branches": [
137145
"main",
138-
"next",
139-
"alpha"
146+
{
147+
"name": "next",
148+
"prerelease": true
149+
},
150+
{
151+
"name": "alpha",
152+
"prerelease": true
153+
}
140154
],
141155
"plugins": [
142156
"@semantic-release/commit-analyzer",
@@ -157,10 +171,6 @@
157171
"@semantic-release/github"
158172
]
159173
},
160-
"dependencies": {
161-
"@dash-ui/mq": "^0.4.0"
162-
},
163-
"peerDependencies": {
164-
"@dash-ui/styles": ">=0.8.4"
165-
}
174+
"source": "src/index.ts",
175+
"unpkg": "dist/umd/responsive.js"
166176
}

0 commit comments

Comments
 (0)