Skip to content

Commit 3c71d46

Browse files
committed
order design and functional fixes
1 parent 53f16e8 commit 3c71d46

File tree

5 files changed

+32
-11
lines changed

5 files changed

+32
-11
lines changed

client/src/NoteComponents/ModalNoteEdit.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,13 @@ function ModalNoteEdit() {
140140
<div>
141141
<Palette
142142
className="btn btn-light mx-1"
143+
style={{ boxShadow: "none" }}
143144
disabled={!note}
144145
setColor={tryChangeColor}
145146
></Palette>
146147
<button
147148
className="btn btn-light"
149+
style={{ boxShadow: "none" }}
148150
disabled={!note}
149151
onClick={tryRemove}
150152
><i className="bi bi-trash text-dark"></i></button>
@@ -157,6 +159,7 @@ function ModalNoteEdit() {
157159
<div>
158160
<button
159161
className="btn btn-light"
162+
style={{ boxShadow: "none" }}
160163
onClick={tryClose}
161164
>Close</button>
162165
</div>

client/src/NoteComponents/NoteItem.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ function NoteItem({ note = new Note(), index }) {
2525
const lineClip = 12
2626
const bgColor = note.color
2727

28+
const footerBtn = {
29+
className: `btn btn-light p-0 text-secondary item-footer-btn`,
30+
style: {
31+
width: "1.8em", height: "1.8em", float: "right",
32+
borderColor: "transparent",
33+
backgroundColor: "transparent",
34+
boxShadow: "none"
35+
}
36+
}
37+
2838
return (
2939
<div className="p-1" >
3040
<div className="card" style={{ backgroundColor: bgColor }} >
@@ -44,16 +54,16 @@ function NoteItem({ note = new Note(), index }) {
4454
{/**Кнопки изменения порядка */}
4555
<div className="card-body pt-0">
4656
<button
47-
className={`btn btn-light p-0`}
48-
style={{ width: "1.8em", height: "1.8em", float: "right", borderColor: "transparent", backgroundColor: "transparent" }}
49-
onClick={() => editNoteOrder(index, Number(note.order) - 1)}
57+
className={footerBtn.className}
58+
style={footerBtn.style}
59+
onClick={() => editNoteOrder(index, false)}
5060
>
5161
&#10097;
5262
</button>
5363
<button
54-
className={`btn btn-light p-0`}
55-
style={{ width: "1.8em", height: "1.8em", float: "right", borderColor: "transparent", backgroundColor: "transparent" }}
56-
onClick={() => editNoteOrder(index, Number(note.order) + 1)}
64+
className={footerBtn.className}
65+
style={footerBtn.style}
66+
onClick={() => editNoteOrder(index, true)}
5767
>
5868
&#10096;
5969
</button>

client/src/Pages/NotesPage.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,11 @@
2626
display: inline-block;
2727
transform: rotate(90deg);
2828
}
29+
30+
.item-footer-btn {
31+
transition: opacity 0.15s !important;
32+
opacity: 0.2 !important;
33+
}
34+
.item-footer-btn:hover {
35+
opacity: 0.9 !important;
36+
}

client/src/Pages/NotesPage.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ function NotesPage() {
142142

143143
/**
144144
* Изменение порядка заметки
145-
* @param {*} index
146-
* @param {*} order
145+
* @param {number} index
146+
* @param {boolean} orderOperationFlag
147147
*/
148-
function editNoteOrder(index, order) {
148+
function editNoteOrder(index, orderOperationFlag) {
149149
if (notesArr[index]) {
150-
notesArr[index].order = order
150+
notesArr[index].order += orderOperationFlag ? 2 : -2
151151
let fixedArr = fixOrders(notesArr)
152152
setNotesArr(fixedArr)
153153
fixedArr.forEach((note) => {

client/src/Shared/order.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function calcOrder(notesArr = []) {
3030
*/
3131
export function fixOrders(notesArr = []) {
3232
let fixedArr = notesArr
33-
const sortedArr = Array.isArray(notesArr) ? notesArr.sort(sortByOrder) : []
33+
const sortedArr = Array.isArray(notesArr) ? notesArr.sort(sortByOrder).reverse() : []
3434
sortedArr.forEach((sortedNote, sortedNoteIndex) => {
3535
fixedArr.forEach((note) => {
3636
if (note.id === sortedNote.id) note.order = sortedNoteIndex

0 commit comments

Comments
 (0)