'use client'; import { useReducer } from 'react'; import GraphemeSplitter from 'grapheme-splitter'; import { Pause, Play } from 'lucide-react'; import Typist from 'react-typist-component'; import Balancer from 'react-wrap-balancer'; import { blogConfig } from '@/config'; import { cn } from '@/lib/utils'; type TypingState = { titleDone: boolean; subtitleDone: boolean; isPaused: boolean; }; type TypingAction = | { type: 'togglePause' } | { type: 'setDone'; payload: 'title' | 'subtitle' }; const reducer = (state: TypingState, action: TypingAction) => { switch (action.type) { case 'togglePause': return { ...state, isPaused: !state.isPaused, }; case 'setDone': return { ...state, [`${action.payload}Done`]: true, }; } }; const splitter = (str: string) => new GraphemeSplitter().splitGraphemes(str); export function HeroSection() { const [{ titleDone, subtitleDone, isPaused }, dispatch] = useReducer( reducer, { titleDone: false, subtitleDone: false, isPaused: false, }, ); return (
dispatch({ type: 'setDone', payload: 'title' })} >

Добро пожаловать в мой блог 👋

{titleDone && ( { dispatch({ type: 'setDone', payload: 'subtitle' }); }} > Я пишу про {' '} )} {subtitleDone && ( {blogConfig.topics.map((topic) => ( {topic} ))} )}

); }