Skip to content

Commit 79b0bc4

Browse files
author
1360151219
committed
Merge branch 'master' into develop
2 parents 10ee0ca + 1e6a6a7 commit 79b0bc4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1656
-787
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"editor.formatOnSave": true, // optional
66
"editor.formatOnSaveMode": "file",
77
"[typescriptreact]": {
8-
"editor.defaultFormatter": "esbenp.prettier-vscode"
8+
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
99
},
1010
"[scss]": {
1111
"editor.defaultFormatter": "esbenp.prettier-vscode"

packages/demo/index.scss

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,55 @@ h3 {
5858
font-size: 18px;
5959
}
6060

61+
62+
63+
.pivot-code-box {
64+
position: relative;
65+
display: inline-block;
66+
width: 100%;
67+
margin: 16px 0;
68+
overflow: hidden;
69+
border: 1px solid rgba(5, 5, 5, 0.06);
70+
border-radius: 6px;
71+
-webkit-transition: all 0.2s;
72+
transition: all 0.2s;
73+
&-actions {
74+
display: flex;
75+
flex-direction: row-reverse;
76+
padding: 4px 8px;
77+
.pivot-code-box-icon {
78+
width: 20px;
79+
height: 20px;
80+
cursor: pointer;
81+
img {
82+
width: 100%;
83+
height: 100%;
84+
}
85+
}
86+
}
87+
&-demo {
88+
padding: 24px 30px;
89+
display: flex;
90+
border-bottom: 1px solid rgba(5, 5, 5, 0.06);
91+
flex-wrap: wrap;
92+
justify-content: center;
93+
align-items: center;
94+
> :not(.PIVOT-draggable-item) {
95+
margin: 0 24px;
96+
}
97+
}
98+
99+
.line-numbers {
100+
//width: 100%;
101+
.code-toolbar {
102+
.data-prismjs-copy {
103+
//width: 70vw;
104+
//width: 100%;
105+
overflow: auto;
106+
}
107+
}
108+
}
109+
}
61110
.demo-draggable-item {
62111
color: #fff;
63112
background-color: #3685f5;
6 KB
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { DndContext, DraggableItem } from 'pivot-design';
2+
import React, { useState } from 'react';
3+
const Basic: React.FC = () => {
4+
const [coordinates, setCoordinates] = useState({ x: 0, y: 0 });
5+
const onDragEnd = (e) => {
6+
const { delta } = e;
7+
setCoordinates(({ x, y }) => {
8+
return {
9+
x: x + delta.x,
10+
y: y + delta.y,
11+
};
12+
});
13+
};
14+
return (
15+
<DndContext onDragEnd={onDragEnd}>
16+
<DraggableItem id="draggable" className="demo-draggable-item" left={coordinates.x} top={coordinates.y}>
17+
Drag Me!
18+
</DraggableItem>
19+
</DndContext>
20+
);
21+
};
22+
export default Basic;

packages/demo/src/components/Draggable/demo/ButtonOnClick.tsx

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { DndContext, DraggableItem, Droppable } from 'pivot-design';
2+
import React, { useState } from 'react';
3+
const Basic: React.FC = () => {
4+
const [parent, setParent] = useState('');
5+
const onDragEnd = ({ id, isDrop }) => {
6+
setParent(isDrop ? id : '');
7+
};
8+
return (
9+
<DndContext onDragEnd={onDragEnd}>
10+
<div style={{ minWidth: '150px', display: 'flex' }}>
11+
{parent !== 'A' ? (
12+
<DraggableItem className="demo-draggable-item" id={'A'}>
13+
draggable
14+
</DraggableItem>
15+
) : null}
16+
</div>
17+
<Droppable style={{ textAlign: 'center' }}>
18+
{parent === 'A' ? (
19+
<DraggableItem className="demo-draggable-item" id={'A'}>
20+
draggable
21+
</DraggableItem>
22+
) : null}
23+
</Droppable>
24+
</DndContext>
25+
);
26+
};
27+
export default Basic;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.demo-sortable-wrap {
2+
display: flex;
3+
width: 100%;
4+
justify-content: center;
5+
align-items: center;
6+
7+
&.__demo-sortable-grid {
8+
width: 600px;
9+
flex-wrap: wrap;
10+
.demo-sortable-item {
11+
height: 150px;
12+
width: 150px;
13+
padding: 0;
14+
margin: 10px;
15+
line-height: 150px;
16+
text-align: center;
17+
}
18+
}
19+
.demo-sortable-item {
20+
background-color: #6193f0;
21+
color: #fff;
22+
text-align: center;
23+
padding: 12px 0;
24+
margin: 8px 0;
25+
border-radius: 16px;
26+
cursor: grab;
27+
cursor: -webkit-grab;
28+
user-select: none;
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { arrayMove, DndContext, SortableContext, SortableItem } from 'pivot-design';
2+
import { DragEndEvent } from 'pivot-design/components/Draggable/sensors/events';
3+
import { useState } from 'react';
4+
import './GridSortable.scss';
5+
const Container = ({ children }) => {
6+
return <div className={'demo-sortable-wrap __demo-sortable-grid'}>{children}</div>;
7+
};
8+
const GridSortable = () => {
9+
const [items, setItems] = useState([1, 2, 3, 4, 5, 6, 7, 8, 9]);
10+
const reorderItems = ({ active, over }: DragEndEvent) => {
11+
setItems((items) => arrayMove(items, active.index, over.index));
12+
};
13+
return (
14+
<DndContext onDragEnd={reorderItems}>
15+
<SortableContext items={items} id="A" type="grid">
16+
<Container>
17+
{items.map((item, index) => {
18+
return (
19+
<SortableItem id={item} className="demo-sortable-item" key={index} index={index}>
20+
{item}
21+
</SortableItem>
22+
);
23+
})}
24+
</Container>
25+
</SortableContext>
26+
</DndContext>
27+
);
28+
};
29+
30+
export default GridSortable;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.demo-sortable-wrap {
2+
display: flex;
3+
width: 100%;
4+
justify-content: center;
5+
align-items: center;
6+
7+
8+
&.__demo-sortable-horizen {
9+
justify-content: space-around;
10+
.demo-sortable-item {
11+
width: 14%;
12+
}
13+
}
14+
15+
16+
.demo-sortable-item {
17+
background-color: #6193f0;
18+
color: #fff;
19+
text-align: center;
20+
padding: 12px 0;
21+
margin: 8px 0;
22+
border-radius: 16px;
23+
cursor: grab;
24+
cursor: -webkit-grab;
25+
user-select: none;
26+
}
27+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { arrayMove, DndContext, SortableContext, SortableItem } from 'pivot-design';
2+
import { DragEndEvent } from 'pivot-design/components/Draggable/sensors/events';
3+
import { useState } from 'react';
4+
import './HorizenSortable.scss';
5+
const Container = ({ children }) => {
6+
return <div className={'demo-sortable-wrap __demo-sortable-horizen'}>{children}</div>;
7+
};
8+
const HorizenSortable = () => {
9+
const [items, setItems] = useState([1, 2, 3, 4, 5]);
10+
const reorderItems = ({ active, over }: DragEndEvent) => {
11+
setItems((items) => arrayMove(items, active.index, over.index));
12+
};
13+
return (
14+
<DndContext onDragEnd={reorderItems}>
15+
<SortableContext items={items} id="A" type="horizen">
16+
<Container>
17+
{items.map((item, index) => {
18+
return (
19+
<SortableItem id={item} className="demo-sortable-item" key={index} index={index}>
20+
{item}
21+
</SortableItem>
22+
);
23+
})}
24+
</Container>
25+
</SortableContext>
26+
</DndContext>
27+
);
28+
};
29+
30+
export default HorizenSortable;

0 commit comments

Comments
 (0)