Skip to content

Commit 2ee61bd

Browse files
authored
fix: semantic release setup (#202)
* v2.0.1-alpha.1 * strip comments * cleanup config * moved files back to root * ignore some stuff * fix: package.json * fix: ci * fix: renovate
1 parent ec038fe commit 2ee61bd

File tree

15 files changed

+330
-4351
lines changed

15 files changed

+330
-4351
lines changed

packages/scroll-into-view-if-needed/.babelrc.js renamed to .babelrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if (BABEL_ENV === 'cjs') {
1212
}
1313

1414
module.exports = {
15+
comments: false,
1516
presets: [
1617
'@babel/preset-typescript',
1718
[

.circleci/config.yml

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
aliases:
33
- &restore-cache
44
keys:
5-
- v4-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}
5+
- v5-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}
66
# Fallback in case checksum fails
7-
- v4-dependencies-{{ .Branch }}-
7+
- v5-dependencies-{{ .Branch }}-
88

99
- &install
1010
run: yarn --no-progress
1111

1212
- &save-cache
1313
paths:
1414
- node_modules
15-
key: v4-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}
15+
key: v5-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}
1616

1717
- &cypress-dependencies-install
1818
run:
@@ -29,19 +29,7 @@ jobs:
2929
- restore-cache: *restore-cache
3030
- *install
3131
- run: yarn lint
32-
- run:
33-
name: scroll-into-view-if-needed
34-
command: yarn build:d.ts
35-
working_directory: packages/scroll-into-view-if-needed
36-
- run:
37-
name: scroll-into-view-if-needed
38-
command: yarn build
39-
working_directory: packages/scroll-into-view-if-needed
40-
- run:
41-
name: smooth-scroll-into-view-if-needed
42-
command: yarn typecheck
43-
working_directory: packages/smooth-scroll-into-view-if-needed
44-
- save-cache: *save-cache
32+
- run: yarn typecheck
4533

4634
Build:
4735
docker:
@@ -53,35 +41,14 @@ jobs:
5341
- run: yarn build
5442
- save-cache: *save-cache
5543

56-
Website:
57-
docker:
58-
- image: circleci/node:carbon-browsers
59-
steps:
60-
- checkout
61-
- run:
62-
name: Report dependency versions included in the docker image
63-
command: node --version && npm --version && npx --version && yarn --version
64-
- *cypress-dependencies-install
65-
- restore-cache: *restore-cache
66-
- *install
67-
- run: yarn build
68-
- save-cache: *save-cache
69-
7044
Semantic Release:
7145
docker:
7246
- image: circleci/node:8
7347
steps:
7448
- checkout
7549
- restore-cache: *restore-cache
7650
- *install
77-
#- run:
78-
# name: scroll-into-view-if-needed
79-
# command: npx --no-install semantic-release -e semantic-release-monorepo
80-
# working_directory: packages/scroll-into-view-if-needed
81-
#- run:
82-
# name: smooth-scroll-into-view-if-needed
83-
# command: npx --no-install semantic-release -e semantic-release-monorepo
84-
# working_directory: packages/smooth-scroll-into-view-if-needed
51+
- run: npx semantic-release
8552

8653
# Workflows enables us to run multiple jobs in parallel
8754
workflows:
@@ -90,12 +57,10 @@ workflows:
9057
jobs:
9158
- Typecheck
9259
- Build
93-
- Website
9460
- Semantic Release:
9561
requires:
9662
- Typecheck
9763
- Build
98-
- Website
9964
filters:
10065
branches:
10166
only:

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
node_modules
22
lerna-debug.log
3-
.next
3+
.next
4+
dist
5+
es
6+
typings
7+
umd
8+
/compute.js
9+
/index.js
File renamed without changes.

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,67 @@ This used to be just a [ponyfill](https://ponyfill.com) for
1212
release.
1313

1414
## [Demo](https://scroll-into-view-if-needed.netlify.com)
15+
16+
## Install
17+
18+
```bash
19+
yarn add scroll-into-view-if-needed
20+
```
21+
22+
## Usage
23+
24+
```js
25+
import scrollIntoView from 'scroll-into-view-if-needed'
26+
const node = document.getElementById('hero')
27+
28+
// similar behavior as Element.scrollIntoView({block: "nearest", inline: "nearest"})
29+
// only that it is a no-op if `node` is already visible
30+
// see: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
31+
// same behavior as Element.scrollIntoViewIfNeeded()
32+
// see: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded
33+
scrollIntoView(node, {
34+
scrollMode: 'if-needed',
35+
block: 'nearest',
36+
inline: 'nearest',
37+
})
38+
39+
// same behavior as Element.scrollIntoViewIfNeeded(true) without the "IfNeeded" behavior
40+
// see: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded
41+
scrollIntoView(node, { block: 'center', inline: 'center' })
42+
// scrollMode is "always" by default
43+
44+
// smooth scroll if the browser supports it and if the element isn't visible
45+
scrollIntoView(node, { behavior: 'smooth', scrollMode: 'if-needed' })
46+
```
47+
48+
### Ponyfill smooth scrolling
49+
50+
If you're ok with a larger bundlesize and want the smooth scrolling behavior to be ponyfilled you can use the [`smooth-scroll-into-view-if-needed`](https://github.com/stipsan/smooth-scroll-into-view-if-needed) addon.
51+
52+
### Custom scrolling transition
53+
54+
If the default smooth scrolling ponyfill isn't the duration or easing you want,
55+
you can provide your own scrolling logic by giving `behavior` a callback.
56+
57+
```js
58+
import scrollIntoView from 'scroll-into-view-if-needed'
59+
const node = document.getElementById('hero')
60+
61+
scrollIntoView(node, {
62+
// Your scroll actions will always be an array, even if there is nothing to scroll
63+
behavior: scrollActions =>
64+
// list is sorted from innermost (closest parent to your target) to outermost (often the document.body or viewport)
65+
scrollActions.forEach(([el, scrollTop, scrollLeft]) => {
66+
// implement the scroll anyway you want
67+
el.scrollTop = scrollTop
68+
el.scrollLeft = scrollLeft
69+
70+
// If you need the relative scroll coordinates, for things like window.scrollBy style logic, just do the math
71+
const offsetTop = el.scrollTop - scrollTop
72+
const offsetLeft = el.scrollLeft - scrollLeft
73+
}),
74+
// all the other options (scrollMode, block, inline) still work, so you don't need to reimplement them (unless you really really want to)
75+
})
76+
```
77+
78+
## More documentation will be added (hang in there)

package.json

Lines changed: 72 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,86 @@
11
{
2-
"private": true,
3-
"workspaces": [
4-
"packages/*",
5-
"integration-tests/*",
6-
"website"
2+
"name": "scroll-into-view-if-needed",
3+
"description": "Ponyfill for upcoming Element.scrollIntoView() APIs like scrollMode: if-needed, behavior: smooth and block: center",
4+
"license": "MIT",
5+
"author": "Stian Didriksen",
6+
"homepage": "https://scroll-into-view-if-needed.netlify.com",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/stipsan/scroll-into-view-if-needed.git"
10+
},
11+
"version": "2.0.0-dev",
12+
"main": "index.js",
13+
"files": [
14+
"compute.js",
15+
"es",
16+
"typings",
17+
"umd"
718
],
819
"scripts": {
9-
"build": "lerna exec --concurrency 1 -- yarn build",
20+
"prebuild": "yarn clean",
21+
"build": "yarn build:d.ts && yarn build:cjs && yarn build:es && yarn build:umd && yarn build:umd.min",
22+
"build:cjs": "BABEL_ENV=cjs babel src -d . --extensions '.ts'",
23+
"build:d.ts": "tsc --emitDeclarationOnly",
24+
"build:es": "BABEL_ENV=es babel src -d es --extensions '.ts'",
25+
"build:umd": "BABEL_ENV=umd NODE_ENV=development rollup -c -f umd -o umd/scroll-into-view-if-needed.js",
26+
"build:umd.min": "BABEL_ENV=umd NODE_ENV=production rollup -c -f umd -o umd/scroll-into-view-if-needed.min.js",
27+
"clean": "rimraf 'umd' 'es' 'typings'",
1028
"precommit": "lint-staged",
11-
"predeploy:website": "yarn build",
12-
"deploy:website": "cd website && yarn deploy",
29+
"dev": "concurrently 'tsc --watch' 'yarn build:cjs --watch'",
1330
"lint": "eslint ./integration-examples",
14-
"publish:canary": "lerna publish --npm-tag=next --canary",
15-
"typecheck": "lerna exec --concurrency 1 -- yarn typecheck"
31+
"prepublishOnly": "unset npm_config_cafile && yarn build",
32+
"typecheck": "tsc --noEmit"
1633
},
1734
"devDependencies": {
35+
"@babel/cli": "7.0.0-beta.46",
36+
"@babel/core": "7.0.0-beta.46",
37+
"@babel/plugin-external-helpers": "7.0.0-beta.46",
38+
"@babel/preset-env": "7.0.0-beta.46",
39+
"@babel/preset-typescript": "7.0.0-beta.46",
1840
"babel-eslint": "8.2.3",
41+
"babel-plugin-add-module-exports": "0.2.1",
42+
"babel-plugin-dev-expression": "0.2.1",
43+
"concurrently": "3.5.1",
1944
"eslint": "4.19.1",
2045
"eslint-config-prettier": "2.9.0",
2146
"eslint-plugin-import": "2.11.0",
2247
"eslint-plugin-react": "7.7.0",
2348
"husky": "0.14.3",
24-
"lerna": "2.11.0",
2549
"lint-staged": "7.0.5",
2650
"prettier": "1.12.1",
27-
"prettier-package-json": "1.5.1"
51+
"prettier-package-json": "1.5.1",
52+
"rimraf": "2.6.2",
53+
"rollup": "0.58.2",
54+
"rollup-plugin-babel": "4.0.0-beta.4",
55+
"rollup-plugin-commonjs": "9.1.0",
56+
"rollup-plugin-node-resolve": "3.3.0",
57+
"rollup-plugin-replace": "2.0.0",
58+
"rollup-plugin-uglify": "3.0.0",
59+
"semantic-release": "15.1.7",
60+
"typescript": "2.8.3"
2861
},
62+
"keywords": [
63+
"behavior-smooth",
64+
"if-needed",
65+
"polyfill",
66+
"ponyfill",
67+
"scroll",
68+
"scroll-into-view",
69+
"scrollIntoView",
70+
"scrollIntoViewIfNeeded",
71+
"scrollMode",
72+
"smooth",
73+
"smoothscroll",
74+
"typescript"
75+
],
2976
"publishConfig": {
3077
"tag": "next"
3178
},
79+
"browserify": {
80+
"transform": [
81+
"loose-envify"
82+
]
83+
},
3284
"lint-staged": {
3385
"*.js": [
3486
"prettier --write",
@@ -59,6 +111,7 @@
59111
"git add"
60112
]
61113
},
114+
"module": "es/index.js",
62115
"prettier": {
63116
"semi": false,
64117
"singleQuote": true,
@@ -72,7 +125,11 @@
72125
}
73126
]
74127
},
75-
"resolutions": {
76-
"@types/react": "*"
77-
}
128+
"release": {
129+
"prepare": [
130+
"@semantic-release/npm"
131+
]
132+
},
133+
"sideEffects": false,
134+
"typings": "typings/index.d.ts"
78135
}

packages/scroll-into-view-if-needed/.gitignore

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)