1.0.9 • Published 3 years ago

tulitip v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

tulitip

This is a simple Tooltip created for studies purpose.

It has some repositioning logic based on the target's specified parent, if none is passed, it assumes the body as it's parent.

The usage is basically:

import { useRef, useState } from 'react';

import Tooltip from '../../Tooltip';

export function Sample01 () {
    const [isOpen, setIsOpen] = useState(false);

    const targetRef = useRef({});
    const parentTargetRef = useRef({});

    return (
        <div ref={parentTargetRef} className='container'>
            <div
                ref={targetRef}
                className='target'
                onClick={
                    () => setIsOpen(!isOpen)
                }
            ></div>

            <Tooltip
                targetElement={targetRef.current}
                isOpen={isOpen}
                preferredPositions={['bottom', 'top', 'left', 'right']}
                targetParentElement={parentTargetRef.current}
                paddingAroundTarget={10}
                containerStyle={
                    { "z-index": "-1" }
                }
            >
                <div className='tooltipContainer'>
                    <span>My Tooltip!</span>
                </div>
            </Tooltip>
        </div>
    );
}

Only depends on React for usage.

Improvements

  • Add some events for the Tooltip component
  • Create more options to give more control for the user
1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago