Giter Site home page Giter Site logo

knowingharsh / react-coach-mark Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 7.0 6.95 MB

A light weight coach mark library on react for guided UI experience and live tutorials.

License: MIT License

JavaScript 7.35% HTML 8.19% TypeScript 55.50% CSS 11.13% Less 17.83%
coach-marks splash-screen splash-page tutorial tutorials intro react reactjs hooks

react-coach-mark's Introduction

React Coach Mark

A light weight coach mark library on react.

Applications

  • Intro screen
  • Splash screen
  • Live tutorials
  • Guided experience

Demo

Demo

Usage

import { CoachMark, ICoachProps } from "react-coach-mark";

const coach: ICoachProps = {
        activate: true,
        component: <div>Any Component You Want</div>,
        reference: ref,
        tooltip: { position: 'bottom' }
    };
<CoachMark {...coach} />

Project Structure

src folder contains demo as well as library code. Go to the lib folder from here to check the source code.

Installation

To install

npm i react-coach-mark

To contribute or play-around with the project

git clone https://github.com/hashlucifer/react-coach-mark.git 
npm install 
npm start 

Integration code

There are just 4 params you need to feed in as basic props.

  • activate : boolean to enable/disable the black screen
  • component : Element can be any valid React Node.
  • reference : will be react ref
  • tooltip : having position of tooltip w.r.t focused element on screen.

Check out demo file here for integrations steps.

You control the flow and view

Step 1: Create and Assign ref (hooks version), it also works for class version.

const ref1 = useRef(null);
const ref2 = useRef(null);
// assign it to div
<h1 ref={ref1}>Coach Mark</h1>
<p ref={ref2}>Any ref based element</p>

Step 2: Create state and write your next/prev/skip handlers

const [activatedNumber, setActivateNumber] = useState<number>(0);
const NextButton = <button onClick={() => setActivateNumber(activatedNumber + 1)}>Next</button>;

Step 3: You control the flow, you control the components it will render.

 const coachList: Array<ICoachProps> = [
    {
        activate: activatedNumber === 0,
        component: <div>I can do this {NextButton} </div>,
        reference: ref1,
        tooltip: { position: 'bottom' }
    },
    {
        activate: activatedNumber === 1,
        component: <div>I can be long. {NextButton}</div>,
        reference: ref2,
        tooltip: { position: 'top' }
    }
 ]

const coach : ICoachProps = coachList[activatedNumber]

Step 4: Just pass the configuration to the coach mark

<CoachMark {...coach} />

Sample Screenshot

Demo

Please note that : This works individually as well by calling it twice <CoachMark {...coach1} /> and <CoachMark {...coach2} /> but it might not give smooth css transition for one focus to another.

You can override classes for your own css customization

Please feel free to connect and contribute, Happy Coding.

react-coach-mark's People

Contributors

kenichi-morihara avatar rikusen0335 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-coach-mark's Issues

Possible issue on initial rendering of component

Good afternoon. I just wanted to share a potential issue I came across with the Coach component. It seems that on initial rendering the component doesn't render even when using the sample code provided in the README.md. It seems that just adding a timeout through a useEffect is a workaround for now, but wanted to raise the issue. Also I put together a github repo to demonstrate this:

https://github.com/ronbravo/react-coach-mark-bug-demo

Thanks and take care.

Overlay scroll disable

The overlay doesn't disable the scroll on other components of the screen. How should i do that?

After installing the react-coach-marks package, I couldn't find the src and lib folders in the node_modules/react-coach-marks directory.

image

Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'C:\Users\Prasanth.M\Desktop\sample\frontend-react\node_modules\react-coach-mark\src\lib\utilities\coach.tsx' file: Error: ENOENT: no such file or directory, open 'C:\Users\Prasanth.M\Desktop\sample\frontend-react\node_modules\react-coach-mark\src\lib\utilities\coach.tsx'

WARNING in ./node_modules/react-coach-mark/dist/utilities/common.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'C:\Users\Prasanth.M\Desktop\sample\frontend-react\node_modules\react-coach-mark\src\lib\utilities\common.tsx' file: Error: ENOENT: no such file or directory, open 'C:\Users\Prasanth.M\Desktop\ezscm\frontend-react\node_modules\react-coach-mark\src\lib\utilities\common.tsx'

WARNING in ./node_modules/react-coach-mark/dist/utilities/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'C:\Users\Prasanth.M\Desktop\sample\frontend-react\node_modules\react-coach-mark\src\lib\utilities\index.tsx' file: Error: ENOENT: no such file or directory, open 'C:\Users\Prasanth.M\Desktop\ezscm\frontend-react\node_modules\react-coach-mark\src\lib\utilities\index.tsx'

Failed to compile.

Hi Team, @knowingharsh

Now, I can't import react-coach-mark after installing this lib

Module not found: Error: Can't resolve 'react-coach-mark'

Screen Shot 2022-11-09 at 17 41 35

Lib needs to load less

In my project we doesn't use less, but this lib's stylesheet needs loaders to use less.

Error outputs:

ERROR in ./node_modules/react-coach-mark/dist/styles/index.less 1:0
Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> @import "./coach-mark.less";
 @ ./node_modules/react-coach-mark/dist/index.js 2:0-29

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.