Repository navigation
[FEATURE]: Documentation + Demos with Docusaurus #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
81 commits
Select commit
Hold shift + click to select a range
eeab863
chore: adds docusaurus and updates basic config
pravton ee84f46
chore: updates configs and packages
pravton ce557b8
chore: removes all unused files
pravton 9dbe9fc
chore: version helpers/components to keep the version consistent accr…
pravton 0a0c817
chore: adds base utils needed
pravton d778ee6
chore: updates config and adds scss
pravton c06529b
chore: adds intro and getting started docs
pravton 2cf159d
chore: adds basic gallery demo
pravton 9ef2705
chore: adds api docs based on readme
pravton b9e0ae1
chore: updates config and the basic demo
pravton 2979c78
chore: updates side bar to auto generate and config update
pravton 0a6e845
chore: adds category json for sidebar root page and labeling
pravton f90488e
chore: updates spacing
pravton d7c90a0
chore: adds guides docs
pravton 12999f0
chore: adds css custom properties doc
pravton 27f10d2
chore: adds looping gallery demo
pravton 1049287
chore: adds thumbnail gallery demo
pravton 54c992e
chore: adds card stack demo
pravton 5987402
chore: updates base style to scss
pravton 9f55632
chore: updates styling and the image sizes
pravton 0cc44e7
chore: adds open in code open option
pravton 9fc1571
chore: updates demo to use the open in code pen button
pravton 6053064
chore: adds custom control demo
pravton aa0bf3a
chore: adds stories demo
pravton 815158d
chore: updates demo names
pravton 033eed4
chore: removes unrelated boilerplating comments
pravton 4fca497
chore: updates comments
pravton f727078
chore: removes unrelated link
pravton 866ad46
chore: updates to use workspace and added docs related commands
pravton 3974529
chore: adds docs deploy workflow
pravton e9e7790
chore: updates package-lock to be in sync
pravton 723599a
chore: removes branch specific run
pravton 8ab2087
chore: updates demo content
pravton 6704812
Update docs/docs/api/css-custom-properties.md
pravton 7cca930
Update docs/docs/api/gallery-item.md
pravton 011b3d9
Update docs/docs/api/gallery-item.md
pravton fba8ec9
Update docs/docs/api/gallery.md
pravton 75e13af
Update docs/docs/api/gallery.md
pravton 0033995
Update docs/docs/api/gallery-item.md
pravton 8b70e94
Update docs/docs/api/gallery-nav.md
pravton b5aa00d
Update docs/docs/api/gallery-main.md
pravton afb9bc6
Apply suggestion from @andrewrubin
pravton 2647b82
Apply suggestion from @andrewrubin
pravton 2fac934
Apply suggestion from @andrewrubin
pravton 061b609
Apply suggestion from @andrewrubin
pravton a7139fe
Apply suggestion from @andrewrubin
pravton ac43c20
Apply suggestion from @andrewrubin
pravton 30ad931
Apply suggestion from @andrewrubin
pravton a6a037b
Apply suggestion from @andrewrubin
pravton 10e6268
Apply suggestion from @andrewrubin
pravton 003dc8e
Apply suggestion from @andrewrubin
pravton 501a257
Apply suggestion from @andrewrubin
pravton f4f7e43
chore: removes confusing example
pravton 4c2b5e8
chore: removes error related comments
pravton 597425a
chore: removes style reference
pravton 977e7be
chore: reworded the comment
pravton f6d468d
chore: updates action versions
pravton 115d378
chore: updates comment regarding inactive element focus
pravton 46c4459
chore: updated the comment improving clarity
pravton d12c356
chore: updates the example with render prop
pravton 5395482
chore: removed un-used markdown page
pravton a849eb8
chore: updated pagination doc to refect the reason behind active item…
pravton a832c9c
Revert "chore: updated the comment improving clarity"
pravton d18e29f
chore: removed inline style suggesting reference
pravton 660c3d5
chore: removed unrelated comment
pravton f75a551
chore: removed inline style related comment
pravton 073aa18
chore: removed on change event example on the demo
pravton 379f911
chore: updates inert related comment on accesibilty.md
pravton 6d4d54a
chore: adds reusable mdx for snippets being used in multiple places
pravton e969517
chore: removed css custom prop md and combined with style.md
pravton ee4923a
chore: updates the wording emphasize default layout css props
pravton c2f357d
chore: updates comment regarding focus shift on active item
pravton e69b9fe
chore: updates renderNavItem example
pravton f97b0cd
chore: fixes broken links
pravton 3ee8738
chore: fixes the path
pravton 2868bf9
chore: deletes non relevant comment regarding accessibilty
pravton a663d7b
chore: updates default layout comment
pravton 6bd8ebc
chore: updates logo and the footer links
pravton 7d43378
Merge branch 'main' into feature/docs-and-demos
pravton ac53c91
chore: updates packages
pravton 83bc06c
chore: updates to render the version on header and the link
pravton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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=<Your GitHub username> 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "label": "API", | ||
| "position": 4, | ||
| "link": { | ||
| "type": "generated-index" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| --- | ||
| sidebar_position: 3 | ||
| --- | ||
|
|
||
| # GalleryItem | ||
|
|
||
| Wraps a single gallery item. It renders an `<li>` and sets the attributes and CSS custom properties the stylesheet uses to position it. Always return it from `renderGalleryItem` on [`<GalleryMain>`](/docs/api/gallery-main). | ||
|
|
||
| ```jsx | ||
| <GalleryMain | ||
| renderGalleryItem={({ item, index, active }) => ( | ||
| <GalleryItem key={item.id} index={index} active={active}> | ||
| <img src={item.image} alt={item.alt} /> | ||
| </GalleryItem> | ||
| )} | ||
| /> | ||
| ``` | ||
|
|
||
| ## 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 `<li>`. Use it with `active` for state styling. | | ||
| Any other `<li>` 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 `<li>`. 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). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 `<ul>` and calls `renderGalleryItem` once for each entry in the `items` array passed to [`<Gallery>`](/docs/api/gallery). Must be used inside a `<Gallery>`. | ||
|
|
||
| <Tabs groupId="code-language"> | ||
| <TabItem value="ts" label="TypeScript" default> | ||
|
|
||
| ```tsx | ||
| <GalleryMain<Item> | ||
| renderGalleryItem={({ item, index, active }) => ( | ||
| <GalleryItem key={item.id} index={index} active={active}> | ||
| <img src={item.image} alt={item.alt} /> | ||
| </GalleryItem> | ||
| )} | ||
| /> | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="js" label="JavaScript"> | ||
|
|
||
| ```jsx | ||
| <GalleryMain | ||
| renderGalleryItem={({ item, index, active }) => ( | ||
| <GalleryItem key={item.id} index={index} active={active}> | ||
| <img src={item.image} alt={item.alt} /> | ||
| </GalleryItem> | ||
| )} | ||
| /> | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| ## Props | ||
|
|
||
| TypeScript: `GalleryMainProps<T>`. Pass your item type as `<GalleryMain<Item>>`, or `item` is `unknown`; the [TypeScript guide](/docs/guides/typescript) explains why. | ||
|
|
||
| | Prop | Type | Required | Description | | ||
| | --- | --- | --- | --- | | ||
| | `renderGalleryItem` | `(args: RenderGalleryItemArgs<T>) => ReactNode` | yes | Called for each item. Must return a [`<GalleryItem>`](/docs/api/gallery-item). | | ||
| | `className` | `string` | | Extra class for the `<ul>`. | | ||
| Any other `<ul>` attributes (`id`, `aria-label`, `data-*`, ...) are passed through to the list. | ||
|
|
||
| ## renderGalleryItem arguments | ||
|
|
||
| TypeScript: `RenderGalleryItemArgs<T>`. | ||
|
|
||
| | Field | Type | Description | | ||
| | --- | --- | --- | | ||
| | `item` | `T` | This item's entry from the `items` array. | | ||
| | `index` | `number` | This item's index. | | ||
| | `active` | `boolean` | Whether this item is the active one. | | ||
| | `activeIndex` | `number` | Index of the active item. | | ||
|
|
||
| ## Layout | ||
|
|
||
| With the base stylesheet, the `<ul>` is a CSS grid with a single cell. Every item sits in that cell and is moved sideways with a `transform` built from [Styling](/docs/guides/styling). Remove the transform in your own item CSS and the items stack instead, which is a starting point for a fading gallery. | ||
|
|
||
| `GalleryMain` sets two of those properties on the `<ul>`: `--selected` (the active index) and `--total` (the number of items). | ||
|
|
||
| ## Dragging | ||
|
|
||
| When `<Gallery>` has `draggable` on (the default), `GalleryMain` handles pointer events on the list: | ||
|
|
||
| - A horizontal drag of more than 10px starts moving the items with the pointer, through `--touch-offset`. | ||
| - If the pointer moves more than 20px vertically before a horizontal drag starts, it is treated as page scrolling and the drag is ignored. | ||
| - Releasing after a drag longer than `swipeThreshold` (50px) goes to the next item (dragged left) or the previous one (dragged right). Shorter drags snap back. | ||
|
|
||
| The base stylesheet sets `touch-action: pan-y` on draggable galleries so vertical page scrolling still works on touch screens. | ||
|
pravton marked this conversation as resolved.
Resolved
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.