-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make
AnimatedCopyButton
for code blocks
- Loading branch information
Showing
5 changed files
with
60 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const iterableObject = { | ||
data: [1, 2, 3], | ||
[Symbol.iterator]: function () { | ||
let index = 0; | ||
return { | ||
next: () => ({ | ||
value: this.data[index++], | ||
done: index > this.data.length, | ||
}), | ||
}; | ||
}, | ||
}; | ||
|
||
for (const item of iterableObject) { | ||
console.log(item); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,121 +1,23 @@ | ||
'use client'; | ||
import './styles.mod.scss'; | ||
import React from 'react'; | ||
import { useEffect } from 'react'; | ||
const Component: React.FC = () => { | ||
useEffect(() => { | ||
var header = document.getElementById('myHeader'); | ||
var page = document.getElementById('page'); | ||
var openMenuButton = document.getElementById('openmenu'); | ||
|
||
window.addEventListener('scroll', function () { | ||
page && page.classList.remove('menuopen'); | ||
if (window.scrollY >= 100) { | ||
header && header.classList.add('sticky'); | ||
} else { | ||
header && header.classList.remove('sticky'); | ||
} | ||
}); | ||
|
||
// Event listener to remove the sticky class when the button is clicked | ||
openMenuButton && | ||
openMenuButton.addEventListener('click', function () { | ||
header && header.classList.remove('sticky'); | ||
page && page.classList.add('menuopen'); | ||
}); | ||
|
||
var links = document.querySelectorAll('a[href^="#"]'); | ||
|
||
links.forEach(function (link) { | ||
link.addEventListener('click', function (event) { | ||
// Prevent the default action | ||
event.preventDefault(); | ||
|
||
// Get the target element | ||
// @ts-ignore | ||
var targetId = this.getAttribute('href'); | ||
var targetElement = document.querySelector(targetId); | ||
|
||
// Smooth scroll to target | ||
if (targetElement) { | ||
targetElement.scrollIntoView({ | ||
behavior: 'smooth', | ||
}); | ||
} | ||
}); | ||
}); | ||
}, []); | ||
|
||
export default function Com() { | ||
return ( | ||
<div> | ||
<header id="myHeader" className=""> | ||
<svg | ||
id="logo" | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 714.6 401.1" | ||
> | ||
<path | ||
fill="#fff" | ||
fillRule="evenodd" | ||
d="M502.8 0h211.8l-23 39.7-138.5 240L483 401H342.7L413 279.6 251.4 0h140.3L483 158.1 538.6 62 502.8 0Zm-201 279.6L140.1 0H0l231.7 401 70-121.4Z" | ||
/> | ||
</svg> | ||
<nav> | ||
<a href="#vision">Vision</a> | ||
<a href="#knowledge">Knowledge</a> | ||
<a href="#space">Space</a> | ||
<a href="#future">Future</a> | ||
<button id="openmenu"> | ||
<span></span> | ||
<span></span> | ||
</button> | ||
</nav> | ||
</header> | ||
<div id="page" className=""> | ||
<section | ||
id="vision" | ||
style={{ | ||
backgroundImage: 'url(https://assets.codepen.io/214624/vision.jpg)', | ||
}} | ||
> | ||
<h1>Vision.</h1> | ||
</section> | ||
<section | ||
id="knowledge" | ||
style={{ | ||
backgroundImage: | ||
'url(https://assets.codepen.io/214624/knowledge.jpg)', | ||
}} | ||
> | ||
<h1>Knowledge.</h1> | ||
</section> | ||
<section | ||
id="space" | ||
style={{ | ||
backgroundImage: 'url(https://assets.codepen.io/214624/space.jpg)', | ||
}} | ||
> | ||
<h1>Space.</h1> | ||
</section> | ||
<section | ||
id="future" | ||
style={{ | ||
backgroundImage: 'url(https://assets.codepen.io/214624/future.jpg)', | ||
}} | ||
> | ||
<h1>Future.</h1> | ||
</section> | ||
<> | ||
{' '} | ||
<div className=" flex justify-center items-center "> | ||
<div className="relative average-transition hover:scale-80"> | ||
<div className="grid grid-cols-12 gap-2"> | ||
{Array.from({ length: 144 }, (_, index) => ( | ||
<div | ||
key={index} | ||
className=" bg-pink-500 flex items-center justify-center rounded-full" | ||
> | ||
<span className="h-1 w-1 bg-red-200 rounded-full animate-ping "></span> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
<a | ||
id="fixedlink" | ||
target="_blank" | ||
rel="nofollow noopener" | ||
href="https://wyld.studio/" | ||
> | ||
» See this solution in real usage | ||
</a> | ||
</div> | ||
<div className="h-24 w-full"></div> | ||
</> | ||
); | ||
}; | ||
|
||
export default Component; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.