1.1.13 • Published 3 years ago

react-modal-hover v1.1.13

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

react-modal-hover

How it works 🤔

Hovering over the desired component will open a modal with another component shown as information Take care with the width of the element you want to hover 🤟

There are 3 main elements on this component:

1 - Content: the element to show when user hover the element

2 - Legend: the element to make users know some element is hoverable

3 - Background: a black transparent window when you hover

🚀 Live Demo: https://onlyMastering.com/devmode

Quick Start

Install package from npm 📥

npm i react-modal-hover

Import it on your .js 📥

import { ModalHover } from 'react-modal-hover'

Prepare your "onHover" component or just a simple string

<ModalHover onHover={<h3>Hello World</h3>}>
  <div>Hover Me!</div>
<ModalHover/>

ℹ️ it's recommended to use <div> as first child, then whatever you want 😃

General Props

ℹ️ Main props of the component, legendMsg is ? because is the typical tooltip map legend ℹ️ if option active={false} ModalHover will not be even visible on the html

OptionTypeDefaultDescription
activebooleantrueactivate all the hover option
legendbooleantruelegend on top of your hover component
legendPosstringrightposition of the legend on your hover component
legendMsgstring?message of the legend

Example

<ModalHover onHover={<MySocialMediaComponent/>} legendPos="left" legendMsg="Follow me!">
  <div>Author: Carlos Torres</div>
<ModalHover/>

Styled Props (CSS)

ℹ️ Styling props, you can add it on objects or direct CSS, check examples below

BackgroundStyles

OptionTypeDefaultDescription
backgroundColorstringrgba(0, 0, 0, 0.75)background-color, better with some transparency

ContentStyles

OptionTypeDefaultDescription
backgroundColorstringrgba(0, 0, 0, 1)content css property
maxWidthstring100%content css property
borderRadiusstring8pxcontent css property
boxShadowstring0 0 10px 2px blackcontent css property
colorstringwhitecontent css property
paddingstring10px 20pxcontent css property
borderstring2px solid greycontent css property
marginLeftstring20pxcontent css property
marginRightstring20pxcontent css property

Example with object

const MyContentStyles = {
    backgroundColor: "white",
    color: "black",
    padding: "20px 40px"
}
...
<ModalHover ContentStyles={MyContentStyles} onHover={<MyCompOnHover/>} legendMsg="HOVER ME!">
  <div>Im a div that wants to be hovered</div>
<ModalHover/>

LegendStyles

OptionTypeDefaultDescription
colorstringwhiteLegend css property
backgroundColorstringorangeLegend css property
borderRadiusstring50pxLegend css property
minHeightstring20pxLegend css property
minWidthstring20pxLegend css property
paddingstring2px 2pxLegend css property
displaystringflexLegend css property
justifyContentstringspace-aroundLegend css property
alignItemsstringcenterLegend css property
cursorstringpointerLegend css property
boxShadowstring0 0 5px 0 blackLegend css property
fontSizestring16pxLegend css property
fontWeightstringboldLegend css property
marginTopstring0pxLegend css property
marginLeftstring0pxLegend css property

Example with direct css insert (just like in React)

<ModalHover
    ContentStyles={{color:"red", padding:"20px"}}
    LegendStyles={{backgroundColor:"red"}}
    onHover={<MyCompOnHover/>}
    legendMsg="info"
    >
  <div>Im other div that wants to be hovered</div>
<ModalHover/>

Fades

ℹ️ You can set fade-in/out props to the background and the content, do it carefully ⚠️ :

OptionTypeDefaultDescription
backFadeInstring1s easerecommended fade in for background
backFadeOutstring.3s easerecommended fade out for background
contFadeInstring1s easerecommended fade in for content
contFadeOutstring.3s easerecommended fade out for content

Example with Fades

<ModalHover
    Fades={{backFadeIn:".5s linear", contFadeIn:".5s linear"}}
    legendMsg="info"
    >
  <div>Im other div that wants to be hovered</div>
<ModalHover/>

TypeScript

This package does support TypeScript 🥰

Follow me! ✨

GitHub | @carlostorreswav Twitter | @carlostorreswav Linkedin | Carlos Torres

TypeScript support thanks to @ciensprog 🧡

1.1.13

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

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

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.11

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago