New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-reveal-effect

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-reveal-effect

Reveal Effect of Fluent Design for React

latest
Source
npmnpm
Version
3.2.3
Version published
Maintainers
1
Created
Source

react-reveal-effect

Reveal Effect of Fluent Design for React

 

Features

  • 💪 Excellent performance, use CSS entirely to draw light effects
  • 📦 Lightweight package
  • 👍 React Hooks & React Components are all supported
  • IE 10 is supported

 

Demo & Docs

🔗 https://ythinker.github.io/react-reveal-effect

 

Install

🔗NPM Package https://www.npmjs.com/package/react-reveal-effect

> npm i react-reveal-effect --save

 

Usage

🔨you can choose to use hooks or component
🚩Whether you choose to use hooks or component, you must use the global configuration context on their parent node
🆕Draw directly with RevealEffectConstructor, with no other restrictions
Parent.ts

import { RevealEffectConfig } from 'react-reveal-effect';

const Parent = ({ children }) => {
  return (
    <RevealEffectConfig
      globalRoot={document.querySelector('#root')}
      config={{
        borderColor: "#fff",
        clickEffect: false,
        elementGradientSize: 300
      }}
    >
      {children}
    </RevealEffectConfig>
  )
}

Hooks

Child.ts

import { useRevealEffect } from "react-reveal-effect";

const Child = () => {
  const containerRef = useRef(null);
  const buttonRef = useRef(null);
  const removeEffect = useRevealEffect(
    {
      borderSelector: containerRef,
      elementSelector: buttonRef
    },
    {
      borderGradientSize: 100,
      elementColor: '#f2f2f2'
    }
  );

  return (
    <div ref={containerRef}>
      <button ref={buttonRef}></button>
    </div>
  )
}

Component

import { RevealEffect } from "react-reveal-effect";

const Child = () => {

  return (
    <RevealEffect component="span" config={{
      borderEffect: false
    }}>
      <button>Demo</button>
    </RevealEffect>
  )
}

Class

<div id='container'>
  <span id='children'></span>
</div>

<script type='module'>
  import { RevealEffectConstructor } from 'react-reveal-effect'

  const instance = new RevealEffectConstructor({
    borderSelector: document.getElementById('container'),
    elementSelector: document.getElementById('children')
  }, {
    elementColor: 'rgba(255, 255, 255, 0.6)'
    borderColor: 'rgba(255, 255, 255, 0.4)',
    root: document.body
  })

  // change config
  instance.config = { clickEffect: true, clickColor: 'rgba(200, 200, 200)' }
  // stop draw effect
  instance.stop();
  // restart draw effect
  instance.start();
  // remove event listener
  instance.removeEffect();
</script>

Config

Global Config(Type: EffectConfigType)

Config PropertyDescriptionTypeDefault
borderColorborder effect colorborderColor?: stringrgba(255, 255, 255, 0.25)
elementColorhover effect colorelementColor?: stringrgba(255, 255, 255, 0.25)
clickColorclick effect colorclickColor?: stringrgba(255, 255, 255, 0.25)
clickEffecttake click effectclickEffect?: stringfalse
borderGradientSizeborder effect sizeborderGradientSize?: number150
elementGradientSizehover effect sizeelementGradientSize?: number150
clickGradientSizeclick effect sizeclickGradientSize?: number80
borderEffecttake border effectborderEffect?: booleantrue
elementEffecttake hover effectelementEffect?: booleantrue
stopstop drawer effectstop?: booleanfalse
effectTypeuse which css property to draw the light effectstop?: "border-image"|"background-image""background-image"

Hooks

Parameter

ParamsDescriptionType
selectorsdraw effect on the selector{
  borderSelector?: MutableRefObject<HTMLElement>|HTMLElement|HTMLElement[],
  elementSelector: HTMLElement|HTMLElement[]
}
configeffect configEffectConfigType

Component

Property

PropsDescriptionTypedefault
configeffect configComponentConfig
componentThe component used for the root nodeelementTypediv

Component Config(extend from EffectConfigType)

Config PropertyDescriptionTypeDefault
...global configEffectConfigType
borderWidthborder effect line widthstring | number
borderRadiusborder effect radiusstring | number
stylecontainer stylestring
borderStyleborder element stylestring
classNamecontainer classNamestring
borderClassNameborder element classNamestring
borderRefborder element refMutableRefObject<HTMLElement>
effectBoxSizingeffectBoxSizing type
"content-box": might break layout
"border-box": It works by shrink the child element which may cause the child element to be clipped
"safe":border effect might be obscured by "overflow: hidden" and "RevealEffect" component's position property is "relative"
"content-box"|"border-box"|"safe""content-box"

 

License

MIT

 

This plugin is extend from 🔗fluent-reveal-effect
🙆‍♀️ Thank U

 

Q&A

Define borderStyle|borderClassName|borderRef when RevealEffect's config effectBoxSizing is not "effectBoxSizing"

    If you have defined borderStyle|borderClassName|borderRef When RevealEffect component's config effectBoxSizing is not "border-box", they will take effect on the container element because in this case border effect will be added on the container element.

"border-image" effectType doesn't support CSS property "border-radius"

https://stackoverflow.com/questions/5706963/possible-to-use-border-radius-together-with-a-border-image-which-has-a-gradient     Use clip-path: inset(0 round radius-pixel) or overflow to replace border-radius

 

Changelog

v3.2.3

Fix: remove side effect style

v3.2.0

Break:

  • The underlying implementation was changed from a function named applyEffect to a class named RevealEffectConstructor
  • Remove the RevealEffectConfig properties mountOnBody and component
  • Add the RevealEffectConfig properties globalRoot

It is now easier to customize using the underlying implementation class RevealEffectConstructor

v3.1.0

Optimize: narrow type inference
New: support to use CSS "border-image" property to draw the effect

v3.0.0

Fix: Compatible with React 18
Optimize: Change the attribute name to make it more uniform and semantic.\

old namenew namenew type
lightColorelementColor
clickEffectColorclickColor
lightGradientSizeelementGradientSize
effectBorderborderEffect
effectBackgroundelementEffect
clickEffectGradientSizeclickGradientSize
parceleffectBoxSizing"content-box"|"border-box"|"safe"

New: RevealEffectConfig add a new config property "stop", which has lower priority than useRevealEffect's stop property.
New: RevealEffectConfig add a new property "off", which can stop all effect and remove event listener. This property has higher priority.

v2.0.3

Optimize project structure

v2.0.2

<RevealEffect> component's config borderRadius has been removed, which can be computed automatically. tips: unable to listen for borderRadius style changes, if you has such a need you can use className or style property.

v2.0.1

update RevealEffect component type, support type derivation. fix lightColor state change

v2.0.0

Update:
useRevealEffect accept MutableRefObject<HTMLElement>
Reveal Effect Config support mountOnBody option
Reveal Effect & Reveal Effect Config support component option

v1.2.2

Update Reveal Effect component's options: borderWidth & borderRadius support number type

v1.2.1

Fixed some problem of renderer when options have been changed

v1.2.0

Added some new options for effect options. (clickEffectGradientSize, clickEffectColor)
Added some new property for RevealEffect component. (style, borderStyle, className, borderClassName, ref, borderRef)
Effect options is reactive.
Some types have been changed.

v1.1.0

Added a new option for RevealEffect component(parcel: "shrink").
ClickEffect won't be affected by EffectBackground.

Iteration Planning

  • RevealEffect非入侵模式开发(不污染子元素的background-image,仅支持ie11)
  • useRevealEffect返回信息更加详细
  • 大量dom页面性能测试
  • 单元测试补齐
  • HomePage 完善

Keywords

react

FAQs

Package last updated on 09 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts