Skip to content

Commit

Permalink
Use typewriter react component
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanalemunioz committed Oct 28, 2024
1 parent 3c07d1a commit 667c82e
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 42 deletions.
42 changes: 42 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"tailwind-merge": "^2.2.1",
"tailwindcss": "^3.4.1",
"tailwindcss-animate": "^1.0.7",
"typewriter-effect": "^2.21.0",
"zod": "^3.22.4"
},
"devDependencies": {
Expand Down
38 changes: 38 additions & 0 deletions src/components/home-hero.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.Typewriter {
background: inherit;
display: inline-block;
}

.Typewriter__cursor {
-webkit-animation: Typewriter-cursor 1s infinite;
animation: Typewriter-cursor 1s infinite;
margin-left: 1px
}

@-webkit-keyframes Typewriter-cursor {
0% {
opacity: 0
}

50% {
opacity: 1
}

100% {
opacity: 0
}
}

@keyframes Typewriter-cursor {
0% {
opacity: 0
}

50% {
opacity: 1
}

100% {
opacity: 0
}
}
70 changes: 29 additions & 41 deletions src/components/home-hero.tsx
Original file line number Diff line number Diff line change
@@ -1,54 +1,42 @@
import { buttonVariants } from "@/components/ui/button";
import { siteConfig } from "@/config/site";
import { cn } from "@/lib/utils";
import { useEffect } from "react";
import Typewriter from 'typewriter-effect';

export default function HomeHero() {

useEffect(() => {(async () => {
await import('./typewriter')

var app = document.getElementById('typewriter');

var typewriter: any = new (window as any).Typewriter(app, {
loop: true,
delay: 50,
deleteSpeed: 50,
skipAddStyles: true
});

typewriter.typeString('sin vueltas')
.pauseFor(2500)
.deleteAll()
.typeString('fácilmente')
.pauseFor(2500)
.deleteAll()
.typeString('hoy mismo')
.pauseFor(2500)
.deleteAll()
.typeString('via API')
.pauseFor(2500)
.deleteAll()
.typeString('con PHP')
.pauseFor(2500)
.deleteAll()
.typeString('con Python')
.pauseFor(2500)
.deleteAll()
.typeString('con Node')
.pauseFor(2500)
.deleteAll()
.typeString('con Ruby')
.pauseFor(2500)
.start();
})().catch(() => {})}, []);
import './home-hero.scss'

export default function HomeHero() {
return (
<>
<h1
className="font-heading text-4xl font-bold sm:text-5xl md:text-6xl lg:text-6xl !leading-[1.1] text-balance"
>
Conectate a <br />AFIP&nbsp;<span id="typewriter" className="text-gradient_indigo-purple">sin vueltas</span>
Conectate a <br />AFIP&nbsp;<span className="text-gradient_indigo-purple">
<span id="Typewriter-default" ref={ref => {
ref?.remove();
}}>sin vueltas</span>
<Typewriter
options={{
strings: ['sin vueltas',
'fácilmente',
'hoy mismo',
'via API',
'con PHP',
'con Python',
'con Node',
'con Ruby'
],
autoStart: true,
delay: 50,
deleteSpeed: 50,
skipAddStyles: true,
loop: true,
}}
onInit={() => {
document.getElementById('Typewriter-default')?.remove();
}}
/>
</span>
</h1>

<p
Expand Down
1 change: 0 additions & 1 deletion src/components/typewriter.js

This file was deleted.

0 comments on commit 667c82e

Please sign in to comment.