Skip to content

Commit e2de468

Browse files
committed
fix: moved repo to scroll-into-view org
1 parent d01f384 commit e2de468

File tree

8 files changed

+31632
-6057
lines changed

8 files changed

+31632
-6057
lines changed

.circleci/config.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,6 @@ jobs:
5151
- store_test_results:
5252
path: reports
5353

54-
Semantic Release:
55-
docker:
56-
- image: circleci/node:12
57-
steps:
58-
- checkout
59-
- restore-cache: *restore-cache
60-
- *install
61-
- run: npx semantic-release
62-
6354
# Workflows enables us to run multiple jobs in parallel
6455
workflows:
6556
version: 2
@@ -68,12 +59,3 @@ workflows:
6859
- Typecheck
6960
- Build
7061
- Test
71-
- Semantic Release:
72-
requires:
73-
- Typecheck
74-
- Build
75-
- Test
76-
filters:
77-
branches:
78-
only:
79-
- master

.github/workflows/ci.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
name: CI & Release
3+
4+
# Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
5+
run-name: >-
6+
${{
7+
inputs.release && inputs.test && 'Build ➤ Test ➤ Publish to NPM' ||
8+
inputs.release && !inputs.test && 'Build ➤ Skip Tests ➤ Publish to NPM' ||
9+
github.event_name == 'workflow_dispatch' && inputs.test && 'Build ➤ Test' ||
10+
github.event_name == 'workflow_dispatch' && !inputs.test && 'Build ➤ Skip Tests' ||
11+
''
12+
}}
13+
14+
on:
15+
pull_request:
16+
push:
17+
branches: [main]
18+
workflow_dispatch:
19+
inputs:
20+
test:
21+
description: 'Run tests'
22+
required: true
23+
default: true
24+
type: boolean
25+
release:
26+
description: 'Publish new release'
27+
required: true
28+
default: false
29+
type: boolean
30+
31+
concurrency:
32+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
33+
cancel-in-progress: true
34+
35+
jobs:
36+
build:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
40+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
41+
with:
42+
cache: npm
43+
node-version: lts/*
44+
- run: npm ci
45+
- run: npm run lint
46+
if: github.event.inputs.test != 'false'
47+
- run: npm run typecheck
48+
if: github.event.inputs.test != 'false'
49+
- run: npm run prepublishOnly
50+
51+
test:
52+
needs: build
53+
if: github.event.inputs.test != 'false'
54+
runs-on: ${{ matrix.os }}
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
os: [macos-latest, ubuntu-latest, windows-latest]
59+
node: [lts/*]
60+
include:
61+
- os: ubuntu-latest
62+
node: lts/-2
63+
- os: ubuntu-latest
64+
node: current
65+
steps:
66+
- name: Set git to use LF
67+
if: matrix.os == 'windows-latest'
68+
run: |
69+
git config --global core.autocrlf false
70+
git config --global core.eol lf
71+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
72+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
73+
with:
74+
cache: npm
75+
node-version: ${{ matrix.node }}
76+
- run: npm i
77+
- run: npm test
78+
79+
release:
80+
needs: [build, test]
81+
# only run if opt-in during workflow_dispatch
82+
if: always() && github.event.inputs.release == 'true' && needs.build.result != 'failure' && needs.test.result != 'failure' && needs.test.result != 'cancelled'
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
86+
with:
87+
# Need to fetch entire commit history to
88+
# analyze every commit since last release
89+
fetch-depth: 0
90+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
91+
with:
92+
cache: npm
93+
node-version: lts/*
94+
- run: npm ci
95+
# Branches that will release new versions are defined in .releaserc.json
96+
- run: npx semantic-release
97+
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
98+
# e.g. git tags were pushed but it exited before `npm publish`
99+
if: always()
100+
env:
101+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
103+
# Re-run semantic release with rich logs if it failed to publish for easier debugging
104+
- run: npx semantic-release --dry-run --debug
105+
if: failure()
106+
env:
107+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

.github/workflows/prettier.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Prettier
3+
4+
on:
5+
push:
6+
branches: [main]
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
run:
15+
name: 🤔
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
19+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
20+
with:
21+
cache: npm
22+
node-version: lts/*
23+
- run: npm ci --ignore-scripts --only-dev
24+
- uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3
25+
with:
26+
path: node_modules/.cache/prettier/.prettier-cache
27+
key: prettier-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.gitignore') }}
28+
- name: check if workflows needs prettier
29+
run: npx prettier --cache --check ".github/workflows/**/*.yml" || (echo "An action can't make changes to actions, you'll have to run prettier manually" && exit 1)
30+
- run: npx prettier --ignore-path .gitignore --cache --write .
31+
- uses: EndBug/add-and-commit@61a88be553afe4206585b31aa72387c64295d08b # tag=v9
32+
with:
33+
default_author: github_actions
34+
commit: --no-verify
35+
message: 'chore(prettier): 🤖 ✨'

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

.releaserc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "@sanity/semantic-release-preset",
3+
"branches": ["main"]
4+
}

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
[![CircleCI Status](https://img.shields.io/circleci/project/github/stipsan/compute-scroll-into-view.svg?style=flat-square)](https://circleci.com/gh/stipsan/compute-scroll-into-view)
21
[![npm stat](https://img.shields.io/npm/dm/compute-scroll-into-view.svg?style=flat-square)](https://npm-stat.com/charts.html?package=compute-scroll-into-view)
32
[![npm version](https://img.shields.io/npm/v/compute-scroll-into-view.svg?style=flat-square)](https://www.npmjs.com/package/compute-scroll-into-view)
43
[![gzip size][gzip-badge]][unpkg-dist]
@@ -8,15 +7,15 @@
87

98
![compute-scroll-into-view](https://user-images.githubusercontent.com/81981/43024153-a2cc212c-8c6d-11e8-913b-b4d62efcf105.png)
109

11-
Lower level API that is used by the [ponyfill](https://ponyfill.com) [scroll-into-view-if-needed](https://github.com/stipsan/scroll-into-view-if-needed) to compute where (if needed) elements should scroll based on [options defined in the spec](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) and the [`scrollMode: "if-needed"` draft spec proposal](https://github.com/w3c/csswg-drafts/pull/1805).
10+
Lower level API that is used by the [ponyfill](https://ponyfill.com) [scroll-into-view-if-needed](https://github.com/scroll-into-view/scroll-into-view-if-needed) to compute where (if needed) elements should scroll based on [options defined in the spec](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) and the [`scrollMode: "if-needed"` draft spec proposal](https://github.com/w3c/csswg-drafts/pull/1805).
1211
Use this if you want the smallest possible bundlesize and is ok with implementing the actual scrolling yourself.
1312

1413
Scrolling SVG elements are supported, as well as Shadow DOM elements. The [VisualViewport](https://developer.mozilla.org/en-US/docs/Web/API/VisualViewport) API is also supported, ensuring scrolling works properly on modern devices. Quirksmode is also supported as long as you polyfill [`document.scrollingElement`](https://developer.mozilla.org/en-US/docs/Web/API/document/scrollingElement).
1514

1615
## Install
1716

1817
```bash
19-
yarn add compute-scroll-into-view
18+
npm i compute-scroll-into-view
2019
```
2120

2221
The UMD build is also available on [unpkg](https://unpkg.com/compute-scroll-into-view/umd/):
@@ -68,20 +67,20 @@ actions.forEach(({ el, top, left }) => {
6867

6968
Type: `Object`
7069

71-
#### [block](https://scroll-into-view-if-needed.netlify.com/#scroll-alignment)
70+
#### [block](https://scroll-into-view.dev/#scroll-alignment)
7271

7372
Type: `'start' | 'center' | 'end' | 'nearest'`<br> Default: `'center'`
7473

7574
Control the logical scroll position on the y-axis. The spec states that the `block` direction is related to the [writing-mode](https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode), but this is not implemented yet in this library.
7675
This means that `block: 'start'` aligns to the top edge and `block: 'end'` to the bottom.
7776

78-
#### [inline](https://scroll-into-view-if-needed.netlify.com/#scroll-alignment)
77+
#### [inline](https://scroll-into-view.dev/#scroll-alignment)
7978

8079
Type: `'start' | 'center' | 'end' | 'nearest'`<br> Default: `'nearest'`
8180

8281
Like `block` this is affected by the [writing-mode](https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode). In left-to-right pages `inline: 'start'` will align to the left edge. In right-to-left it should be flipped. This will be supported in a future release.
8382

84-
#### [scrollMode](https://scroll-into-view-if-needed.netlify.com/#scrolling-if-needed)
83+
#### [scrollMode](https://scroll-into-view.dev/#scrolling-if-needed)
8584

8685
Type: `'always' | 'if-needed'`<br> Default: `'always'`
8786

@@ -90,7 +89,7 @@ This is a proposed addition to the spec that you can track here: https://github.
9089
This library will be updated to reflect any changes to the spec and will provide a migration path.
9190
To be backwards compatible with `Element.scrollIntoViewIfNeeded` if something is not 100% visible it will count as "needs scrolling". If you need a different visibility ratio your best option would be to implement an [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).
9291

93-
#### [boundary](https://scroll-into-view-if-needed.netlify.com/#limit-propagation)
92+
#### [boundary](https://scroll-into-view.dev/#limit-propagation)
9493

9594
Type: `Element | Function`
9695

@@ -120,7 +119,7 @@ const actions = computeScrollIntoView(target, {
120119

121120
Type: `Boolean`<br> Default: `false`
122121

123-
By default the [spec](https://drafts.csswg.org/cssom-view/#scrolling-box) states that `overflow: hidden` elements should be scrollable because it has [been used to allow programatic scrolling](https://drafts.csswg.org/css-overflow-3/#valdef-overflow-hidden). This behavior can sometimes lead to [scrolling issues](https://github.com/stipsan/scroll-into-view-if-needed/pull/225#issue-186419520) when you have a node that is a child of an `overflow: hidden` node.
122+
By default the [spec](https://drafts.csswg.org/cssom-view/#scrolling-box) states that `overflow: hidden` elements should be scrollable because it has [been used to allow programatic scrolling](https://drafts.csswg.org/css-overflow-3/#valdef-overflow-hidden). This behavior can sometimes lead to [scrolling issues](https://github.com/scroll-into-view/scroll-into-view-if-needed/pull/225#issue-186419520) when you have a node that is a child of an `overflow: hidden` node.
124123

125124
This package follows the convention [adopted by Firefox](https://hg.mozilla.org/integration/fx-team/rev/c48c3ec05012#l7.18) of setting a boolean option to _not_ scroll all nodes with `overflow: hidden` set.
126125

0 commit comments

Comments
 (0)