Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update examples to link to JS and TS source code (#1252)
* docs: add a typescript mode for emitting JS-based documentation * docs: add links to ts and js examples, update documentation build * docs: run prettier over tsc output doc js docs * docs: use spaces with published javascript
- Loading branch information
1 parent
646a26c
commit f43fb00
Showing
23 changed files
with
110 additions
and
111 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,11 @@ | ||
{ | ||
"extends": "./tsconfig.esm.json", | ||
"compilerOptions": { | ||
"jsx": "preserve", | ||
"outDir": "./lib/docs", | ||
"baseUrl": "./", | ||
"declaration": false, | ||
"removeComments": false | ||
}, | ||
"include": ["./src/index.ts"] | ||
} |
This file contains 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.cache | ||
|
||
# Build directory | ||
/public | ||
/public | ||
/static/examples_js |
7 changes: 4 additions & 3 deletions
7
packages/documentation/markdown/examples/chessboard/tutorial.md
This file contains 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
9 changes: 5 additions & 4 deletions
9
packages/documentation/markdown/examples/customize/drop-effects.md
This file contains 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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
--- | ||
path: "/examples/customize/drop-effects" | ||
title: "Drop Effects" | ||
path: '/examples/customize/drop-effects' | ||
title: 'Drop Effects' | ||
--- | ||
|
||
[Browse the Source](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/05%20Customize/Drop%20Effects) | ||
[JavaScript](https://github.com/react-dnd/react-dnd/tree/gh-pages/examples_js/05%20Customize/Drop%20Effects) | ||
[TypeScript](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/05%20Customize/Drop%20Effects) | ||
|
||
Some browsers let you specify the “drop effects” for the draggable | ||
items. In the compatible browsers, you will see a “copy” icon when you | ||
drag the first box over the drop zone. | ||
|
||
<customize-drop-effects></customize-drop-effects> | ||
<customize-drop-effects></customize-drop-effects> |
9 changes: 5 additions & 4 deletions
9
packages/documentation/markdown/examples/customize/handles-and-previews.md
This file contains 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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
--- | ||
path: "/examples/customize/handles-and-previews" | ||
title: "Handles and Previews" | ||
path: '/examples/customize/handles-and-previews' | ||
title: 'Handles and Previews' | ||
--- | ||
|
||
[Browse the Source](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/05%20Customize/Handles%20and%20Previews) | ||
[JavaScript](https://github.com/react-dnd/react-dnd/tree/gh-pages/examples_js/05%20Customize/Handles%20and%20Previews) | ||
[TypeScript](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/05%20Customize/Handles%20and%20Previews) | ||
|
||
React DnD lets you choose the draggable node, as well as the drag | ||
preview node in your component's `render` function. | ||
You may also use an [Image](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image) instance that you created programmatically once it has loaded. | ||
|
||
<customize-handles-and-previews></customize-handles-and-previews> | ||
<customize-handles-and-previews></customize-handles-and-previews> |
11 changes: 4 additions & 7 deletions
11
packages/documentation/markdown/examples/drag-around/custom-drag-layer.md
This file contains 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 |
---|---|---|
@@ -1,27 +1,24 @@ | ||
--- | ||
path: "/examples/drag-around/custom-drag-layer" | ||
title: "Custom Drag Layer" | ||
path: '/examples/drag-around/custom-drag-layer' | ||
title: 'Custom Drag Layer' | ||
--- | ||
|
||
[Browse the Source](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/02%20Drag%20Around/Custom%20Drag%20Layer) | ||
[JavaScript](https://github.com/react-dnd/react-dnd/tree/gh-pages/examples_js/02%20Drag%20Around/Custom%20Drag%20Layer) | ||
[TypeScript](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/02%20Drag%20Around/Custom%20Drag%20Layer) | ||
|
||
The browser APIs provide no way to change the drag preview or its | ||
behavior once drag has started. Libraries such as jQuery UI implement | ||
the drag and drop from scratch to work around this, but react-dnd only | ||
supports browser drag and drop “backend” for now, so we have to accept | ||
its limitations. | ||
|
||
We can, however, customize behavior a great deal if we feed the | ||
browser an empty image as drag preview. This library provides a | ||
`DragLayer` that you can use to implement a fixed layer on | ||
top of your app where you'd draw a custom drag preview component. | ||
|
||
Note that we can draw a completely different component on our drag | ||
layer if we wish so. It's not just a screenshot. | ||
|
||
With this approach, we miss out on default “return” animation when | ||
dropping outside the container. However, we get great flexibility in | ||
customizing drag feedback and zero flicker. | ||
|
||
<drag-around-custom-drag-layer></drag-around-custom-drag-layer> | ||
|
7 changes: 4 additions & 3 deletions
7
packages/documentation/markdown/examples/drag-around/naive.md
This file contains 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
7 changes: 4 additions & 3 deletions
7
packages/documentation/markdown/examples/dustbin/copy-or-move.md
This file contains 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
This file contains 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
12 changes: 6 additions & 6 deletions
12
packages/documentation/markdown/examples/dustbin/multiple-targets.md
This file contains 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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
--- | ||
path: "/examples/dustbin/multiple-targets" | ||
title: "Multiple Targets" | ||
path: '/examples/dustbin/multiple-targets' | ||
title: 'Multiple Targets' | ||
--- | ||
[Browse the Source](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/01%20Dustbin/Multiple%20Targets) | ||
|
||
|
||
[JavaScript](https://github.com/react-dnd/react-dnd/tree/gh-pages/examples_js/01%20Dustbin/Multiple%20Targets) | ||
[TypeScript](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/01%20Dustbin/Multiple%20Targets) | ||
|
||
This is a slightly more interesting example. | ||
|
||
It demonstrates how a single drop target may accept multiple types, | ||
and how those types may be derived from props. It also demonstrates | ||
the handling of native files and URLs (try dropping them onto the last | ||
two dustbins). | ||
|
||
<dustbin-multiple-targets></dustbin-multiple-targets> | ||
<dustbin-multiple-targets></dustbin-multiple-targets> |
7 changes: 4 additions & 3 deletions
7
packages/documentation/markdown/examples/dustbin/single-target.md
This file contains 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
10 changes: 5 additions & 5 deletions
10
packages/documentation/markdown/examples/dustbin/stress-test.md
This file contains 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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
--- | ||
path: "/examples/dustbin/stress-test" | ||
title: "Stress Test" | ||
path: '/examples/dustbin/stress-test' | ||
title: 'Stress Test' | ||
--- | ||
|
||
[Browse the Source](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/01%20Dustbin/Stress%20Test) | ||
[JavaScript](https://github.com/react-dnd/react-dnd/tree/gh-pages/examples_js/01%20Dustbin/Stress%20Test) | ||
[TypeScript](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/01%20Dustbin/Stress%20Test) | ||
|
||
This example is similar to the previous one, but props of both the | ||
drag sources and the drop targets change every second. It demonstrates | ||
that React DnD keeps track of the changing props, and if a component | ||
receives the new props, React DnD recalculates the drag and drop | ||
state. It also shows how a custom `isDragging` implementation can make the drag source appear as dragged, even if the component that initiated the drag has received new props. | ||
|
||
|
||
<dustbin-stress-test></dustbin-stress-test> | ||
<dustbin-stress-test></dustbin-stress-test> |
7 changes: 4 additions & 3 deletions
7
packages/documentation/markdown/examples/dustbin/using-fcs.md
This file contains 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
10 changes: 6 additions & 4 deletions
10
packages/documentation/markdown/examples/nesting/drag-sources.md
This file contains 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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
--- | ||
path: "/examples/nesting/drag-sources" | ||
title: "Drag Sources" | ||
path: '/examples/nesting/drag-sources' | ||
title: 'Drag Sources' | ||
--- | ||
[Browse the Source](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/03%20Nesting/Drag%20Sources) | ||
|
||
[JavaScript](https://github.com/react-dnd/react-dnd/tree/gh-pages/examples_js/03%20Nesting/Drag%20Sources) | ||
[TypeScript](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/03%20Nesting/Drag%20Sources) | ||
|
||
You can nest the drag sources in one another. If a nested drag source | ||
returns `false` from `canDrag`, its parent will | ||
be asked, until a draggable source is found and activated. Only the | ||
activated drag source will have its `beginDrag()` and | ||
`endDrag()` called. | ||
|
||
<nesting-drag-sources></nesting-drag-sources> | ||
<nesting-drag-sources></nesting-drag-sources> |
12 changes: 7 additions & 5 deletions
12
packages/documentation/markdown/examples/nesting/drop-targets.md
This file contains 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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
--- | ||
path: "/examples/nesting/drop-targets" | ||
title: "Drop Targets" | ||
path: '/examples/nesting/drop-targets' | ||
title: 'Drop Targets' | ||
--- | ||
[Browse the Source](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/03%20Nesting/Drop%20Targets) | ||
|
||
[JavaScript](https://github.com/react-dnd/react-dnd/tree/gh-pages/examples_js/03%20Nesting/Drop%20Targets) | ||
[TypeScript](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/03%20Nesting/Drop%20Targets) | ||
|
||
Drop targets can, too, be nested in one another. Unlike the drag | ||
sources, several drop targets may react to the same item being | ||
dragged. | ||
dragged. | ||
|
||
React DnD by design offers no means of stopping propagation. Instead, the drop targets may compare `monitor.isOver()` and `monitor.isOver({ shallow: false })` to learn if just them, or their nested targets, are being hovered. They may also check `monitor.didDrop()` and `monitor.getDropResult()` to learn if a nested target has already handled the drop, and even return a different drop result. | ||
React DnD by design offers no means of stopping propagation. Instead, the drop targets may compare `monitor.isOver()` and `monitor.isOver({ shallow: false })` to learn if just them, or their nested targets, are being hovered. They may also check `monitor.didDrop()` and `monitor.getDropResult()` to learn if a nested target has already handled the drop, and even return a different drop result. | ||
|
||
<nesting-drop-targets></nesting-drop-targets> |
10 changes: 6 additions & 4 deletions
10
packages/documentation/markdown/examples/other/native-files.md
This file contains 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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
--- | ||
path: "/examples/other/native-files" | ||
title: "Native Files" | ||
path: '/examples/other/native-files' | ||
title: 'Native Files' | ||
--- | ||
[Browse the Source](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/06%20Other/Native%20Files) | ||
|
||
[JavaScript](https://github.com/react-dnd/react-dnd/tree/gh-pages/examples_js/06%20Other/Native%20Files) | ||
[TypeScript](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/06%20Other/Native%20Files) | ||
|
||
Example demonstrating drag and drop of native files. | ||
|
||
<other-native-files></other-native-files> | ||
<other-native-files></other-native-files> |
11 changes: 6 additions & 5 deletions
11
packages/documentation/markdown/examples/sortable/cancel-on-drop-outside.md
This file contains 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
10 changes: 6 additions & 4 deletions
10
packages/documentation/markdown/examples/sortable/simple.md
This file contains 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 |
---|---|---|
@@ -1,11 +1,13 @@ | ||
--- | ||
path: "/examples/sortable/simple" | ||
title: "Simple" | ||
path: '/examples/sortable/simple' | ||
title: 'Simple' | ||
--- | ||
[Browse the Source](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/04%20Sortable/Simple) | ||
|
||
[JavaScript](https://github.com/react-dnd/react-dnd/tree/gh-pages/examples_js/04%20Sortable/Simple) | ||
[TypeScript](https://github.com/react-dnd/react-dnd/tree/master/packages/documentation-examples/src/04%20Sortable/Simple) | ||
|
||
It is easy to implement a sortable interface with React DnD. Just make | ||
the same component both a drag source and a drop target, and reorder | ||
the data in the `hover` handler. | ||
|
||
<sortable-simple></sortable-simple> | ||
<sortable-simple></sortable-simple> |
This file contains 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
This file contains 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
Oops, something went wrong.