Skip to content

Commit ec096a5

Browse files
committed
docs: remove example cross-referencing
1 parent ba4ec05 commit ec096a5

File tree

15 files changed

+228
-20
lines changed

15 files changed

+228
-20
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@
105105
"testMatch": [
106106
"<rootDir>/packages/**/__tests__/**/?(*.)(spec|test).(t|j)s(x|)"
107107
],
108+
"testPathIgnorePatterns": [
109+
"/packages/documentation/static/",
110+
"/packages/documentation/public/"
111+
],
108112
"transform": {
109113
"^.+\\.(ts|tsx)$": "ts-jest"
110114
},

packages/examples-hooks/src/01-dustbin/copy-or-move/Box.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import ItemTypes from '../single-target/ItemTypes'
2+
import ItemTypes from './ItemTypes'
33

44
import { __EXPERIMENTAL_DND_HOOKS_THAT_MAY_CHANGE_AND_BREAK_MY_BUILD__ } from 'react-dnd'
55
const {

packages/examples-hooks/src/01-dustbin/copy-or-move/Dustbin.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { __EXPERIMENTAL_DND_HOOKS_THAT_MAY_CHANGE_AND_BREAK_MY_BUILD__ } from 'react-dnd'
3-
import ItemTypes from '../single-target/ItemTypes'
3+
import ItemTypes from './ItemTypes'
44
const {
55
useDrop,
66
} = __EXPERIMENTAL_DND_HOOKS_THAT_MAY_CHANGE_AND_BREAK_MY_BUILD__
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
BOX: 'box',
3+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react'
2+
import { __EXPERIMENTAL_DND_HOOKS_THAT_MAY_CHANGE_AND_BREAK_MY_BUILD__ } from 'react-dnd'
3+
import ItemTypes from './ItemTypes'
4+
const {
5+
useDrag,
6+
} = __EXPERIMENTAL_DND_HOOKS_THAT_MAY_CHANGE_AND_BREAK_MY_BUILD__
7+
8+
const style: React.CSSProperties = {
9+
border: '1px dashed gray',
10+
backgroundColor: 'white',
11+
padding: '0.5rem 1rem',
12+
marginRight: '1.5rem',
13+
marginBottom: '1.5rem',
14+
cursor: 'move',
15+
float: 'left',
16+
}
17+
18+
interface BoxProps {
19+
name: string
20+
}
21+
22+
const Box: React.FC<BoxProps> = ({ name }) => {
23+
const [{ isDragging }, drag] = useDrag({
24+
item: { name, type: ItemTypes.BOX },
25+
end: (dropResult?: { name: string }) => {
26+
if (dropResult) {
27+
alert(`You dropped ${name} into ${dropResult.name}!`)
28+
}
29+
},
30+
collect: monitor => ({
31+
isDragging: monitor.isDragging(),
32+
}),
33+
})
34+
const opacity = isDragging ? 0.4 : 1
35+
36+
return (
37+
<div ref={drag} style={{ ...style, opacity }}>
38+
{name}
39+
</div>
40+
)
41+
}
42+
43+
export default Box
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React from 'react'
2+
import { __EXPERIMENTAL_DND_HOOKS_THAT_MAY_CHANGE_AND_BREAK_MY_BUILD__ } from 'react-dnd'
3+
import ItemTypes from './ItemTypes'
4+
5+
const {
6+
useDrop,
7+
} = __EXPERIMENTAL_DND_HOOKS_THAT_MAY_CHANGE_AND_BREAK_MY_BUILD__
8+
9+
const style: React.CSSProperties = {
10+
height: '12rem',
11+
width: '12rem',
12+
marginRight: '1.5rem',
13+
marginBottom: '1.5rem',
14+
color: 'white',
15+
padding: '1rem',
16+
textAlign: 'center',
17+
fontSize: '1rem',
18+
lineHeight: 'normal',
19+
float: 'left',
20+
}
21+
22+
const Dustbin: React.FC = () => {
23+
const [{ canDrop, isOver }, drop] = useDrop({
24+
accept: ItemTypes.BOX,
25+
drop: () => ({ name: 'Dustbin' }),
26+
collect: monitor => ({
27+
isOver: monitor.isOver(),
28+
canDrop: monitor.canDrop(),
29+
}),
30+
})
31+
32+
const isActive = canDrop && isOver
33+
let backgroundColor = '#222'
34+
if (isActive) {
35+
backgroundColor = 'darkgreen'
36+
} else if (canDrop) {
37+
backgroundColor = 'darkkhaki'
38+
}
39+
40+
return (
41+
<div ref={drop} style={{ ...style, backgroundColor }}>
42+
{isActive ? 'Release to drop' : 'Drag a box here'}
43+
</div>
44+
)
45+
}
46+
47+
export default Dustbin
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
BOX: 'box',
3+
}

packages/examples-hooks/src/01-dustbin/single-target-in-iframe/index.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import {
66
DragDropContextProvider,
77
} from 'react-dnd'
88
import HTML5Backend from 'react-dnd-html5-backend'
9-
import Dustbin from '../single-target/Dustbin'
10-
import Box from '../single-target/Box'
11-
import { isDebugMode } from '../../isDebugMode'
9+
import Dustbin from './Dustbin'
10+
import Box from './Box'
1211

1312
const {
1413
default: Frame,
@@ -18,11 +17,7 @@ const {
1817
const FrameBindingContext: React.FC = ({ children }) => (
1918
<FrameContextConsumer>
2019
{({ window }: any) => (
21-
<DragDropContextProvider
22-
backend={HTML5Backend}
23-
context={window}
24-
debugMode={isDebugMode()}
25-
>
20+
<DragDropContextProvider backend={HTML5Backend} context={window}>
2621
{children}
2722
</DragDropContextProvider>
2823
)}

packages/examples/src/01-dustbin/copy-or-move/Box.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
DragSourceConnector,
66
DragSourceMonitor,
77
} from 'react-dnd'
8-
import ItemTypes from '../single-target/ItemTypes'
8+
import ItemTypes from './ItemTypes'
99

1010
const style: React.CSSProperties = {
1111
border: '1px dashed gray',

packages/examples/src/01-dustbin/copy-or-move/Dustbin.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { DropTarget, ConnectDropTarget } from 'react-dnd'
3-
import ItemTypes from '../single-target/ItemTypes'
3+
import ItemTypes from './ItemTypes'
44

55
const style: React.CSSProperties = {
66
height: '12rem',

0 commit comments

Comments
 (0)