Skip to content

Commit 1cab1bf

Browse files
authored
chore: standardize repository maintenance (#48)
* chore: standardize repository maintenance * chore: align reusable test workflow * chore: address review feedback * chore: set up utoo for preview builds * chore: use npm install for vercel preview * chore: align maintenance dependencies * chore: fix upgraded test tooling * docs: align Chinese README language switch * chore: fix upgraded tooling checks * chore: align TypeScript 6 tooling checks * test: fix cypress webpack config * docs: set button types in shadow demo * docs: use npm install in README * chore: migrate to native eslint flat config * chore: address review comments
1 parent 8726b8b commit 1cab1bf

22 files changed

Lines changed: 560 additions & 174 deletions

.eslintrc.js

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

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: ant-design
2+
open_collective: ant-design

.github/dependabot.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
# To get started with Dependabot version updates, you'll need to specify which
2-
# package ecosystems to update and where the package manifests are located.
3-
# Please see the documentation for all configuration options:
4-
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5-
61
version: 2
72
updates:
8-
- package-ecosystem: "npm" # See documentation for possible values
9-
directory: "/" # Location of package manifests
3+
- package-ecosystem: npm
4+
directory: '/'
5+
schedule:
6+
interval: weekly
7+
day: monday
8+
time: '21:00'
9+
timezone: Asia/Shanghai
10+
open-pull-requests-limit: 10
11+
groups:
12+
npm-dependencies:
13+
patterns:
14+
- '*'
15+
16+
- package-ecosystem: github-actions
17+
directory: '/'
1018
schedule:
11-
interval: "weekly"
19+
interval: weekly
20+
day: monday
21+
time: '21:00'
22+
timezone: Asia/Shanghai
23+
open-pull-requests-limit: 10
24+
groups:
25+
github-actions:
26+
patterns:
27+
- '*'

.github/workflows/ci.yml

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

.github/workflows/codeql.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: 'CodeQL'
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
pull_request:
7+
branches: ['main']
8+
schedule:
9+
- cron: '36 13 * * 3'
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: [javascript-typescript]
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v7
28+
with:
29+
persist-credentials: false
30+
31+
- name: Initialize CodeQL
32+
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e
33+
with:
34+
languages: ${{ matrix.language }}
35+
queries: +security-and-quality
36+
37+
- name: Autobuild
38+
uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e
39+
40+
- name: Perform CodeQL Analysis
41+
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e
42+
with:
43+
category: '/language:${{ matrix.language }}'

.github/workflows/react-doctor.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: React Doctor
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
issues: write
12+
statuses: write
13+
14+
jobs:
15+
react-doctor:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v7
19+
with:
20+
fetch-depth: 0
21+
persist-credentials: false
22+
- uses: millionco/react-doctor@0b4f4f4bd248a154e64eb508a48347f71154b3f3
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Surge Preview
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
checks: write
10+
11+
jobs:
12+
preview:
13+
runs-on: ubuntu-latest
14+
concurrency:
15+
group: surge-preview-${{ github.event.pull_request.number }}
16+
cancel-in-progress: true
17+
steps:
18+
- uses: actions/checkout@v7
19+
with:
20+
persist-credentials: false
21+
- name: Check Surge token
22+
id: surge-token
23+
env:
24+
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
25+
run: |
26+
if [ -n "$SURGE_TOKEN" ]; then
27+
echo "enabled=true" >> "$GITHUB_OUTPUT"
28+
else
29+
echo "enabled=false" >> "$GITHUB_OUTPUT"
30+
fi
31+
- name: Setup utoo
32+
if: ${{ steps.surge-token.outputs.enabled == 'true' }}
33+
uses: utooland/setup-utoo@v1
34+
35+
- name: Build preview
36+
if: ${{ steps.surge-token.outputs.enabled == 'true' }}
37+
run: |
38+
ut install
39+
npm run build
40+
- uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec
41+
if: ${{ steps.surge-token.outputs.enabled == 'true' }}
42+
env:
43+
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
44+
with:
45+
surge_token: ${{ env.SURGE_TOKEN }}
46+
github_token: ${{ secrets.GITHUB_TOKEN }}
47+
dist: .doc
48+
failOnError: false
49+
setCommitStatus: false
50+
- name: Skip Surge preview
51+
if: ${{ steps.surge-token.outputs.enabled != 'true' }}
52+
run: echo "SURGE_TOKEN is not configured; skip Surge preview."

.github/workflows/test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: ✅ test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
uses: react-component/rc-test/.github/workflows/test-utoo.yml@main
15+
secrets:
16+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

README.md

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,78 @@
1-
# @rc-component/dom-align
2-
3-
---
4-
5-
Align source html element with target html element flexibly.
6-
7-
[![NPM version][npm-image]][npm-url]
8-
[![npm download][download-image]][download-url]
9-
[![build status][github-actions-image]][github-actions-url]
10-
[![Codecov][codecov-image]][codecov-url]
11-
[![bundle size][bundlephobia-image]][bundlephobia-url]
12-
[![dumi][dumi-image]][dumi-url]
13-
14-
[npm-image]: http://img.shields.io/npm/v/@rc-component/dom-align.svg?style=flat-square
15-
[npm-url]: http://npmjs.org/package/@rc-component/dom-align
16-
[travis-image]: https://img.shields.io/travis/react-component/dom-align/main?style=flat-square
17-
[travis-url]: https://travis-ci.com/react-component/dom-align
18-
[github-actions-image]: https://github.com/react-component/dom-align/actions/workflows/ci.yml/badge.svg
19-
[github-actions-url]: https://github.com/react-component/dom-align/actions/workflows/ci.yml
20-
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/dom-align/main.svg?style=flat-square
21-
[codecov-url]: https://app.codecov.io/gh/react-component/dom-align
22-
[david-url]: https://david-dm.org/react-component/dom-align
23-
[david-image]: https://david-dm.org/react-component/dom-align/status.svg?style=flat-square
24-
[david-dev-url]: https://david-dm.org/react-component/dom-align?type=dev
25-
[david-dev-image]: https://david-dm.org/react-component/dom-align/dev-status.svg?style=flat-square
26-
[download-image]: https://img.shields.io/npm/dm/@rc-component/dom-align.svg?style=flat-square
27-
[download-url]: https://npmjs.org/package/@rc-component/dom-align
28-
[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/dom-align
29-
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/dom-align
30-
[dumi-url]: https://github.com/umijs/dumi
31-
[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square
32-
33-
## Screenshot
34-
35-
<img height=444 src="http://gtms02.alicdn.com/tps/i2/TB1XIp2HXXXXXajaXXXgJfr8XXX-548-888.png">
1+
<div align="center">
2+
<h1>@rc-component/dom-align</h1>
3+
<p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Part of the Ant Design ecosystem.</sub></p>
4+
<p>📐 DOM alignment utility for positioning one element against another.</p>
5+
6+
<p>
7+
<a href="https://npmjs.org/package/@rc-component/dom-align"><img alt="NPM version" src="https://img.shields.io/npm/v/@rc-component/dom-align.svg?style=flat-square"></a>
8+
<a href="https://npmjs.org/package/@rc-component/dom-align"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@rc-component/dom-align.svg?style=flat-square"></a>
9+
<a href="https://github.com/react-component/dom-align/actions/workflows/test.yml"><img alt="build status" src="https://github.com/react-component/dom-align/actions/workflows/test.yml/badge.svg"></a>
10+
<a href="https://app.codecov.io/gh/react-component/dom-align"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/react-component/dom-align/main.svg?style=flat-square"></a>
11+
<a href="https://bundlephobia.com/package/@rc-component/dom-align"><img alt="bundle size" src="https://img.shields.io/bundlephobia/minzip/@rc-component/dom-align?style=flat-square"></a>
12+
<a href="https://github.com/umijs/dumi"><img alt="dumi" src="https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square"></a>
13+
</p>
14+
</div>
15+
16+
<p align="center">English | <a href="./README.zh-CN.md">简体中文</a></p>
17+
18+
## Highlights
19+
20+
| Area | Support |
21+
| ------- | ------------------------------------------------------------------ |
22+
| Purpose | DOM alignment utility for positioning one element against another. |
23+
| Package | `@rc-component/dom-align` |
24+
| Release | `@rc-component/np` / `rc-np` |
3625

3726
## Install
3827

39-
[![@rc-component/dom-align](https://nodei.co/npm/@rc-component/dom-align.png)](https://npmjs.org/package/@rc-component/dom-align)
40-
41-
## Feature
42-
43-
- support Edge Chrome Firefox
44-
- support align points and offset
45-
- support auto adjust according to visible area
28+
```bash
29+
npm install @rc-component/dom-align
30+
```
4631

4732
## Usage
4833

49-
```js
34+
```tsx | pure
5035
import domAlign from '@rc-component/dom-align';
5136

52-
// use domAlign
53-
// sourceNode's initial style should be position:absolute;left:-9999px;top:-9999px;
37+
domAlign(sourceNode, targetNode, {
38+
points: ['tl', 'tr'],
39+
offset: [10, 20],
40+
overflow: { adjustX: true, adjustY: true },
41+
});
42+
```
43+
44+
## API
45+
46+
| Option | Description |
47+
| --- | --- |
48+
| `points` | Source and target alignment points. |
49+
| `offset` | Source node offset. |
50+
| `targetOffset` | Target node offset. |
51+
| `overflow` | Auto-adjust behavior when the source overflows viewport. |
52+
| `useCssRight` / `useCssBottom` / `useCssTransform` | Choose CSS positioning strategy. |
5453

55-
const alignConfig = {
56-
points: ['tl', 'tr'], // align top left point of sourceNode with top right point of targetNode
57-
offset: [10, 20], // the offset sourceNode by 10px in x and 20px in y,
58-
targetOffset: ['30%', '40%'], // the offset targetNode by 30% of targetNode width in x and 40% of targetNode height in y,
59-
overflow: { adjustX: true, adjustY: true }, // auto adjust position when sourceNode is overflowed
60-
};
54+
## Development
6155

62-
domAlign(sourceNode, targetNode, alignConfig);
56+
```bash
57+
npm install
58+
npm start
59+
npm test
60+
npm run lint
61+
npm run tsc
62+
npm run compile
6363
```
6464

65-
## API
65+
The dumi site runs at `http://localhost:8000`.
66+
67+
## Release
68+
69+
```bash
70+
npm run prepublishOnly
71+
```
72+
73+
The release flow is handled by `@rc-component/np` through the `rc-np` command when the package uses the shared release flow.
74+
75+
## Detailed API
6676

6777
### void domAlign(source: HTMLElement, target: HTMLElement, alignConfig: Object):Function
6878

@@ -125,17 +135,10 @@ domAlign(sourceNode, targetNode, alignConfig);
125135
</tbody>
126136
</table>
127137

128-
## Development
129-
130-
```
131-
pnpm install
132-
pnpm start
133-
```
134-
135138
## Example
136139

137140
http://localhost:8000/
138141

139142
## License
140143

141-
@rc-component/dom-align is released under the MIT license.
144+
@rc-component/dom-align is released under the [MIT](./LICENSE.md) license.

0 commit comments

Comments
 (0)