├── .babelrc.json
├── .gitignore
├── .storybook
├── main.js
└── preview.js
├── LICENSE
├── README.md
├── dist
├── index.es.js
└── index.js
├── dummyackage.json
├── package.json
├── pnpm-lock.yaml
├── rollup.config.mjs
└── src
├── components
├── CircleCursor
│ ├── index.jsx
│ └── styles.module.css
├── EmojiCursor
│ ├── index.jsx
│ └── styles.module.css
├── ImageCursor
│ ├── index.jsx
│ └── styles.module.css
├── SquareOrRectangleCursors
│ ├── index.jsx
│ └── styles.module.css
└── index.jsx
├── index.js
└── stories
├── Button.jsx
├── Button.stories.jsx
├── Cursors.jsx
├── Cursors.stories.jsx
├── Header.jsx
├── Header.stories.js
├── Introduction.mdx
├── Page.jsx
├── Page.stories.js
├── assets
├── code-brackets.svg
├── colors.svg
├── comments.svg
├── direction.svg
├── flow.svg
├── plugin.svg
├── repo.svg
└── stackalt.svg
├── button.css
├── cursors.css
├── header.css
└── page.css
/.babelrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["@babel/env"]
3 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/.storybook/main.js:
--------------------------------------------------------------------------------
1 | /** @type { import('@storybook/react-vite').StorybookConfig } */
2 | const config = {
3 | stories: ['../src/**/*.stories.@(js|jsx)'],
4 | addons: [
5 | "@storybook/addon-links",
6 | "@storybook/addon-essentials",
7 | "@storybook/addon-interactions",
8 | '@storybook/addon-styling',
9 | '@storybook/addon-interactions',
10 | ],
11 | framework: {
12 | name: "@storybook/react-vite",
13 | options: {},
14 | },
15 | core: {
16 | disableTelemetry: true, // 👈 Disables telemetry
17 | },
18 |
19 | docs: {
20 | autodocs: "tag",
21 | },
22 | };
23 | export default config;
24 |
--------------------------------------------------------------------------------
/.storybook/preview.js:
--------------------------------------------------------------------------------
1 | /** @type { import('@storybook/react').Preview } */
2 | const preview = {
3 | parameters: {
4 | actions: { argTypesRegex: "^on[A-Z].*" },
5 | controls: {
6 | matchers: {
7 | color: /(background|color)$/i,
8 | date: /Date$/,
9 | },
10 | },
11 | },
12 | };
13 |
14 | export default preview;
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Shridhar Kamat
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://www.npmjs.com/package/react-cursors)
2 | [](https://www.npmjs.com/package/react-cursors)
3 | 
4 |
5 |
6 |
React Cursors
7 |
Collection of highly customizable cursors for react!
8 |
9 | > Currently we have a few cursors ready for you to use, you may also customize them to your liking and contribute to this repo ✨
10 |
11 | ## Installation
12 | ```
13 | npm i react-cursors
14 | ```
15 |
16 | ## Usage
17 |
18 | Import the component
19 |
20 | ``` js
21 | import { CircleCursor } from 'react-cursors'
22 | ```
23 |
24 | Use it
25 |
26 | ``` js
27 |
50 |
51 | ```
52 |
53 | Props provided in the initial will be the initial styles of the cursor, and the props provided in the hover will be the styles of cursor when the cursor hovers over an element with class 'hover-detect'.
54 |
55 |
56 |
57 | If you want to use default styling, or no hover elements then you will have to keep the component as :
58 |
59 | ```js
60 |
61 |
62 |
63 | ```
64 |
65 |
66 | Further, it is always recommeded to use lazy loading while importing the component, to avoid any DOM related problems.
67 |
68 | Problems faced without lazy loading can lead to bugs like, hover styles not getting activated when cursors hovers over elements having class 'hover-detect'
69 |
70 | ```
71 |
72 | import React, { Suspense } from "react"; // we also need to import suspense
73 |
74 | const CircleCursor = React.lazy(() => import('react-cursors').then(module => ({ default: module.CircleCursor }))) ;
75 |
76 | ```
77 |
78 | And using it like :
79 |
80 | ```html
81 |
82 |
83 |
84 | Loading ...
}>
85 |
86 |
87 |
88 |
89 | ```
90 |
91 |
92 |
93 |
94 | ## Element attributes
95 | All the attributes are optional, incase values are not provided, the default values will be used
96 |
97 |
98 |
99 | ### Common for all
100 |
101 |
102 | | Attribute | Values | Description |
103 | | ----------------------- | ------------------------ | ---------------------------------------------------------------------------------------- |
104 | | `safeBoundaryX` | `string` | Used to set the boundary of the cursor along the x-axis, helpful inorder to prevent overflow
105 | | `safeBoundaryY` | `string` | Used to set the boundary of the cursor along the y-axis, helpful inorder to prevent overflow
106 |
107 |
108 |
109 | ### Circle Cursor
110 |
111 |
112 | | Attribute | Values | Description |
113 | | ----------------------- | ------------------------ | ---------------------------------------------------------------------------------------- |
114 | | `dotSize` | `string` | Used to set the size of the inner dot |
115 | | `circleSize` | `string` | Used to set the size of the outer circle |
116 | | `borderStyle` | `string` | Used to set the border style of the outer circle |
117 | | `color` | `string` | Used to set the color of the outer circle and inner dot |
118 | | `borderWidth` | `string` | Used to set the border width of the outer circle |
119 | | `circleDelay` | `string` | Used to set the delay of the outer circle |
120 | | `dotDelay` | `string` | Used to set the delay of the inner circle |
121 |
122 |
123 |
124 | ### Emoji Cursor
125 |
126 |
127 | | Attribute | Values | Description |
128 | | ----------------------- | ------------------------ | ---------------------------------------------------------------------------------------- |
129 | | `size` | `string` | Used to set the size of the emoji |
130 | | `delay` | `string` | Used to set the delay of the emoji |
131 | | `emoji` | `string` | Used to set the emoji |
132 |
133 |
134 |
135 | ### Image Cursor
136 |
137 | #### Experimental ⚠
138 |
139 |
140 | | Attribute | Values | Description |
141 | | ----------------------- | ------------------------ | ---------------------------------------------------------------------------------------- |
142 | | `width` | `string` | Used to set the width of the image |
143 | | `height` | `string` | Used to set the height of the image |
144 | | `delay` | `string` | Used to set the delay of the image |
145 | | `url` | `string` | Url of the image |
146 |
147 |
148 |
149 | ### Square Rectangle Cursor
150 |
151 |
152 | | Attribute | Values | Description |
153 | | ----------------------- | ------------------------ | ---------------------------------------------------------------------------------------- |
154 | | `innerShapeSize` | `string` | Used to set the size of the inner shape |
155 | | `shapeSize` | `string` | Used to set the size of the outer shape |
156 | | `borderStyle` | `string` | Used to set the border style of the outer circle |
157 | | `color` | `string` | Used to set the color of the outer shape and inner shape |
158 | | `borderWidth` | `string` | Used to set the border width of the outer circle |
159 | | `shapeDelay` | `string` | Used to set the delay of the outer circle |
160 | | `innerShapeDelay` | `string` | Used to set the delay of the inner circle |
161 |
162 |
163 |
164 |
165 | ---
166 |
167 |
Join our Community and feel free to drop your questions on
21 | We recommend building UIs with a{' '}
22 |
23 | component-driven
24 | {' '}
25 | process starting with atomic components and ending with pages.
26 |
27 |
28 | Render pages with mock data. This makes it easy to build and review page states without
29 | needing to navigate to them in your app. Here are some handy patterns for managing page
30 | data in Storybook:
31 |
32 |
33 |
34 | Use a higher-level connected component. Storybook helps you compose such data from the
35 | "args" of child component stories
36 |
37 |
38 | Assemble data in the page component from your services. You can mock these services out
39 | using Storybook.
40 |