Skip to content
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

Update docs #61

Merged
merged 4 commits into from
Mar 21, 2023
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
9 changes: 9 additions & 0 deletions docs/adapters/react-ranger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: React Router
---

You can install TanStack Router with any [NPM](https://npmjs.com) package manager.

```sh
npm install @tanstack/react-ranger
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
94 changes: 94 additions & 0 deletions docs/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"docSearch": {
"appId": "FQ0DQ6MA3C",
"apiKey": "8264730bab8a9b7fa6a0c85761d7a3fe",
"indexName": "tanstack"
},
"menu": [
{
"label": "Getting Started",
"children": [
{
"label": "Overview",
"to": "overview"
},
{
"label": "Installation",
"to": "installation"
},
{
"label": "Quick Start",
"to": "quick-start"
}
]
},
{
"label": "Adapters",
"children": [
{
"label": "React",
"to": "adapters/react-ranger"
}
]
},
{
"label": "API",
"children": [
{
"label": "Core API",
"to": "api/core"
}
]
},
{
"label": "React Ranger",
"children": [
{
"label": "Basic",
"to": "api/react/basic"
},
{
"label": "Custom Steps",
"to": "api/react/custom-steps"
},
{
"label": "Custom Styles",
"to": "api/react/custom-styles"
},
{
"label": "Logarithmic Interpolator",
"to": "api/react/logarithmic-interpolator"
},
{
"label": "Update on Drag",
"to": "api/react/update-on-drag"
}
]
},
{
"label": "React Examples",
"children": [
{
"label": "Basic",
"to": "examples/react/basic?file=src%2Fmain.tsx"
},
{
"label": "Custom Steps",
"to": "examples/react/custom-steps?file=src%2Fmain.tsx"
},
{
"label": "Custom Styles",
"to": "examples/react/custom-styles?file=src%2Fmain.tsx"
},
{
"label": "Logarithmic Interpolator",
"to": "examples/react/logarithmic-interpolator?file=src%2Fmain.tsx"
},
{
"label": "Update on Drag",
"to": "examples/react/update-on-drag?file=src%2Fmain.tsx"
}
]
}
]
}
27 changes: 8 additions & 19 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
---
name: Installation
route: /installation
title: Installation
---

# Installation
You can install TanStack Ranger with any [NPM](https://npmjs.com) package manager.

Install React Ranger as a dependency using `npm` or `yarn`
Depending on your framework of choice, install one of the following packages:

```bash
# NPM
$ npm install react-ranger

# Yarn
$ yarn add react-ranger
```

To import React Ranger:

```js
import { useRanger } from '@tanstack/react-ranger'
```

Once you've installed React Ranger, continue to [Concepts](./concepts) to read more about how to utilize its API
- [React](./adapters/react-ranger)
- Solid (coming soon!)
- Vue (coming soon!)
- Svelte (coming soon!)
- Angular (coming soon!)
15 changes: 15 additions & 0 deletions docs/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Overview
---

Feature Rich and Lightweight Headless utility, which means out of the box, it doesn't render or supply any actual UI elements. Some of its features include:

- 100% Typesafe
- Lightweight (10kb)
- Easy to maintain
- Extensible
- Not dictating UI

## Let's go!

Enough overview, there's so much more to do with TanStack Ranger. Hit that next button and let's get started!
112 changes: 112 additions & 0 deletions docs/quick-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
title: Quick Start
---

If you're feeling impatient and prefer to skip all of our wonderful documentation, here is the bare minimum to get going with TanStack Router. We'll use React for this example, but the same principles apply to other frameworks.

```tsx
import React from 'react'
import ReactDOM from 'react-dom'
import { useRanger, Ranger } from '@tanstack/react-ranger'

function App() {
const rangerRef = React.useRef<HTMLDivElement>(null)
const [values, setValues] = React.useState<ReadonlyArray<number>>([
10, 15, 50,
])

const rangerInstance = useRanger<HTMLDivElement>({
getRangerElement: () => rangerRef.current,
values,
min: 0,
max: 100,
stepSize: 5,
onChange: (instance: Ranger<HTMLDivElement>) =>
setValues(instance.sortedValues),
})

return (
<div className="App" style={{ padding: 10 }}>
<h1>Basic Range</h1>
<span>Active Index: {rangerInstance.activeHandleIndex}</span>
<br />
<br />
<div
ref={rangerRef}
style={{
position: 'relative',
userSelect: 'none',
height: '4px',
background: '#ddd',
boxShadow: 'inset 0 1px 2px rgba(0,0,0,.6)',
borderRadius: '2px',
}}
>
{rangerInstance
.handles()
.map(
(
{
value,
onKeyDownHandler,
onMouseDownHandler,
onTouchStart,
isActive,
},
i,
) => (
<button
key={i}
onKeyDown={onKeyDownHandler}
onMouseDown={onMouseDownHandler}
onTouchStart={onTouchStart}
role="slider"
aria-valuemin={rangerInstance.options.min}
aria-valuemax={rangerInstance.options.max}
aria-valuenow={value}
style={{
position: 'absolute',
top: '50%',
left: `${rangerInstance.getPercentageForValue(value)}%`,
zIndex: isActive ? '1' : '0',
transform: 'translate(-50%, -50%)',
width: '14px',
height: '14px',
outline: 'none',
borderRadius: '100%',
background: 'linear-gradient(to bottom, #eee 45%, #ddd 55%)',
border: 'solid 1px #888',
}}
/>
),
)}
</div>
<br />
<br />
<br />
<pre
style={{
display: 'inline-block',
textAlign: 'left',
}}
>
<code>
{JSON.stringify({
values,
})}
</code>
</pre>
</div>
)
}

ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root'),
)

```

If you skipped this example or didn't understand something, we don't blame you, because there's so much more to learn to really take advantage of TanStack Router! Let's move on.
12 changes: 12 additions & 0 deletions examples/react/basic/tsconfig.dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"composite": true,
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./build/types"
},
"files": ["src/main.tsx"],
"include": [
"src"
// "__tests__/**/*.test.*"
]
}
13 changes: 4 additions & 9 deletions examples/react/basic/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{
"composite": true,
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./build/types"
},
"files": ["src/main.tsx"],
"include": [
"src"
// "__tests__/**/*.test.*"
]
"strict": true,
"esModuleInterop": true,
"jsx": "react"
}
}