Skip to content

Commit

Permalink
Merge pull request #31 from ThuanTheSecond/main
Browse files Browse the repository at this point in the history
Solves issue 30#
  • Loading branch information
VBproDev authored Nov 12, 2024
2 parents a4b71e4 + 348f4cc commit ddff7ec
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 2 deletions.
7 changes: 7 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@
</head>

<body>
<div class="d-flex justify-content-center">
<div class="popup_saved d-flex align-items-center bg-success text-white rounded-pill py-2 px-4 position-fixed top-0 mt-3 transition-opacity">
<span>Design has been saved</span>
<button class="btn-close btn-close-white ms-2" aria-label="Close"></button>
</div>
</div>

<div class="d-flex justify-content-center p-2">
<h4 class="me-1">Line Color:</h4>
<input class="color me-3" type="color" />
Expand Down
2 changes: 1 addition & 1 deletion min/script.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion min/stylesheet.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const ctx = canvas.getContext('2d');
const design = document.querySelector('.design');
const userDesign = document.querySelector('.user-design');
const save = document.querySelector('.save');
const popup_saved = document.querySelector('.popup_saved');
const curveInputContainer = document.querySelector('.curve-input-container');
const btnClose = document.querySelector('.btn-close');
const localCanvas = localStorage.getItem('canvasArray');
const previewLineHandler = (e) => {
clear();
Expand Down Expand Up @@ -339,6 +341,15 @@ set === null || set === void 0 ? void 0 : set.addEventListener('click', () => {
});
save === null || save === void 0 ? void 0 : save.addEventListener('click', () => {
localStorage.setItem('canvasArray', JSON.stringify(canvasArray));
num = num + canvasArray.length;
popup_saved.classList.add('show');
btnClose === null || btnClose === void 0 ? void 0 : btnClose.addEventListener('click', () => {
clearTimeout(saveTimer);
popup_saved.classList.remove('show');
});
const saveTimer = setTimeout(() => {
popup_saved.classList.remove('show');
}, 2300);
});
userDesign === null || userDesign === void 0 ? void 0 : userDesign.addEventListener('click', () => {
clear();
Expand Down
13 changes: 13 additions & 0 deletions script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const ctx = canvas.getContext('2d');
const design = document.querySelector('.design') as HTMLInputElement;
const userDesign = document.querySelector('.user-design');
const save = document.querySelector('.save');
const popup_saved = document.querySelector('.popup_saved') as HTMLDivElement;
const curveInputContainer = document.querySelector('.curve-input-container')!;
const btnClose = document.querySelector('.btn-close');
const localCanvas = localStorage.getItem('canvasArray');

const previewLineHandler = (e: MouseEvent | PointerEvent) => {
Expand Down Expand Up @@ -361,6 +363,17 @@ set?.addEventListener('click', () => {

save?.addEventListener('click', () => {
localStorage.setItem('canvasArray', JSON.stringify(canvasArray));
num = num + canvasArray.length;
popup_saved.classList.add('show');

btnClose?.addEventListener('click', () => {
clearTimeout(saveTimer);
popup_saved.classList.remove('show');
})

const saveTimer = setTimeout(() => {
popup_saved.classList.remove('show');
}, 2300);
});

userDesign?.addEventListener('click', () => {
Expand Down
Loading

0 comments on commit ddff7ec

Please sign in to comment.