fixes
This commit is contained in:
@@ -4,7 +4,7 @@ const CompanyInfoMockup = ({
|
|||||||
children
|
children
|
||||||
}: PropsWithChildren) => {
|
}: PropsWithChildren) => {
|
||||||
return (
|
return (
|
||||||
<div className='bg-base-300 w-full h-min rounded-2xl sm:border-8 sm:border-black'>
|
<div className='bg-base-300 w-full h-min rounded-4xl sm:border-8 sm:border-black'>
|
||||||
<div className='hidden sm:flex flex-col w-full'>
|
<div className='hidden sm:flex flex-col w-full'>
|
||||||
<div className='w-full grid grid-cols-3 p-2'>
|
<div className='w-full grid grid-cols-3 p-2'>
|
||||||
<div className='flex space-x-2 overflow-hidden'>
|
<div className='flex space-x-2 overflow-hidden'>
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ const DirectorSection = () => {
|
|||||||
Нашей стратегией является превращать сложные задачи сферы ЖКХ <span className='text-blue-500'>в эффективные цифровые решения</span>. Мы разрабатываем автоматизацию для жизненно важной отрасли.
|
Нашей стратегией является превращать сложные задачи сферы ЖКХ <span className='text-blue-500'>в эффективные цифровые решения</span>. Мы разрабатываем автоматизацию для жизненно важной отрасли.
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div className='flex flex-row gap-2 sm:grid sm:grid-cols-2 justify-end mt-auto'>
|
<div className='flex flex-row gap-2 justify-end mt-auto'>
|
||||||
<div className="flex justify-center items-center">
|
<div className="flex justify-center items-center w-full">
|
||||||
<img className="max-w-64 w-full h-auto" src="/assets/sign.png" />
|
<img className="max-w-64 w-full h-auto" src="/assets/sign.png" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,48 +1,47 @@
|
|||||||
import { useInView } from "motion/react";
|
import { useInView } from "motion/react";
|
||||||
import { useRef, useEffect, useState } from "react";
|
import { useRef, useEffect, useState } from "react";
|
||||||
|
|
||||||
export default function TypingEffect({ text = 'Typing Effect', speed = 0.1 }: { text: string, speed?: number }) {
|
export default function TypingEffect({
|
||||||
|
text = "Typing Effect",
|
||||||
|
speed = 0.05,
|
||||||
|
}: {
|
||||||
|
text: string;
|
||||||
|
speed?: number;
|
||||||
|
}) {
|
||||||
const ref = useRef<HTMLHeadingElement>(null);
|
const ref = useRef<HTMLHeadingElement>(null);
|
||||||
const isInView = useInView(ref, { once: true });
|
const isInView = useInView(ref, { once: true });
|
||||||
|
|
||||||
const [visibleChars, setVisibleChars] = useState(0);
|
const [visibleChars, setVisibleChars] = useState(0);
|
||||||
|
|
||||||
// Split text into lines
|
const lines = text.split("\n");
|
||||||
const lines = text.split('\n');
|
const totalChars = text.replace(/\n/g, "").length;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isInView) return;
|
if (!isInView) return;
|
||||||
|
|
||||||
let currentIndex = 0;
|
|
||||||
const totalChars = text.replace(/\n/g, '').length;
|
|
||||||
|
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
if (currentIndex < totalChars) {
|
setVisibleChars((prev) => {
|
||||||
currentIndex++;
|
if (prev >= totalChars) return 0; // loop
|
||||||
setVisibleChars(currentIndex);
|
return prev + 1;
|
||||||
} else {
|
});
|
||||||
clearInterval(interval);
|
|
||||||
}
|
|
||||||
}, speed * 1000);
|
}, speed * 1000);
|
||||||
|
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
}, [isInView, text, speed]);
|
}, [isInView, totalChars, speed]);
|
||||||
|
|
||||||
// Build visible text based on visible characters
|
// Build visible overlay text
|
||||||
let charsProcessed = 0;
|
let charsProcessed = 0;
|
||||||
const visibleLines: string[] = [];
|
const visibleLines: string[] = [];
|
||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
const lineLength = line.length;
|
const lineLength = line.length;
|
||||||
|
|
||||||
if (charsProcessed + lineLength <= visibleChars) {
|
if (charsProcessed + lineLength <= visibleChars) {
|
||||||
// Full line is visible
|
|
||||||
visibleLines.push(line);
|
visibleLines.push(line);
|
||||||
charsProcessed += lineLength;
|
charsProcessed += lineLength;
|
||||||
} else {
|
} else {
|
||||||
// Partial line
|
const remaining = visibleChars - charsProcessed;
|
||||||
const remainingChars = visibleChars - charsProcessed;
|
if (remaining > 0) visibleLines.push(line.slice(0, remaining));
|
||||||
if (remainingChars > 0) {
|
|
||||||
visibleLines.push(line.slice(0, remainingChars));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,11 +52,11 @@ export default function TypingEffect({ text = 'Typing Effect', speed = 0.1 }: {
|
|||||||
ref={ref}
|
ref={ref}
|
||||||
className="text-sm text-left font-mono text-base-content/70 tracking-tighter absolute bottom-0"
|
className="text-sm text-left font-mono text-base-content/70 tracking-tighter absolute bottom-0"
|
||||||
>
|
>
|
||||||
|
{lines.map((line, i) => (
|
||||||
|
<div key={i}>{line}</div>
|
||||||
|
))}
|
||||||
{visibleLines.map((line, index) => (
|
{visibleLines.map((line, index) => (
|
||||||
<div key={index}>
|
<div key={index}>{line}</div>
|
||||||
{line}
|
|
||||||
{index < visibleLines.length - 1 && <br />}
|
|
||||||
</div>
|
|
||||||
))}
|
))}
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user