Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Every change needs a review from a maintainer.
* @YauhenBichel
46 changes: 46 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Bug report
description: Something does not work the way the README says.
labels: [bug]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time. A screenshot of the map is perfect; please never
attach a real photo of a person.
Security problems go to info@molecare.co.uk instead (see SECURITY.md).
- type: textarea
id: what
attributes:
label: What happened
description: What you did, what you expected, and what happened instead.
validations:
required: true
- type: textarea
id: repro
attributes:
label: Smallest example
description: A few lines of JSX, or a link to a CodeSandbox or StackBlitz.
render: tsx
validations:
required: true
- type: input
id: version
attributes:
label: Package version
placeholder: '0.1.0'
validations:
required: true
- type: input
id: react
attributes:
label: React version and framework
placeholder: 'React 19.1, Next.js 15 App Router'
validations:
required: true
- type: input
id: browser
attributes:
label: Browser and device
placeholder: 'Safari 18 on iPhone 15, touch'
validations:
required: true
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Report a security problem privately
url: https://github.com/MoleCare/react-body-map/security/advisories/new
about: Please do not open a public issue for security problems.
- name: Try the live demo
url: https://molecare.github.io/react-body-map/
about: Check whether the behaviour you see also happens on the demo.
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Feature request
description: An idea that would make the package more useful.
labels: [enhancement]
body:
- type: markdown
attributes:
value: |
This package shows where things are on a body and never says what they
mean (see CONTRIBUTING.md). Ideas that colour regions as good or bad, or
add a risk scale, will be declined. Finer regions, better accessibility
and theming are very welcome.
- type: textarea
id: problem
attributes:
label: The problem
description: What are you trying to do that is hard today?
validations:
required: true
- type: textarea
id: idea
attributes:
label: Your idea
description: How you would like it to work, ideally with the props or API you imagine.
- type: checkboxes
id: help
attributes:
label: Can you help?
options:
- label: I would like to open a pull request for this.
34 changes: 34 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: 2
updates:
# Dev tools only: the package has no run-time dependencies besides React,
# which is a peer. Minor and patch updates come grouped, once a week.
# Major updates come one pull request each, so each can be judged alone.
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
groups:
dev-tools:
dependency-type: development
update-types: [minor, patch]
ignore:
# Follows the Node version CI and .nvmrc use (22), not the newest Node.
- dependency-name: '@types/node'
update-types: [version-update:semver-major]
# typescript-eslint declares an upper bound on TypeScript, and minor
# versions can cross it too, so TypeScript moves only on purpose.
- dependency-name: typescript
update-types: [version-update:semver-major, version-update:semver-minor]
# Babel 8 needs babel-jest to support it first.
- dependency-name: '@babel/*'
update-types: [version-update:semver-major]
open-pull-requests-limit: 5

# Actions are pinned by SHA; this keeps the pins current.
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
actions:
patterns: ['*']
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## What this changes

<!-- One change per pull request. What does a user notice? -->

## Checklist

- [ ] A test for the behaviour I changed (100% coverage stays)
- [ ] A line in the top section of `CHANGELOG.md`, if a user would notice
- [ ] New words are props with an English default, not built-in text
- [ ] Left and right still follow the person, not the viewer (the regions test passes)
- [ ] Shades stay neutral: no good/bad colours, no risk scale
118 changes: 118 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: CI

# Runs on pull requests from forks as well as branches. Nothing here needs a
# secret, so the read-only GITHUB_TOKEN on fork PRs is enough.
on:
pull_request:
push:
branches: [main]

permissions:
contents: read

concurrency:
group: ci-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

jobs:
check:
name: lint, types, tests, build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '22'
cache: npm

- run: npm ci
- run: npm run lint
- run: npm run format
- run: npm run typecheck
- run: npx jest --ci --coverage
- run: npm run build
# The demo imports src/, so this also catches an API change that breaks it.
- run: npm run demo:build

package:
name: exports, types and tarball contents
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '22'
cache: npm

- run: npm ci

# publint checks package.json against the files; arethetypeswrong checks
# that require() and import each get the right types.
- run: npm run check:package

# A test fixture, a .env or a stray photo in the tarball would be
# published to everyone; fail instead.
- name: Only built code, sources and docs are published
run: |
npm pack --dry-run --json --ignore-scripts > pack.json
node -e '
const files = require("./pack.json")[0].files.map(f => f.path);
const allowed = /^(dist\/index\.(js|cjs|d\.ts|d\.cts|js\.map|cjs\.map)|src\/[^/]+\.tsx?|CHANGELOG\.md|LICENSE|README\.md|SECURITY\.md|package\.json)$/;
const bad = files.filter(f => !allowed.test(f));
console.log(files.join("\n"));
if (bad.length) { console.error("Not allowed in the package:", bad); process.exit(1); }
if (!files.some(f => f.startsWith("dist/"))) { console.error("No built code in the package"); process.exit(1); }
'

consumer:
name: installs with ${{ matrix.pm }}
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
pm: [npm, yarn1, yarn4-pnp, yarn4-node-modules, pnpm, bun]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '22'
cache: npm

- run: npm ci
- name: Pack the package as it would be published
run: npm pack
- name: Install it with ${{ matrix.pm }} and load it
run: bash scripts/check-consumer.sh ${{ matrix.pm }} ./molecare-react-body-map-*.tgz

react18:
name: works with React 18
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '22'
cache: npm

- run: npm ci
- run: npm pack
# The lowest React the peer range allows: server render, "use client" and types.
- run: bash scripts/check-consumer.sh npm ./molecare-react-body-map-*.tgz
env:
REACT: 18.3.1
57 changes: 57 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Demo site

# Builds the demo (demo/, which imports the package from src/) and publishes
# it to GitHub Pages, so the live demo always matches main.
#
# One-time setup: Settings -> Pages -> Source: GitHub Actions.

on:
push:
branches: [main]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: pages
cancel-in-progress: false

jobs:
build:
name: build the demo
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '22'
cache: npm

- run: npm ci
# The demo uses relative paths (vite base './'), so it needs no
# configure-pages step, and this job needs no Pages permission.
- run: npm run demo:build

- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: demo-dist

deploy:
name: publish to GitHub Pages
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
Loading
Loading