diff --git a/button-ripple-effect/script.js b/button-ripple-effect/script.js
index b17ecf1..2a7ced9 100644
--- a/button-ripple-effect/script.js
+++ b/button-ripple-effect/script.js
@@ -2,15 +2,25 @@ const buttons = document.querySelectorAll('.ripple')
buttons.forEach(button => {
button.addEventListener('click', function (e) {
+ // e is an event object
+ // clientx provides the horizontal coordinate within the viewport (currently being shown)
+ // at which the event occur( as opposed to the coordinate within the page)
const x = e.clientX
const y = e.clientY
+ // event.target provides the reference to the object onto which the event was dispatched 触发事件
+ // it is different from event.currentTarget when the handler is called during the bubbling or capturing phase of the event
+
+ // five values that position can take : static, absolute, relative, fixed, sticky.
+ // offsetTop is the distance between the current node and the closest offset parent( whose position is non-static )
+ // if there is on offset parent, return body
const buttonTop = e.target.offsetTop
const buttonLeft = e.target.offsetLeft
const xInside = x - buttonLeft
const yInside = y - buttonTop
-
+ console.log(e,x,y,'x,y',buttonLeft,buttonTop,'offsetTop,offsetLeft')
+ console.log(this === e.target,'this')
const circle = document.createElement('span')
circle.classList.add('circle')
circle.style.top = yInside + 'px'
diff --git a/toast-notification/style.css b/toast-notification/style.css
index 9ae67d4..3782f37 100644
--- a/toast-notification/style.css
+++ b/toast-notification/style.css
@@ -49,6 +49,17 @@ body {
border-radius: 5px;
padding: 1rem 2rem;
margin: 0.5rem;
+ animation: toastStart .5s ease-in;
+}
+@keyframes toastStart{
+ from{
+ transform: scale(1,0);
+ opacity: 0.5;
+ }
+ to{
+ transform: scale(1);
+ opacity: 1;
+ }
}
.toast.info {
diff --git a/workout/day1-button-ripple-effect/index.html b/workout/day1-button-ripple-effect/index.html
new file mode 100644
index 0000000..9fb3f9d
--- /dev/null
+++ b/workout/day1-button-ripple-effect/index.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+ Document
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/workout/day1-button-ripple-effect/script.js b/workout/day1-button-ripple-effect/script.js
new file mode 100644
index 0000000..7efab8c
--- /dev/null
+++ b/workout/day1-button-ripple-effect/script.js
@@ -0,0 +1,40 @@
+const rippleButtons = document.querySelectorAll('.ripple');
+
+function rippleClick(e){
+
+ // e is an event object
+ // clientx provides the horizontal coordinate within the viewport (currently being shown)
+ // at which the event occur( as opposed to the coordinate within the page)
+ const clientX = e.clientX
+ const clientY = e.clientY
+
+ // event.target provides the reference to the object onto which the event was dispatched 触发事件
+ // it is different from event.currentTarget when the handler is called during the bubbling or capturing phase of the event
+
+ // five values that position can take : static, absolute, relative, fixed, sticky.
+ // offsetTop is the distance between the current node and the closest offset parent( whose position is non-static )
+ // if there is on offset parent, return body
+ const target = e.target
+ const offsetLeft = target.offsetLeft
+ const offsetTop = target.offsetTop
+
+ const xInside = clientX - offsetLeft;
+ const yInside = clientY - offsetTop;
+
+ const spanNode = document.createElement('span');
+ spanNode.classList.add('rippleCircle');
+ // type of value style.left is a string
+ spanNode.style.left = xInside + 'px'
+ spanNode.style.top = yInside + 'px'
+
+ target.appendChild(spanNode)
+
+ setTimeout(()=>{
+ spanNode.remove()
+ },500)
+}
+
+console.log(rippleButtons,'rippleButtons')
+rippleButtons.forEach((ele) =>{
+ ele.addEventListener('click',rippleClick)
+})
\ No newline at end of file
diff --git a/workout/day1-button-ripple-effect/style.css b/workout/day1-button-ripple-effect/style.css
new file mode 100644
index 0000000..5df3c9d
--- /dev/null
+++ b/workout/day1-button-ripple-effect/style.css
@@ -0,0 +1,51 @@
+@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
+
+* {
+ box-sizing: border-box;
+}
+
+body {
+ background-color: #000;
+ font-family: 'Roboto', sans-serif;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ height: 100vh;
+ overflow: hidden;
+ margin: 0;
+}
+
+button {
+ background-color: purple;
+ color: #fff;
+ border: 1px purple solid;
+ font-size: 14px;
+ text-transform: uppercase;
+ letter-spacing: 2px;
+ padding: 20px 30px;
+ overflow: hidden;
+ margin: 10px 0;
+ position: relative;
+}
+
+button:focus {
+ outline: none;
+}
+/* why set translate(-50%,50%)? */
+/* to set center of the ripple element at the place where the mouse is÷\ */
+.rippleCircle{
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background-color: #fff;
+ border-radius: 50%;
+ transform: translate(-50%, -50%) scale(0);
+ animation: circle .5s ease-out;
+}
+@keyframes circle{
+ to{
+ transform: translate(-50%, -50%) scale(3);
+ opacity: 0;
+ }
+}
\ No newline at end of file
diff --git a/workout/day2-toast-notification/index.html b/workout/day2-toast-notification/index.html
new file mode 100644
index 0000000..e700ba7
--- /dev/null
+++ b/workout/day2-toast-notification/index.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ Document
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/workout/day2-toast-notification/script.js b/workout/day2-toast-notification/script.js
new file mode 100644
index 0000000..a0ef296
--- /dev/null
+++ b/workout/day2-toast-notification/script.js
@@ -0,0 +1,32 @@
+const btn = document.querySelector('.btn');
+const toastContainer = document.querySelector('#finnui-toast');
+
+const randomTextArr = ['message one', 'message two', 'message three', 'message four'];
+const randomTypeArr = ['warning', 'success', 'error'];
+
+function createToast(text,type){
+ const toastDom = document.createElement('div');
+ const toastText = text || randomText()
+ const toastType = type || randomType();
+ toastDom.classList.add('finn-toast')
+ toastDom.classList.add(toastType)
+ toastDom.innerText = toastText
+ return toastDom
+}
+
+function randomText(){
+ return randomTextArr[Math.floor(Math.random()*randomTextArr.length)]
+}
+function randomType(){
+ return randomTypeArr[Math.floor(Math.random()*randomTypeArr.length)]
+}
+
+function showToast(duration = 5){
+ const toastNode = createToast();
+ toastContainer.appendChild(toastNode)
+ setTimeout(()=>{
+ toastNode.remove()
+ },duration*1000)
+}
+
+btn.addEventListener('click',()=>showToast())
\ No newline at end of file
diff --git a/workout/day2-toast-notification/style.css b/workout/day2-toast-notification/style.css
new file mode 100644
index 0000000..d0e08a8
--- /dev/null
+++ b/workout/day2-toast-notification/style.css
@@ -0,0 +1,79 @@
+@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;400&display=swap');
+
+* {
+ box-sizing: border-box;
+}
+
+body {
+ background-color: rebeccapurple;
+ font-family: 'Poppins', sans-serif;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ height: 100vh;
+ overflow: hidden;
+ margin: 0;
+}
+
+#finnui-toast{
+ width: 200px;
+ position: absolute;
+ top: 10px;
+ bottom: 10px;
+ right: 10px;
+ display: flex;
+ flex-direction: column;
+ justify-content: flex-end;
+}
+
+.btn {
+ background-color: #ffffff;
+ color: rebeccapurple;
+ font-family: inherit;
+ font-weight: bold;
+ padding: 1rem;
+ border-radius: 5px;
+ border: none;
+ cursor: pointer;
+}
+
+
+@keyframes toast-show{
+ from{
+ transform: scale(1,0);
+ }
+ to{
+ transform: scale(1);
+ }
+}
+
+@keyframes toast-leave{
+ from{
+ transform: scale(1,0);
+ }
+ to{
+ transform: scale(1);
+ }
+}
+
+.finn-toast{
+ min-width: 200px;
+ margin-bottom: 10px;
+ font-size: 16px;
+ line-height: 20px;
+ background-color: #ffffff;
+ animation: toast-show .5s ease-in;
+ padding: 5px;
+ border-radius: 3px;
+}
+
+.warning{
+ color: #F2C037;
+}
+.success{
+ color: green;
+}
+.error{
+ color: red;
+}
\ No newline at end of file
diff --git a/workout/day3-hidden-search/index.html b/workout/day3-hidden-search/index.html
new file mode 100644
index 0000000..54f45b9
--- /dev/null
+++ b/workout/day3-hidden-search/index.html
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+ Hidden Search
+
+
+