项目作者: kerematam

项目描述 :
It's a component to highlight wrapped component(s) by filling background with backdrop layer.
高级语言: JavaScript
项目地址: git://github.com/kerematam/rc-spotlight.git
创建时间: 2019-12-22T16:27:00Z
项目社区:https://github.com/kerematam/rc-spotlight

开源协议:

下载


rc-spotlight

Spotlight component simply highlights the component(s) that it wraps.

NPM
JavaScript Style Guide
Conventional Commits

Install

  1. npm install --save rc-spotlight

Demo

Edit react-counter-input

Image description

Usage

  1. import React, { Component } from "react";
  2. import Spotlight from "rc-spotlight";
  3. class Example extends Component {
  4. render() {
  5. return (
  6. <Spotlight isActive label={<h1>This is backdrop view</h1>}>
  7. <div>Content with Spotlight Effect</div>
  8. </Spotlight>
  9. );
  10. }
  11. }

Usage with LabelWrapper

  1. import React from "react";
  2. import Spotlight, { LabelWrapper } from "rc-spotlight";
  3. const BackdropText = text => (
  4. <LabelWrapper center>
  5. <div>{text}</div>
  6. </LabelWrapper>
  7. );
  8. const App = () => (
  9. <Spotlight isActive label={BackdropText("This is title")}>
  10. <h1>Spotlight</h1>
  11. </Spotlight>
  12. );

Usage with Antd Tooltip

Image description

Create Wrapper for Spotlight with Tooltip :

  1. const SpotlightWithTooltip = ({
  2. isActive,
  3. toolTipPlacement = "top",
  4. toolTipTitle = "Check here!",
  5. children,
  6. ...rest
  7. }) => {
  8. return (
  9. <Tooltip
  10. placement={toolTipPlacement}
  11. visible={isActive}
  12. title={toolTipTitle}
  13. >
  14. <Spotlight isActive={isActive} {...rest}>
  15. {children}
  16. </Spotlight>
  17. </Tooltip>
  18. );
  19. };

And use it :

  1. const App = () => (
  2. <SpotlightWithTooltip
  3. isActive
  4. toolTipPlacement="right"
  5. toolTipTitle={"You can use Antd Tooltip"}
  6. style={{
  7. width: "fit-content",
  8. boxShadow: "0 0 0 5px #ffffff"
  9. }}
  10. >
  11. <Title>Spotlight</Title>
  12. </SpotlightWithTooltip>
  13. );

Spotlight API


































































Property Description Type Default
isActive Whether the component is enabled or disabled. Boolean false
children Component(s) to have spotlight effect. Node(s) null
label Component(s) to be rendered over backdrop. Node(s) null
zIndex Z index of backdrop and wrapped component. Number or String 1000
backdropColor Color of backdrop. String #000000
backdropOpacity Opacity of backdrop. Number 0.8
inheritParentBackgroundColor Recursively search for parent background color in case you don’t want your component to inherit color of
backdrop. This prop prevent transparent component to inherit backdrop color.
Boolean true
enableShadow Gives shadow around wrapped component . Boolean false
style Inline style for wrapped component when spotlight is actived Object null

LabelWrapper API




































Property Description Type Default
children Component(s) to have spotlight effect. Node(s) null
zIndex Z index of backdrop and wrapped component. Number or String 1000
center Centers label Boolean false
style Inline style for label Object null

License

MIT © kerematam