diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 0000000..e088175 --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,84 @@ +name: Build and Deploy Documentation + +on: + push: + branches: + - main + paths: + - "docs/**" + - "package.json" + - "package-lock.json" + - ".github/workflows/deploy-docs.yml" + + pull_request: + branches: + - main + paths: + - "docs/**" + - "package.json" + - "package-lock.json" + - ".github/workflows/deploy-docs.yml" + + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: docs-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build Docusaurus + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: 24 + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Build documentation + run: npm run docs:build + + - name: Upload build artifact for testing + if: github.ref != 'refs/heads/main' + uses: actions/upload-artifact@v6 + with: + name: docusaurus-build + path: docs/build + retention-days: 7 + + - name: Upload GitHub Pages artifact + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: actions/upload-pages-artifact@v5 + with: + path: docs/build + + deploy: + name: Deploy to GitHub Pages + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + needs: build + runs-on: ubuntu-latest + + permissions: + contents: read + pages: write + id-token: write + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Deploy documentation + id: deployment + uses: actions/deploy-pages@v5 diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..b2d6de3 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,20 @@ +# Dependencies +/node_modules + +# Production +/build + +# Generated files +.docusaurus +.cache-loader + +# Misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/docs/.stylelintrc.yml b/docs/.stylelintrc.yml new file mode 100644 index 0000000..643b926 --- /dev/null +++ b/docs/.stylelintrc.yml @@ -0,0 +1,34 @@ +extends: stylelint-config-standard-scss +plugins: + - stylelint-order +rules: + block-no-empty: null + color-hex-length: null + custom-property-no-missing-var-function: null + custom-property-pattern: null + declaration-block-no-redundant-longhand-properties: null + length-zero-no-unit: null + max-nesting-depth: + - 3 + - ignore: + - blockless-at-rules + - pseudo-classes + no-descending-specificity: null + no-invalid-position-at-import-rule: null + selector-class-pattern: null + selector-pseudo-class-no-unknown: null + value-no-vendor-prefix: null + + order/order: + - dollar-variables + - custom-properties + - declarations + order/properties-alphabetical-order: true + + scss/at-if-no-null: null + scss/at-mixin-pattern: null + scss/dollar-variable-colon-newline-after: null + scss/double-slash-comment-whitespace-inside: null + scss/no-global-function-names: null + scss/operator-no-newline-after: null + scss/operator-no-unspaced: null diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..bce6eb2 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,43 @@ +# Website + +This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator. + +## Installation + +```bash +npm install +``` + +**Note**: feel free to use the package manager of your choice. + +## Local Development + +```bash +npm run start +``` + +This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. + +## Build + +```bash +npm run build +``` + +This command generates static content into the `build` directory and can be served using any static contents hosting service. + +## Deployment + +Using SSH: + +```bash +USE_SSH=true npm run deploy +``` + +Not using SSH: + +```bash +GIT_USER= npm run deploy +``` + +If you are using GitHub Pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. diff --git a/docs/docs/api/_category_.json b/docs/docs/api/_category_.json new file mode 100644 index 0000000..4efba99 --- /dev/null +++ b/docs/docs/api/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "API", + "position": 4, + "link": { + "type": "generated-index" + } +} diff --git a/docs/docs/api/gallery-item.md b/docs/docs/api/gallery-item.md new file mode 100644 index 0000000..6edb129 --- /dev/null +++ b/docs/docs/api/gallery-item.md @@ -0,0 +1,57 @@ +--- +sidebar_position: 3 +--- + +# GalleryItem + +Wraps a single gallery item. It renders an `
  • ` and sets the attributes and CSS custom properties the stylesheet uses to position it. Always return it from `renderGalleryItem` on [``](/docs/api/gallery-main). + +```jsx + ( + + {item.alt} + + )} +/> +``` + +## Props + +TypeScript: `GalleryItemProps`. `GalleryItem` never sees your item data, so it takes no type argument. + +| Prop | Type | Required | Description | +| --- | --- | --- | --- | +| `index` | `number` | yes | This item's index. Pass `index` through from `renderGalleryItem`. | +| `active` | `boolean` | yes | Whether this item is active. Pass `active` through from `renderGalleryItem`. | +| `children` | `ReactNode` | | The item's content. | +| `className` | `string` | | Extra class for the `
  • `. Use it with `active` for state styling. | +Any other `
  • ` attributes are passed through. + +## Accessibility + +- Every item gets `tabIndex={-1}`, so items can receive focus to the active gallery item when the user navigates to it via a button of some sort, eg: with pagination. (the gallery uses this, see [GalleryNav](/docs/api/gallery-nav#focus)). + + +## Data attributes + +| Attribute | Value | +| --- | --- | +| `data-item-visible` | `"true"` if the item is within the gallery's [`visibleRange`](/docs/api/gallery#visiblerange) of the active item, otherwise `"false"`. Always `"true"` when `visibleRange` is `-1`. | +| `data-was-active` | `"true"` on the item that was active before the last change. | + +Style them with attribute selectors, for example `.my-slide[data-item-visible="false"]`. + +## CSS custom properties + +`GalleryItem` sets these inline on the `
  • `. The base stylesheet combines them into `--x`, the item's horizontal position. + +| Property | Description | +| --- | --- | +| `--i` | This item's index. | +| `--center-offset` | Distance from the active item, in items (always positive). | +| `--index-offset` | Distance from the active item, in items: negative before it, positive after it. | +| `--side` | `-1` before the active item, `0` for the active item, `1` after it. | +| `--active` | `1` for the active item, otherwise `0`. | + +They're handy in your own CSS, for example `transition-delay: calc(0.05s * var(--center-offset))`. The full list, including `--x`, is in [Styling](/docs/guides/styling). diff --git a/docs/docs/api/gallery-main.md b/docs/docs/api/gallery-main.md new file mode 100644 index 0000000..f1aae71 --- /dev/null +++ b/docs/docs/api/gallery-main.md @@ -0,0 +1,76 @@ +--- +sidebar_position: 2 +--- + +import Tabs from "@theme/Tabs" +import TabItem from "@theme/TabItem" + +# GalleryMain + +The main gallery view. It renders a `