All Projects → medhatdawoud → react-change-highlight

medhatdawoud / react-change-highlight

Licence: MIT License
✨ a react component to highlight changes constantly ⚡️

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-change-highlight

react-daterange-picker
A react date range picker to using @material-ui. Live Demo: https://flippingbitss.github.io/react-daterange-picker/
Stars: ✭ 85 (+7.59%)
Mutual labels:  npm-package, react-hooks
react-native-value-picker
Cross-Platform iOS(ish) style picker for react native.
Stars: ✭ 18 (-77.22%)
Mutual labels:  npm-package, react-hooks
react-abac
Attribute Based Access Control for React
Stars: ✭ 54 (-31.65%)
Mutual labels:  react-hooks
bulk-mail-cli
Do quick, hassle-free email marketing with this small but very powerful tool! 🔥
Stars: ✭ 88 (+11.39%)
Mutual labels:  npm-package
react-hooks-file-upload
React Hooks File Upload example with Progress Bar using Axios, Bootstrap
Stars: ✭ 30 (-62.03%)
Mutual labels:  react-hooks
react
🎣 React hooks & components on top of ocean.js
Stars: ✭ 27 (-65.82%)
Mutual labels:  react-hooks
react-hooks-example
React Hooks Example
Stars: ✭ 21 (-73.42%)
Mutual labels:  react-hooks
todo
🤖 🚀 I created Todo. Hope you like it and enjoy the open source
Stars: ✭ 16 (-79.75%)
Mutual labels:  react-hooks
window-scroll-position
React hook for Window scroll position
Stars: ✭ 81 (+2.53%)
Mutual labels:  react-hooks
react-sendbird-messenger
ReactJS (React-router-dom v6 + Antdesign + Firebase + Sendbird + Sentry) codebase containing real world examples (CRUD, auth, advanced patterns, etc).
Stars: ✭ 39 (-50.63%)
Mutual labels:  react-hooks
learn-react-typescript
Learning React contents with TypeScript (Hooks, Redux)
Stars: ✭ 15 (-81.01%)
Mutual labels:  react-hooks
fritz-box
📦 Promise-based JavaScript FRITZ!Box API.
Stars: ✭ 14 (-82.28%)
Mutual labels:  npm-package
MERN-BUS-APP
This is a MFRP (My first Real Project) assigned to me during my internship at Cognizant. Made with MERN Stack technology.
Stars: ✭ 92 (+16.46%)
Mutual labels:  react-hooks
radiaSlider
circular/linear knob-style slider
Stars: ✭ 18 (-77.22%)
Mutual labels:  npm-package
Fakeflix
Not the usual clone that you can find on the web.
Stars: ✭ 4,429 (+5506.33%)
Mutual labels:  react-hooks
skygear-SDK-JS
Skygear SDK for JavaScript
Stars: ✭ 25 (-68.35%)
Mutual labels:  npm-package
react-innertext
Returns the innerText of a React JSX object.
Stars: ✭ 37 (-53.16%)
Mutual labels:  npm-package
awesome-starless
A curated list of awesome repositories with few stargazers but has a huge users.
Stars: ✭ 38 (-51.9%)
Mutual labels:  npm-package
add-module-exports-webpack-plugin
Add `module.exports` for Babel and TypeScript compiled code
Stars: ✭ 36 (-54.43%)
Mutual labels:  npm-package
braille
A Node module for converting text to Braille alphabet.
Stars: ✭ 18 (-77.22%)
Mutual labels:  npm-package

React change highlight

React Change Highlight is a react component to highlight changes in the wrapped component to enhance the UX and grab the focus of the user into the changed value of some parts like the cart in an e-commerce application for example.

This is a real use case I'm using in a project UseCase

You can play around with it on this sandbox codesandbox.io/react-change-highlight .. or clone the repo and play around with the all examples in the examples folder

Install

yarn add react-change-highlight

or

npm install react-change-highlight

Usage

Basically you need to wrap the components you want to highlight on change inside ChangeHighlight element (default import) then add ref attribute to each child in this component which you want to highlight when they got their content changed.

In the following example the count variable comes from state, so when ever that function setCount() is called with any different value the background of that wrapped div will be changed as a default action, but actually it can be any kind of animation you make into the class you will pass to highlightStyle attribute.

import ChangeHighlight from "react-change-highlight";

export default () => {
  const [count, setCount] = useState(0);

  return (
    <ChangeHighlight>
      <div ref={React.createRef()}>{count}</div>
    </ChangeHighlight>
  );
};

Default styling for highlighting in case the user didn't use a custom styling using the highlightStyle property is rc-highlight class and it is as follow:

.rc-highlight {
  background-color: #f8ffb4;
  transition: all 0.5s ease-in-out;
}

SSR (server-side rendering)

In case of using this module in a server-side rendering app, you should make sure to create and pass your own className to the highlightStyle attribute, and to make some hint for you, add ssr attribute to the ChangeHighlight element, so it can give you a hint to add a class in your console as a warning like this.

⚠️ "react-change-highlight", As you're using server-side rendering, it's a must to create and pass your css class to the highlightStyle attribute for "ChangeHighlight" component

Props

Property Type Default Descriptio
showAfter number 500 number of milli seconds before start highlighting
hideAfter number 2500 number of milli seconds before ending highlighting
mode change or newOnly change mode of the detection, either change which is the default one to detect the changes in the parsed elements or newOnly which is useful in case of newly added element highlight (check todo example)
disabled boolean false whether you need to disable highlighting
ssr boolean false you need to pass this in case of using it with server-side rendering. (gives a hint for adding style)
highlightClassName string className for highlighing content (a must in case of SSR)
containerClassName string className for component container
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].