Git Product home page Git Product logo

react-ascii-text's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

fredm00n

react-ascii-text's Issues

Single animation not working

Cool project thanks for this!

Goal: I am wanting to get my ascii text to animate, but only once. So noting shows, then the animation shows, and once the animation finishes (for the first time), it stays on the screen; static.

The fadeIn property doesn't seem to do anything for me. IDK what the originaly intent for fadeIn was; but I noticed that fadeIn wasn't documented in the read me. Maybe this was removed on purpose?

Here's a hacky work around I found: pass an array to text and set isPaused to a boolean state variable that you mutate in a useEffect after the first string in the array has finished animating using setTimeout.

export default function Banner() {
  const [paused, setPaused] = useState(false)

  useEffect(() => {
    setTimeout(() => {
      setPaused(true)
    }, 1000)
  }, [])

  const asciiTextRef = useAsciiText({
    animationCharacters: '▒ ░ █',
    font: ansiShadow,
    text: ['MY STRING', 'MT STRING'],
    fadeIn: true,
    animationDirection: 'down',
    isPaused: paused,
  })


  return (
    <div className='h-48'>
      <h1 className='text-z-red text-2xl'>
        <pre ref={asciiTextRef}></pre>
      </h1>
    </div>
  )
}

Type mismatch: `MutableRefObject` & `LegacyRef`

When I do this, basic example:

export default function Banner() {

  const asciiTextRef = useAsciiText({
    animationCharacters: '▒ ░ █',
    font: ansiShadow,
    text: ['MY STRING', 'MY STRING'],
    fadeIn: true,
    animationDirection: 'down',
  })

  return (
    <div className='h-48'>
      <h1 className='text-z-red text-2xl'>
        <pre ref={asciiTextRef}></pre>
      </h1>
    </div>
  )
}

I get this type error:

Diagnostics:
1. Type 'MutableRefObject<HTMLPreElement | undefined>' is not assignable to type 'LegacyRef<HTMLPreElement> | undefined'.
     Type 'MutableRefObject<HTMLPreElement | undefined>' is not assignable to type 'RefObject<HTMLPreElement>'.
       Types of property 'current' are incompatible.
         Type 'HTMLPreElement | undefined' is not assignable to type 'HTMLPreElement | null'.
           Type 'undefined' is not assignable to type 'HTMLPreElement | null'. [2322]

Work around:

export default function Banner() {
  const asciiTextRef = useAsciiText({
    animationCharacters: '▒ ░ █',
    font: ansiShadow,
    text: ['MY STRING', 'MY STRING'],
    fadeIn: true,
    animationDirection: 'down',
  })

  // Using a ref callback to bridge the type mismatch.
  const refCallback = (element: HTMLPreElement | null) => {
    if (asciiTextRef) {
      // Directly manipulate the `.current` property only if it's not `undefined`.
      asciiTextRef.current = element ?? undefined // Convert `null` to `undefined`.
    }
  }

  return (
    <div className='h-48'>
      <h1 className='text-z-red text-2xl'>
        <pre ref={refCallback}></pre>
      </h1>
    </div>
  )
}

Feature request: useAsciiArt()

This package is really cool! I love it!

Feature request: new hook useAsciiArt()
Instead of rendering text with the font, it will render the actual ASCII art we already have, taking care of the spaces and applying animations.

Cannot import multiple instances with different fonts

Thanks a lot for providing this react package. It works like a charm other than 1 scenario I'm currently facing:

  • I'm including multiple instances of the component on 1 web page
  • I'm setting them up so that they all use a different font

However, the last instance seems to override the font of all the other instances.

I wonder if there's a workaround you could think of?

Many thanks
fred

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.