├── .circleci
└── config.yml
├── .editorconfig
├── .env.example
├── .eslintignore
├── .eslintrc
├── .gitattributes
├── .gitignore
├── .husky
├── .npmignore
├── commit-msg
└── pre-commit
├── .prettierignore
├── .prettierrc
├── .yarnrc
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── babel.config.js
├── example
├── app.json
├── babel.config.js
├── index.js
├── metro.config.js
├── package.json
├── src
│ ├── App.tsx
│ ├── components
│ │ ├── FavoriteList
│ │ │ ├── FavoriteItem.tsx
│ │ │ ├── FavoriteList.tsx
│ │ │ └── index.ts
│ │ ├── Header.tsx
│ │ ├── ListHeader.tsx
│ │ └── SimilarList
│ │ │ ├── SimilarItem.tsx
│ │ │ ├── SimilarList.tsx
│ │ │ └── index.ts
│ ├── styled.tsx
│ └── util.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── package.json
├── scripts
└── bootstrap.js
├── src
├── FadeDuringHighlight.tsx
├── HighlightOverlay.tsx
├── HighlightableElement.tsx
├── constructClipPath.ts
├── context
│ ├── HighlightableElementProvider.tsx
│ ├── context.ts
│ ├── index.ts
│ └── useHighlightableElements.ts
└── index.ts
├── tsconfig.build.json
├── tsconfig.json
└── yarn.lock
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2.1
2 |
3 | executors:
4 | default:
5 | docker:
6 | - image: circleci/node:10
7 | working_directory: ~/project
8 |
9 | commands:
10 | attach_project:
11 | steps:
12 | - attach_workspace:
13 | at: ~/project
14 |
15 | jobs:
16 | install-dependencies:
17 | executor: default
18 | steps:
19 | - checkout
20 | - attach_project
21 | - restore_cache:
22 | keys:
23 | - dependencies-{{ checksum "package.json" }}
24 | - dependencies-
25 | - restore_cache:
26 | keys:
27 | - dependencies-example-{{ checksum "example/package.json" }}
28 | - dependencies-example-
29 | - run:
30 | name: Install dependencies
31 | command: |
32 | yarn install --cwd example --frozen-lockfile
33 | yarn install --frozen-lockfile
34 | - save_cache:
35 | key: dependencies-{{ checksum "package.json" }}
36 | paths: node_modules
37 | - save_cache:
38 | key: dependencies-example-{{ checksum "example/package.json" }}
39 | paths: example/node_modules
40 | - persist_to_workspace:
41 | root: .
42 | paths: .
43 |
44 | lint:
45 | executor: default
46 | steps:
47 | - attach_project
48 | - run:
49 | name: Lint files
50 | command: |
51 | yarn lint
52 |
53 | typescript:
54 | executor: default
55 | steps:
56 | - attach_project
57 | - run:
58 | name: Typecheck files
59 | command: |
60 | yarn typescript
61 |
62 | unit-tests:
63 | executor: default
64 | steps:
65 | - attach_project
66 | - run:
67 | name: Run unit tests
68 | command: |
69 | yarn test --coverage
70 | - store_artifacts:
71 | path: coverage
72 | destination: coverage
73 |
74 | build-package:
75 | executor: default
76 | steps:
77 | - attach_project
78 | - run:
79 | name: Build package
80 | command: |
81 | yarn prepare
82 |
83 | workflows:
84 | build-and-test:
85 | jobs:
86 | - install-dependencies
87 | - lint:
88 | requires:
89 | - install-dependencies
90 | - typescript:
91 | requires:
92 | - install-dependencies
93 | - unit-tests:
94 | requires:
95 | - install-dependencies
96 | - build-package:
97 | requires:
98 | - install-dependencies
99 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 | [*]
8 |
9 | indent_style = space
10 | indent_size = 2
11 |
12 | end_of_line = lf
13 | charset = utf-8
14 | trim_trailing_whitespace = true
15 | insert_final_newline = true
16 |
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | GITHUB_TOKEN="the token generated from the Github repo"
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | lib
4 | coverage
5 | scripts
6 | example
7 | *.config.js
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": [
4 | "@react-native-community",
5 | "plugin:react/recommended",
6 | "plugin:@typescript-eslint/recommended",
7 | "react-native-wcandillon",
8 | "prettier"
9 | ],
10 | "rules": {
11 | "no-plusplus": "off",
12 | "yoda": ["error", "never", { "exceptRange": true }],
13 | "no-undef": "off",
14 | "no-unused-vars": "off",
15 | "no-empty-pattern": "error",
16 | "eqeqeq": ["error", "always", { "null": "never" }],
17 | "no-shadow": "off",
18 | "react/jsx-indent": ["error", "tab"],
19 | "react/jsx-indent-props": ["error", "tab"],
20 | "react/no-unstable-nested-components": ["error", { "allowAsProps": true }],
21 | "react-hooks/exhaustive-deps": "error",
22 | "react-native/no-inline-styles": "error",
23 | "react-native/no-unused-styles": "error",
24 | "import/no-default-export": "off",
25 | "no-unsafe-optional-chaining": ["error", { "disallowArithmeticOperators": true }],
26 | "@typescript-eslint/explicit-module-boundary-types": "error",
27 | "@typescript-eslint/no-use-before-define": "off",
28 | "@typescript-eslint/no-unused-vars": [
29 | "error",
30 | {
31 | "argsIgnorePattern": "^_",
32 | "varsIgnorePattern": "^_",
33 | "ignoreRestSiblings": true
34 | }
35 | ],
36 | "@typescript-eslint/no-shadow": "error",
37 | "@typescript-eslint/strict-boolean-expressions": [
38 | "error",
39 | {
40 | "allowString": false,
41 | "allowNumber": false,
42 | "allowNullableObject": false
43 | }
44 | ],
45 | "@typescript-eslint/no-inferrable-types": "error",
46 | "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
47 | "@typescript-eslint/ban-ts-comment": "error"
48 | },
49 | "parserOptions": {
50 | "project": ["tsconfig.json"]
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj -text
2 | # specific for windows script files
3 | *.bat text eol=crlf
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # XDE
6 | .expo/
7 |
8 | # VSCode
9 | .vscode/
10 | jsconfig.json
11 |
12 | # Xcode
13 | #
14 | build/
15 | *.pbxuser
16 | !default.pbxuser
17 | *.mode1v3
18 | !default.mode1v3
19 | *.mode2v3
20 | !default.mode2v3
21 | *.perspectivev3
22 | !default.perspectivev3
23 | xcuserdata
24 | *.xccheckout
25 | *.moved-aside
26 | DerivedData
27 | *.hmap
28 | *.ipa
29 | *.xcuserstate
30 | project.xcworkspace
31 |
32 | # Android/IJ
33 | #
34 | .classpath
35 | .cxx
36 | .gradle
37 | .idea
38 | .project
39 | .settings
40 | local.properties
41 | android.iml
42 |
43 | # Cocoapods
44 | #
45 | example/ios/Pods
46 |
47 | # node.js
48 | #
49 | node_modules/
50 | npm-debug.log
51 | yarn-debug.log
52 | yarn-error.log
53 |
54 | # BUCK
55 | buck-out/
56 | \.buckd/
57 | android/app/libs
58 | android/keystores/debug.keystore
59 |
60 | # Expo
61 | .expo/*
62 |
63 | # generated by bob
64 | lib/
65 | .env
66 |
--------------------------------------------------------------------------------
/.husky/.npmignore:
--------------------------------------------------------------------------------
1 | _
2 |
--------------------------------------------------------------------------------
/.husky/commit-msg:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | yarn commitlint -E HUSKY_GIT_PARAMS
5 |
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | yarn lint && yarn typescript
5 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | package.json
3 | package_lock.json
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "tabWidth": 4,
3 | "useTabs": true,
4 | "printWidth": 100
5 | }
6 |
--------------------------------------------------------------------------------
/.yarnrc:
--------------------------------------------------------------------------------
1 | # Override Yarn command so we can automatically setup the repo on running `yarn`
2 |
3 | yarn-path "scripts/bootstrap.js"
4 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project.
4 |
5 | ## Development workflow
6 |
7 | To get started with the project, run `yarn` in the root directory to install the required dependencies for each package:
8 |
9 | ```sh
10 | yarn
11 | ```
12 |
13 | > While it's possible to use [`npm`](https://github.com/npm/cli), the tooling is built around [`yarn`](https://classic.yarnpkg.com/), so you'll have an easier time if you use `yarn` for development.
14 |
15 | While developing, you can run the [example app](/example/) to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app.
16 |
17 | To start the packager:
18 |
19 | ```sh
20 | yarn example start
21 | ```
22 |
23 | To run the example app on Android:
24 |
25 | ```sh
26 | yarn example android
27 | ```
28 |
29 | To run the example app on iOS:
30 |
31 | ```sh
32 | yarn example ios
33 | ```
34 |
35 | To run the example app on Web:
36 |
37 | ```sh
38 | yarn example web
39 | ```
40 |
41 | Make sure your code passes TypeScript and ESLint. Run the following to verify:
42 |
43 | ```sh
44 | yarn typescript
45 | yarn lint
46 | ```
47 |
48 | To fix formatting errors, run the following:
49 |
50 | ```sh
51 | yarn lint --fix
52 | ```
53 |
54 | Remember to add tests for your change if possible. Run the unit tests by:
55 |
56 | ```sh
57 | yarn test
58 | ```
59 |
60 | ### Commit message convention
61 |
62 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:
63 |
64 | - `fix`: bug fixes, e.g. fix crash due to deprecated method.
65 | - `feat`: new features, e.g. add new method to the module.
66 | - `refactor`: code refactor, e.g. migrate from class components to hooks.
67 | - `docs`: changes into documentation, e.g. add usage example for the module..
68 | - `test`: adding or updating tests, e.g. add integration tests using detox.
69 | - `chore`: tooling changes, e.g. change CI config.
70 |
71 | Our pre-commit hooks verify that your commit message matches this format when committing.
72 |
73 | ### Linting and tests
74 |
75 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/)
76 |
77 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.
78 |
79 | Our pre-commit hooks verify that the linter and tests pass when committing.
80 |
81 | ### Publishing to npm
82 |
83 | We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc.
84 |
85 | To publish new versions, run the following:
86 |
87 | ```sh
88 | yarn release
89 | ```
90 |
91 | ### Scripts
92 |
93 | The `package.json` file contains various scripts for common tasks:
94 |
95 | - `yarn bootstrap`: setup project by installing all dependencies and pods.
96 | - `yarn typescript`: type-check files with TypeScript.
97 | - `yarn lint`: lint files with ESLint.
98 | - `yarn test`: run unit tests with Jest.
99 | - `yarn example start`: start the Metro server for the example app.
100 | - `yarn example android`: run the example app on Android.
101 | - `yarn example ios`: run the example app on iOS.
102 |
103 | ### Sending a pull request
104 |
105 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).
106 |
107 | When you're sending a pull request:
108 |
109 | - Prefer small pull requests focused on one change.
110 | - Verify that linters and tests are passing.
111 | - Review the documentation to make sure it looks good.
112 | - Follow the pull request template when opening a pull request.
113 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue.
114 |
115 | ## Code of Conduct
116 |
117 | ### Our Pledge
118 |
119 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
120 |
121 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
122 |
123 | ### Our Standards
124 |
125 | Examples of behavior that contributes to a positive environment for our community include:
126 |
127 | - Demonstrating empathy and kindness toward other people
128 | - Being respectful of differing opinions, viewpoints, and experiences
129 | - Giving and gracefully accepting constructive feedback
130 | - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
131 | - Focusing on what is best not just for us as individuals, but for the overall community
132 |
133 | Examples of unacceptable behavior include:
134 |
135 | - The use of sexualized language or imagery, and sexual attention or
136 | advances of any kind
137 | - Trolling, insulting or derogatory comments, and personal or political attacks
138 | - Public or private harassment
139 | - Publishing others' private information, such as a physical or email
140 | address, without their explicit permission
141 | - Other conduct which could reasonably be considered inappropriate in a
142 | professional setting
143 |
144 | ### Enforcement Responsibilities
145 |
146 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
147 |
148 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
149 |
150 | ### Scope
151 |
152 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
153 |
154 | ### Enforcement
155 |
156 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement. All complaints will be reviewed and investigated promptly and fairly.
157 |
158 | All community leaders are obligated to respect the privacy and security of the reporter of any incident.
159 |
160 | ### Enforcement Guidelines
161 |
162 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
163 |
164 | #### 1. Correction
165 |
166 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
167 |
168 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
169 |
170 | #### 2. Warning
171 |
172 | **Community Impact**: A violation through a single incident or series of actions.
173 |
174 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
175 |
176 | #### 3. Temporary Ban
177 |
178 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
179 |
180 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
181 |
182 | #### 4. Permanent Ban
183 |
184 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
185 |
186 | **Consequence**: A permanent ban from any sort of public interaction within the community.
187 |
188 | ### Attribution
189 |
190 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
191 | available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
192 |
193 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
194 |
195 | [homepage]: https://www.contributor-covenant.org
196 |
197 | For answers to common questions about this code of conduct, see the FAQ at
198 | https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
199 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Jesper Sporron
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 | # Highlight overlay
2 |
3 | A tinted overlay that allows one or more elements to be highlighted (non-tinted).
4 | Works with all types of components; native, function, class, etc.
5 |
6 | Supports switching between highlights, useful for a "tutorial" / "walkththrough" flow
7 | where you step the user through different parts of a screen. Also very useful for
8 | highlighting an element when the user enters the app from a deep link.
9 |
10 |
11 |
12 |
13 |
14 | ### ⚠️ Caveats ⚠️
15 | - If the `highlightedElementId` given to the `HighlightOverlay` does not
16 | correspond to an existing `HighlightableElement`, the overlay will be shown
17 | without any highlight. Might change this in the future. For now make sure
18 | the id always exists.
19 | - In certain setups, the position of the highlighted element might be off by a
20 | fraction. If this happens to you, set the `rootRef` of
21 | `HighlightableElementProvider` manually to the root element of your app.
22 | However in most circumstances this is not necessary.
23 | - If your `HighlightedElement` is inside a scroll view (like in the demo video above)
24 | the `HighlightOverlay` must also be inside the scroll view, otherwise the highlighted
25 | element will not properly overlay the "root" element. This is because of how React Native handles
26 | measuring positions & sizes. I'm working on possible fixes to make this more
27 | user-friendly.
28 | - If you want to conditionally render a `HighligtableElement`, you must instead conditionally render the contents of the element:
29 | ```
30 | // From:
31 | {showElement && (
32 |
33 |
34 |
35 | )}
36 |
37 | // To
38 |
39 | {showElement && (
40 |
41 | )}
42 |
43 | ```
44 | `HighligtableElement` is an unstyled `View`, but it is non-collapsible so it won't get optimized away. This shouldn't change how your app is displayed, except in rare circumstanses.
45 |
46 | ## Installation
47 |
48 | This package is available in the npm registry as [react-native-highlight-overlay](https://www.npmjs.com/package/react-native-highlight-overlay).
49 |
50 | ```sh
51 | # npm
52 | npm install react-native-highlight-overlay
53 |
54 | # yarn
55 | yarn add react-native-highlight-overlay
56 | ```
57 |
58 | ## Usage
59 |
60 | ```js
61 | import {
62 | HighlightableElement,
63 | HighlightableElementProvider,
64 | HighlightOverlay,
65 | } from "react-native-highlight-overlay";
66 |
67 | // Remember to wrap the ROOT of your app in HighlightableElementProvider!
68 | return (
69 |
70 |
79 |
80 |
81 |
88 |
89 |
90 |
91 | {/*
92 | * The HighlightOverlay should be next to the ROOT of the app,
93 | * since it is NOT a modal, it's just an absolutely positioned view.
94 | * If you want it to be a modal, wrap it in yourself first,
95 | * but I recommend not using modals since they can be buggy.
96 | */}
97 | {
101 | // Called when the user clicks outside of the highlighted element.
102 | // Set "highlightedElementId" to nullish to hide the overlay.
103 | }}
104 | />
105 |
106 | );
107 | ```
108 |
109 | ## Contributing
110 |
111 | See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
112 |
113 | ## License
114 |
115 | MIT
116 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ["module:metro-react-native-babel-preset"],
3 | plugins: ["react-native-reanimated/plugin"],
4 | };
5 |
--------------------------------------------------------------------------------
/example/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-highlight-overlay-example",
3 | "displayName": "HighlightOverlay Example",
4 | "expo": {
5 | "name": "react-native-highlight-overlay-example",
6 | "slug": "react-native-highlight-overlay-example",
7 | "description": "Example app for react-native-highlight-overlay",
8 | "privacy": "public",
9 | "version": "1.0.0",
10 | "platforms": ["ios", "android", "web"],
11 | "ios": {
12 | "supportsTablet": true
13 | },
14 | "assetBundlePatterns": ["**/*"],
15 | "androidNavigationBar": {
16 | "visible": "sticky-immersive"
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/example/babel.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 |
3 | const pak = require("../package.json");
4 |
5 | module.exports = function (api) {
6 | api.cache(true);
7 |
8 | return {
9 | presets: ["babel-preset-expo"],
10 | plugins: [
11 | [
12 | "module-resolver",
13 | {
14 | extensions: [".tsx", ".ts", ".js", ".json"],
15 | alias: {
16 | // For development, we want to alias the library to the source
17 | [pak.name]: path.join(__dirname, "..", pak.source),
18 | },
19 | },
20 | ],
21 | "react-native-reanimated/plugin",
22 | ],
23 | };
24 | };
25 |
--------------------------------------------------------------------------------
/example/index.js:
--------------------------------------------------------------------------------
1 | import { registerRootComponent } from "expo";
2 |
3 | import App from "./src/App";
4 |
5 | // registerRootComponent calls AppRegistry.registerComponent('main', () => App);
6 | // It also ensures that whether you load the app in the Expo client or in a native build,
7 | // the environment is set up appropriately
8 | registerRootComponent(App);
9 |
--------------------------------------------------------------------------------
/example/metro.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 |
3 | const blacklist = require("metro-config/src/defaults/exclusionList");
4 | const escape = require("escape-string-regexp");
5 |
6 | const pak = require("../package.json");
7 |
8 | const root = path.resolve(__dirname, "..");
9 |
10 | const modules = Object.keys({
11 | ...pak.peerDependencies,
12 | });
13 |
14 | module.exports = {
15 | projectRoot: __dirname,
16 | watchFolders: [root],
17 |
18 | // We need to make sure that only one version is loaded for peerDependencies
19 | // So we blacklist them at the root, and alias them to the versions in example's node_modules
20 | resolver: {
21 | blacklistRE: blacklist(
22 | modules.map((m) => new RegExp(`^${escape(path.join(root, "node_modules", m))}\\/.*$`))
23 | ),
24 |
25 | extraNodeModules: modules.reduce((acc, name) => {
26 | acc[name] = path.join(__dirname, "node_modules", name);
27 | return acc;
28 | }, {}),
29 | },
30 |
31 | transformer: {
32 | getTransformOptions: async () => ({
33 | transform: {
34 | experimentalImportSupport: false,
35 | inlineRequires: true,
36 | },
37 | }),
38 | },
39 | };
40 |
--------------------------------------------------------------------------------
/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-highlight-overlay-example",
3 | "description": "Example app for react-native-highlight-overlay",
4 | "version": "0.0.1",
5 | "private": true,
6 | "main": "index",
7 | "scripts": {
8 | "android": "expo start --android",
9 | "ios": "expo start --ios",
10 | "web": "expo start --web",
11 | "start": "expo start",
12 | "test": "jest"
13 | },
14 | "dependencies": {
15 | "@types/react-native-highlight-overlay": "file:../lib/typescript",
16 | "expo": "44.0.0",
17 | "expo-splash-screen": "~0.14.1",
18 | "react": "17.0.1",
19 | "react-dom": "17.0.1",
20 | "react-native": "0.64.3",
21 | "react-native-highlight-overlay": "file:..",
22 | "react-native-reanimated": "~2.3.1",
23 | "react-native-svg": "^12.3.0",
24 | "react-native-unimodules": "~0.15.0",
25 | "react-native-web": "0.17.1"
26 | },
27 | "devDependencies": {
28 | "@babel/core": "7.12.9",
29 | "@babel/runtime": "^7.9.6",
30 | "babel-loader": "^8.2.2",
31 | "babel-plugin-module-resolver": "^4.0.0",
32 | "babel-preset-expo": "9.0.2",
33 | "expo-cli": "^4.0.13"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/example/src/App.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import { ScrollView, StyleSheet, View } from "react-native";
3 | import { HighlightableElementProvider, HighlightOverlay } from "react-native-highlight-overlay";
4 |
5 | import FavoriteList from "./components/FavoriteList";
6 | import Header from "./components/Header";
7 | import SimilarList from "./components/SimilarList";
8 | import { styled } from "./styled";
9 |
10 | export const HIGHLIGHTED_ID_1 = "one";
11 | export const HIGHLIGHTED_ID_2 = "two";
12 |
13 | function App() {
14 | const [rootRef, setRootRef] = useState | null>(null);
15 | const [highlightedId, setHighlightId] = useState(null);
16 |
17 | return (
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | setHighlightId(null)}
28 | />
29 |
30 |
31 | );
32 | }
33 |
34 | const Container = styled(View, {
35 | backgroundColor: "#F0F0F0",
36 | padding: 25,
37 | });
38 |
39 | export default App;
40 |
--------------------------------------------------------------------------------
/example/src/components/FavoriteList/FavoriteItem.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import {
3 | Alert,
4 | Image as RNImage,
5 | ImageSourcePropType,
6 | Pressable,
7 | StyleProp,
8 | StyleSheet,
9 | Text,
10 | View,
11 | ViewStyle,
12 | } from "react-native";
13 | import { styled } from "../../styled";
14 |
15 | export const ITEM_HEIGHT = 60;
16 | const BORDER_RADIUS = 10;
17 |
18 | export type FavoriteItemProps = {
19 | title: string;
20 | artist: string;
21 | duration: string;
22 | imageSource: ImageSourcePropType;
23 | style?: StyleProp;
24 | };
25 |
26 | function FavoriteItem({ title, artist, duration, imageSource, style }: FavoriteItemProps) {
27 | return (
28 | Alert.alert("You pressed", title)}>
29 |
30 |
31 | {title}
32 |
33 | {artist}
34 | {duration}
35 |
36 |
37 |
38 | );
39 | }
40 |
41 | const Container = styled(Pressable, {
42 | height: ITEM_HEIGHT,
43 | flexDirection: "row",
44 | backgroundColor: "#F0F0F0",
45 | borderRadius: BORDER_RADIUS,
46 | });
47 |
48 | const Image = styled(RNImage, {
49 | borderRadius: BORDER_RADIUS,
50 | width: ITEM_HEIGHT,
51 | height: ITEM_HEIGHT,
52 | });
53 |
54 | const TextSection = styled(View, {
55 | flex: 1,
56 | flexDirection: "column",
57 | paddingVertical: 5,
58 | paddingHorizontal: 10,
59 | justifyContent: "space-evenly",
60 | });
61 |
62 | const Title = styled(Text, {
63 | fontWeight: "bold",
64 | fontSize: 22,
65 | });
66 |
67 | const BottomTextSection = styled(View, {
68 | flexDirection: "row",
69 | justifyContent: "space-between",
70 | });
71 |
72 | const Artist = styled(Text, {
73 | fontSize: 14,
74 | opacity: 0.6,
75 | });
76 |
77 | const Duration = styled(Text, {
78 | fontSize: 14,
79 | fontWeight: "bold",
80 | });
81 |
82 | export default FavoriteItem;
83 |
--------------------------------------------------------------------------------
/example/src/components/FavoriteList/FavoriteList.tsx:
--------------------------------------------------------------------------------
1 | import React, { Fragment } from "react";
2 | import { View } from "react-native";
3 | import { HighlightableElement } from "react-native-highlight-overlay";
4 |
5 | import ListHeader from "../ListHeader";
6 | import { getRandomImage } from "../../util";
7 |
8 | import FavoriteItem, { ITEM_HEIGHT } from "./FavoriteItem";
9 | import { styled } from "../../styled";
10 |
11 | const FAVORITES_LIST = [
12 | {
13 | title: "Let me love you",
14 | artist: "Dj Snake ft J8",
15 | duration: "4:38",
16 | imageSource: { uri: getRandomImage(ITEM_HEIGHT, 1) },
17 | },
18 | {
19 | title: "Believer",
20 | artist: "Major Lazer, Showtek",
21 | duration: "3:43",
22 | imageSource: { uri: getRandomImage(ITEM_HEIGHT, 2) },
23 | },
24 | {
25 | title: "Don't let me down",
26 | artist: "The Chainsmokers",
27 | duration: "3:18",
28 | imageSource: { uri: getRandomImage(ITEM_HEIGHT, 3) },
29 | },
30 | {
31 | title: "Last night",
32 | artist: "The dude that never quits",
33 | duration: "2:11",
34 | imageSource: { uri: getRandomImage(ITEM_HEIGHT, 4) },
35 | },
36 | ];
37 |
38 | const getUniqueKeyForItem = (item: typeof FAVORITES_LIST[number]) =>
39 | `${item.title}+${item.artist}+${item.duration}`;
40 |
41 | export type FavoriteListProps = {
42 | setHighlightId: (id: string | null) => void;
43 | };
44 |
45 | function FavoriteList({ setHighlightId }: FavoriteListProps) {
46 | return (
47 |
48 | {
51 | const randomIdx = Math.round(Math.random() * (FAVORITES_LIST.length - 1));
52 | const item = FAVORITES_LIST[randomIdx];
53 | setHighlightId(getUniqueKeyForItem(item));
54 | }}
55 | />
56 |
57 | {FAVORITES_LIST.map((favItem) => (
58 |
59 |
68 |
69 |
70 | {/* We don't want to highlight the margin, so place it outside */}
71 |
72 |
73 | ))}
74 |
75 |
76 | );
77 | }
78 |
79 | const Container = styled(View, {
80 | flex: 1,
81 | });
82 |
83 | const ListContainer = styled(View, {
84 | flex: 1,
85 | });
86 |
87 | const FavoriteItemSpacer = styled(View, {
88 | height: 15,
89 | });
90 |
91 | export default FavoriteList;
92 |
--------------------------------------------------------------------------------
/example/src/components/FavoriteList/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./FavoriteList";
2 |
--------------------------------------------------------------------------------
/example/src/components/Header.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Platform, StatusBar, Text, View } from "react-native";
3 | import { FadeDuringHighlight } from "react-native-highlight-overlay";
4 | import { styled } from "../styled";
5 |
6 | function Header() {
7 | return (
8 |
9 |
10 | 25
11 | /30
12 |
13 | Radio 160
14 | 115k+ favourites
15 |
16 | );
17 | }
18 |
19 | const Container = styled(FadeDuringHighlight, {
20 | backgroundColor: "#0A091C",
21 | elevation: 5,
22 | paddingHorizontal: 25,
23 | paddingTop: Math.max(Platform.select({ android: StatusBar.currentHeight }), 50),
24 | paddingBottom: 50,
25 | });
26 |
27 | const CountContainer = styled(View, {
28 | flexDirection: "row",
29 | alignItems: "flex-end",
30 | marginBottom: 10,
31 | });
32 |
33 | const CountSmall = styled(Text, {
34 | color: "#FAFAFA",
35 | fontSize: 14,
36 | });
37 |
38 | const CountLarge = styled(Text, {
39 | color: "#FAFAFA",
40 | fontSize: 18,
41 | });
42 |
43 | const Title = styled(Text, {
44 | color: "#FAFAFA",
45 | fontSize: 36,
46 | });
47 |
48 | const FavoritesText = styled(Text, {
49 | color: "#FAFAFA",
50 | fontSize: 12,
51 | opacity: 0.8,
52 | });
53 |
54 | export default Header;
55 |
--------------------------------------------------------------------------------
/example/src/components/ListHeader.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Pressable, Text, View } from "react-native";
3 | import { styled } from "../styled";
4 |
5 | export type ListHeaderProps = {
6 | title: string;
7 | onHighlightPressed: () => void;
8 | };
9 |
10 | function ListHeader({ title, onHighlightPressed }: ListHeaderProps) {
11 | return (
12 |
13 | {title}
14 |
15 | Highlight random
16 |
17 |
18 | );
19 | }
20 |
21 | const Header = styled(View, {
22 | flexDirection: "row",
23 | alignItems: "center",
24 | justifyContent: "space-between",
25 | marginBottom: 30,
26 | });
27 |
28 | const HeaderText = styled(Text, {
29 | fontSize: 24,
30 | });
31 |
32 | const HighlightButton = styled(Pressable, {
33 | backgroundColor: "white",
34 | padding: 5,
35 | borderRadius: 5,
36 | });
37 |
38 | const HighlightButtonText = styled(Text, {
39 | fontSize: 14,
40 | });
41 |
42 | export default ListHeader;
43 |
--------------------------------------------------------------------------------
/example/src/components/SimilarList/SimilarItem.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import type { ImageSourcePropType, StyleProp, ViewStyle } from "react-native";
3 | import { Image as RNImage, Text, View } from "react-native";
4 | import { styled } from "../../styled";
5 |
6 | export const ICON_SIZE = {
7 | width: 100,
8 | height: 140,
9 | };
10 |
11 | const BORDER_RADUIS = 15;
12 |
13 | export type SimilarItemProps = {
14 | title: string;
15 | imageSource: ImageSourcePropType;
16 | style?: StyleProp;
17 | };
18 |
19 | function SimilarItem({ title, imageSource, style }: SimilarItemProps) {
20 | return (
21 |
22 |
23 | {title}
24 |
25 | );
26 | }
27 |
28 | const Container = styled(View, {
29 | alignItems: "center",
30 | backgroundColor: "#F0F0F0",
31 | borderRadius: BORDER_RADUIS,
32 | });
33 |
34 | const Image = styled(RNImage, {
35 | ...ICON_SIZE,
36 | borderRadius: BORDER_RADUIS,
37 | marginBottom: 10,
38 | });
39 |
40 | const Title = styled(Text, {
41 | fontSize: 14,
42 | });
43 |
44 | export default SimilarItem;
45 |
--------------------------------------------------------------------------------
/example/src/components/SimilarList/SimilarList.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { View } from "react-native";
3 | import { HighlightableElement } from "react-native-highlight-overlay";
4 | import { styled } from "../../styled";
5 |
6 | import { getRandomImage } from "../../util";
7 | import ListHeader from "../ListHeader";
8 |
9 | import SimilarItem, { ICON_SIZE } from "./SimilarItem";
10 |
11 | const SIMILAR_ITEMS = [
12 | {
13 | title: "Top 15 rap",
14 | imageSource: { uri: getRandomImage(ICON_SIZE, 11) },
15 | },
16 | {
17 | title: "Radio Mirchi",
18 | imageSource: { uri: getRandomImage(ICON_SIZE, 12) },
19 | },
20 | {
21 | title: "SPB: Top 50",
22 | imageSource: { uri: getRandomImage(ICON_SIZE, 13) },
23 | },
24 | ];
25 |
26 | const getUniqueKeyForItem = (item: typeof SIMILAR_ITEMS[number]) => item.title;
27 |
28 | export type SimilarListProps = {
29 | setHighlightId: (id: string | null) => void;
30 | };
31 |
32 | function SimilarList({ setHighlightId }: SimilarListProps) {
33 | return (
34 |
35 | {
38 | const randomIdx = Math.round(Math.random() * (SIMILAR_ITEMS.length - 1));
39 | const item = SIMILAR_ITEMS[randomIdx];
40 | setHighlightId(getUniqueKeyForItem(item));
41 | }}
42 | />
43 |
44 | {SIMILAR_ITEMS.map((item) => (
45 |
52 | [
53 | M(x + width * 0.5, y),
54 | L(x + width * 0.65, y + height * 0.33),
55 | L(x + width, y + height * 0.33),
56 | L(x + width * 0.7, y + height * 0.6),
57 | L(x + width * 0.85, y + height),
58 |
59 | L(x + width * 0.5, y + height * 0.75),
60 |
61 | L(x + width * 0.15, y + height),
62 | L(x + width * 0.3, y + height * 0.6),
63 | L(x, y + height * 0.33),
64 | L(x + width * 0.35, y + height * 0.33),
65 | z,
66 | ].join(" "),
67 | }}
68 | >
69 |
70 |
71 | ))}
72 |
73 |
74 | );
75 | }
76 |
77 | const M = (x: number, y: number) => `M ${x} ${y}`;
78 | const L = (x: number, y: number) => `L ${x} ${y}`;
79 | const z = "z";
80 |
81 | const Container = styled(View, {
82 | flex: 1,
83 | });
84 |
85 | const ListContainer = styled(View, {
86 | flex: 1,
87 | flexDirection: "row",
88 | justifyContent: "space-between",
89 | });
90 |
91 | export default SimilarList;
92 |
--------------------------------------------------------------------------------
/example/src/components/SimilarList/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./SimilarList";
2 |
--------------------------------------------------------------------------------
/example/src/styled.tsx:
--------------------------------------------------------------------------------
1 | import { JSXElementConstructor, PropsWithChildren } from "react";
2 | import { StyleProp, StyleSheet } from "react-native";
3 |
4 | type StyledStyle = {
5 | [key in keyof TStyle]: TStyle[key];
6 | };
7 |
8 | type ComponentStyle = TComponent extends JSXElementConstructor
9 | ? TProps extends {
10 | style?: infer TStyle;
11 | }
12 | ? TStyle
13 | : never
14 | : never;
15 |
16 | type ActualStyle = TStyle extends StyleProp ? TRealStyle : TStyle;
17 |
18 | type PropsOf = TComponent extends JSXElementConstructor
19 | ? TInferProps
20 | : never;
21 |
22 | type MakeOptional = NonNullable> & Partial>;
23 |
24 | type DefinedKeys = {
25 | [key in keyof T as undefined extends T[key] ? never : key]: T[key];
26 | };
27 |
28 | export const styled = ,>(
29 | ComponentType: TComponent,
30 | style?: StyledStyle>>,
31 | props?: TComponent extends JSXElementConstructor ? Partial : never
32 | ) => {
33 | const nativeStyle = StyleSheet.create({ theStyle: style }).theStyle;
34 |
35 | type StyledComponentProps = PropsWithChildren<
36 | MakeOptional, typeof props> & {
37 | style?: ComponentStyle;
38 | }
39 | >;
40 |
41 | return function StyledComponent({ style: userStyle, ...userProps }: StyledComponentProps) {
42 | return (
43 | // @ts-expect-error Bad React typing
44 |
49 | );
50 | };
51 | };
52 |
--------------------------------------------------------------------------------
/example/src/util.ts:
--------------------------------------------------------------------------------
1 | export const getRandomImage = (
2 | pxSize: number | { width: number; height: number },
3 | randomIdx: number
4 | ) =>
5 | typeof pxSize === "number"
6 | ? `https://picsum.photos/${pxSize}?random=${randomIdx}`
7 | : `https://picsum.photos/${pxSize.width}/${pxSize.height}?random=${randomIdx}`;
8 |
--------------------------------------------------------------------------------
/example/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {},
3 | "extends": "expo/tsconfig.base"
4 | }
5 |
--------------------------------------------------------------------------------
/example/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 |
3 | const createExpoWebpackConfigAsync = require("@expo/webpack-config");
4 |
5 | const { resolver } = require("./metro.config");
6 |
7 | const root = path.resolve(__dirname, "..");
8 | const node_modules = path.join(__dirname, "node_modules");
9 |
10 | module.exports = async function (env, argv) {
11 | const config = await createExpoWebpackConfigAsync(env, argv);
12 |
13 | config.module.rules.push({
14 | test: /\.(js|jsx|ts|tsx)$/,
15 | include: path.resolve(root, "src"),
16 | use: "babel-loader",
17 | });
18 |
19 | // We need to make sure that only one version is loaded for peerDependencies
20 | // So we alias them to the versions in example's node_modules
21 | Object.assign(config.resolve.alias, {
22 | ...resolver.extraNodeModules,
23 | "react-native-web": path.join(node_modules, "react-native-web"),
24 | });
25 |
26 | return config;
27 | };
28 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-highlight-overlay",
3 | "version": "1.4.0",
4 | "description": "A tinted overlay that allows one or more elements to be highlighted (non-tinted)",
5 | "main": "lib/commonjs/index",
6 | "module": "lib/module/index",
7 | "types": "lib/typescript/index.d.ts",
8 | "react-native": "src/index",
9 | "source": "src/index",
10 | "files": [
11 | "src",
12 | "lib",
13 | "android",
14 | "ios",
15 | "cpp",
16 | "react-native-highlight-overlay.podspec",
17 | "!lib/typescript/example",
18 | "!android/build",
19 | "!ios/build",
20 | "!**/__tests__",
21 | "!**/__fixtures__",
22 | "!**/__mocks__"
23 | ],
24 | "scripts": {
25 | "test": "jest",
26 | "typescript": "tsc --noEmit",
27 | "lint": "eslint \"**/*.{js,ts,tsx}\"",
28 | "prepare": "bob build",
29 | "release": "dotenv release-it --",
30 | "example": "yarn --cwd example",
31 | "pods": "cd example && pod-install --quiet",
32 | "bootstrap": "yarn example && yarn && yarn pods"
33 | },
34 | "keywords": [
35 | "react-native",
36 | "ios",
37 | "android",
38 | "web",
39 | "overlay",
40 | "highlight",
41 | "focus",
42 | "typed",
43 | "typescript",
44 | "tooltip",
45 | "tutorial",
46 | "hint",
47 | "walkthrough"
48 | ],
49 | "repository": "https://github.com/Charanor/react-native-highlight-overlay",
50 | "author": "Jesper Sporron (https://github.com/Charanor)",
51 | "license": "MIT",
52 | "bugs": {
53 | "url": "https://github.com/Charanor/react-native-highlight-overlay/issues"
54 | },
55 | "homepage": "https://github.com/Charanor/react-native-highlight-overlay#readme",
56 | "publishConfig": {
57 | "registry": "https://registry.npmjs.org/"
58 | },
59 | "devDependencies": {
60 | "@commitlint/config-conventional": "^11.0.0",
61 | "@react-native-community/eslint-config": "^3.0.2",
62 | "@release-it/conventional-changelog": "^2.0.0",
63 | "@types/jest": "^26.0.0",
64 | "@types/lodash.isequal": "^4.5.5",
65 | "@types/react": "^16.9.19",
66 | "@types/react-native": "^0.64.12",
67 | "@typescript-eslint/eslint-plugin": "^5.24.0",
68 | "@typescript-eslint/parser": "^5.24.0",
69 | "@typescript-eslint/typescript-estree": "^5.24.0",
70 | "commitlint": "^11.0.0",
71 | "dotenv-cli": "^4.0.0",
72 | "eslint": "^8.15.0",
73 | "eslint-config-prettier": "^8.5.0",
74 | "eslint-config-react-native-wcandillon": "^3.8.0",
75 | "eslint-plugin-prettier": "^4.0.0",
76 | "eslint-plugin-react-hooks": "^4.5.0",
77 | "eslint-plugin-tsc": "^2.0.0",
78 | "husky": "^7.0.0",
79 | "jest": "^27.0.6",
80 | "pod-install": "^0.1.0",
81 | "prettier": "^2.6.2",
82 | "react": "17.0.2",
83 | "react-native": "0.66.0",
84 | "react-native-builder-bob": "^0.18.0",
85 | "react-native-reanimated": "^2.6.0",
86 | "react-native-svg": "^12.3.0",
87 | "release-it": "^14.2.2",
88 | "typescript": "4.8.4"
89 | },
90 | "peerDependencies": {
91 | "react": "*",
92 | "react-native": "*",
93 | "react-native-reanimated": "^2.6.0",
94 | "react-native-svg": "^12.3.0"
95 | },
96 | "jest": {
97 | "preset": "react-native",
98 | "modulePathIgnorePatterns": [
99 | "/example/node_modules",
100 | "/lib/"
101 | ]
102 | },
103 | "commitlint": {
104 | "extends": [
105 | "@commitlint/config-conventional"
106 | ]
107 | },
108 | "release-it": {
109 | "git": {
110 | "commitMessage": "chore: release ${version}",
111 | "tagName": "v${version}"
112 | },
113 | "npm": {
114 | "publish": true
115 | },
116 | "github": {
117 | "release": true
118 | },
119 | "plugins": {
120 | "@release-it/conventional-changelog": {
121 | "preset": "angular"
122 | }
123 | }
124 | },
125 | "react-native-builder-bob": {
126 | "source": "src",
127 | "output": "lib",
128 | "targets": [
129 | "commonjs",
130 | "module",
131 | [
132 | "typescript",
133 | {
134 | "project": "tsconfig.build.json"
135 | }
136 | ]
137 | ]
138 | },
139 | "dependencies": {
140 | "lodash.isequal": "^4.5.0"
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/scripts/bootstrap.js:
--------------------------------------------------------------------------------
1 | const os = require('os');
2 | const path = require('path');
3 | const child_process = require('child_process');
4 |
5 | const root = path.resolve(__dirname, '..');
6 | const args = process.argv.slice(2);
7 | const options = {
8 | cwd: process.cwd(),
9 | env: process.env,
10 | stdio: 'inherit',
11 | encoding: 'utf-8',
12 | };
13 |
14 | if (os.type() === 'Windows_NT') {
15 | options.shell = true
16 | }
17 |
18 | let result;
19 |
20 | if (process.cwd() !== root || args.length) {
21 | // We're not in the root of the project, or additional arguments were passed
22 | // In this case, forward the command to `yarn`
23 | result = child_process.spawnSync('yarn', args, options);
24 | } else {
25 | // If `yarn` is run without arguments, perform bootstrap
26 | result = child_process.spawnSync('yarn', ['bootstrap'], options);
27 | }
28 |
29 | process.exitCode = result.status;
30 |
--------------------------------------------------------------------------------
/src/FadeDuringHighlight.tsx:
--------------------------------------------------------------------------------
1 | import type { PropsWithChildren } from "react";
2 | import React from "react";
3 | import type { StyleProp, ViewStyle } from "react-native";
4 | import { Pressable, StyleSheet, View } from "react-native";
5 | import Animated from "react-native-reanimated";
6 |
7 | import { useHighlightableElements } from "./context";
8 |
9 | const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
10 |
11 | export type FadeDuringHighlightProps = PropsWithChildren<{
12 | style?: StyleProp;
13 | }>;
14 |
15 | /**
16 | * A component that will fade its children (cover them with a view) when a `HighlightOverlay` is visible.
17 | * This is mostly useful if you are forced to place your `HighlightOverlay` inside of a view (e.g. scroll view)
18 | * and want other items outside of the view to also be faded when the highlight is visible.
19 | *
20 | * @since 1.3
21 | */
22 | function FadeDuringHighlight({ children, style }: FadeDuringHighlightProps): JSX.Element {
23 | const [_, { getCurrentActiveOverlay }] = useHighlightableElements();
24 |
25 | const currentActiveOverlay = getCurrentActiveOverlay();
26 |
27 | return (
28 |
29 | {children}
30 | {currentActiveOverlay != null && (
31 |
37 |
46 |
47 | )}
48 |
49 | );
50 | }
51 |
52 | export default FadeDuringHighlight;
53 |
--------------------------------------------------------------------------------
/src/HighlightOverlay.tsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useMemo, useState } from "react";
2 | import { StyleSheet, View } from "react-native";
3 | import Animated, { FadeIn, FadeOut } from "react-native-reanimated";
4 | import type { RectProps } from "react-native-svg";
5 | import Svg, { ClipPath, Defs, Path, Rect } from "react-native-svg";
6 |
7 | import constructClipPath from "./constructClipPath";
8 | import { useHighlightableElements } from "./context";
9 | import type { Bounds } from "./context/context";
10 |
11 | const AnimatedSvg = Animated.createAnimatedComponent(Svg);
12 |
13 | const DEFAULT_OVERLAY_STYLE: Required = {
14 | color: "black",
15 | opacity: 0.7,
16 | };
17 |
18 | export type OverlayStyle = {
19 | /**
20 | * The color of the overlay. Should not include alpha in the color, use `opacity` prop for that.
21 | *
22 | * @default "black"
23 | * @since 1.3
24 | */
25 | color?: string;
26 |
27 | /**
28 | * The opacity of the overlay color.
29 | *
30 | * @default 0.7
31 | * @since 1.3
32 | */
33 | opacity?: number;
34 | };
35 |
36 | export type EnteringAnimation = Animated.AnimateProps["entering"];
37 |
38 | export type HighlightOverlayProps = {
39 | /**
40 | * The id of the highlighted element. If `undefined`, `null`, or if the id does not exist,
41 | * the overlay is hidden.
42 | *
43 | * @since 1.0
44 | */
45 | highlightedElementId?: string | null;
46 |
47 | /**
48 | * Called when the highlight is requesting to be dismissed. This is usually when the overlay
49 | * (non-highlighted) part of the screen is pressed. The exact behavior is decided by each
50 | * HighlightableElement.
51 | *
52 | * @since 1.0
53 | */
54 | onDismiss: () => void;
55 |
56 | /**
57 | * The style of the overlay.
58 | *
59 | * @default { color: "black", opacity: 0.7 }
60 | * @since 1.3
61 | */
62 | overlayStyle?: OverlayStyle;
63 |
64 | /**
65 | * The animation when the overlay is entering the screen. Defaults to `FadeIn`.
66 | * Set to `null` (not `undefined`!) to disable animation.
67 | *
68 | * @default FadeIn
69 | * @example
70 | * import { FadeIn } from "react-native-reanimated";
71 | *
72 | * @since 1.3
73 | */
74 | entering?: EnteringAnimation | null;
75 |
76 | /**
77 | * The animation when the overlay is exiting the screen. Defaults to `FadeOut`.
78 | * Set to `null` (not `undefined`!) to disable animation.
79 | *
80 | * @default undefined
81 | * @example
82 | * import { FadeOut } from "react-native-reanimated";
83 | *
84 | * @since 1.3
85 | */
86 | exiting?: EnteringAnimation | null;
87 | };
88 |
89 | /**
90 | * An overlay that optionally takes the id of a `HighlightableElement` to highlight
91 | * (exclude from the overlay). This is not a modal, so it should be placed on top of all elements
92 | * you want it to cover.
93 | *
94 | * **NOTE:** If the highlighted element is inside of a `ScrollView`, the `HighlightOverlay` should also
95 | * be inside of that scroll view to ensure that the highlight is correctly placed.
96 | *
97 | * @since 1.0
98 | */
99 | const HighlightOverlay = React.memo(
100 | ({
101 | highlightedElementId,
102 | onDismiss,
103 | overlayStyle = DEFAULT_OVERLAY_STYLE,
104 | entering = FadeIn,
105 | exiting = FadeOut,
106 | }: HighlightOverlayProps) => {
107 | const [elements, { setCurrentActiveOverlay }] = useHighlightableElements();
108 | const [parentSize, setParentSize] = useState();
109 |
110 | const highlightedElementData = useMemo(
111 | () => (highlightedElementId != null ? elements[highlightedElementId] : null),
112 | [elements, highlightedElementId]
113 | );
114 |
115 | const hasContent = highlightedElementData != null && parentSize != null;
116 | const clickThrough = highlightedElementData?.options?.clickthroughHighlight ?? true;
117 | const { color = DEFAULT_OVERLAY_STYLE.color, opacity = DEFAULT_OVERLAY_STYLE.opacity } =
118 | overlayStyle;
119 |
120 | useEffect(() => {
121 | setCurrentActiveOverlay(
122 | highlightedElementId == null
123 | ? null
124 | : { color, opacity, entering, exiting, onDismiss }
125 | );
126 | // Dependency array should NOT include `onDismiss` prop
127 | // eslint-disable-next-line react-hooks/exhaustive-deps
128 | }, [color, entering, exiting, highlightedElementId, opacity, setCurrentActiveOverlay]);
129 |
130 | return (
131 | setParentSize(layout)}
134 | pointerEvents="box-none"
135 | >
136 | {hasContent && (
137 |
145 |
146 | {Object.entries(elements).map(([id, element]) => (
147 |
148 |
152 |
153 | ))}
154 |
155 |
164 |
165 | )}
166 |
167 | );
168 | },
169 | (prevProps, nextProps) =>
170 | // We need this here so we don't check the `onDismiss` prop.
171 | prevProps.highlightedElementId === nextProps.highlightedElementId &&
172 | prevProps.overlayStyle?.color === nextProps.overlayStyle?.color &&
173 | prevProps.overlayStyle?.opacity === nextProps.overlayStyle?.opacity &&
174 | prevProps.entering === nextProps.entering
175 | );
176 |
177 | export default HighlightOverlay;
178 |
--------------------------------------------------------------------------------
/src/HighlightableElement.tsx:
--------------------------------------------------------------------------------
1 | import type { PropsWithChildren } from "react";
2 | import React, { useEffect, useRef } from "react";
3 | import type { HostComponent, StyleProp, ViewStyle } from "react-native";
4 | import { View } from "react-native";
5 |
6 | import { useHighlightableElements } from "./context";
7 | import type { HighlightOptions } from "./context/context";
8 |
9 | export type HighlightableElementProps = PropsWithChildren<{
10 | /**
11 | * The id used by the HighlightOverlay to find this element.
12 | * @since 1.0
13 | */
14 | id: string;
15 | /**
16 | * The options that decide how this element should look. If left undefined, it only highlights the element.
17 | * @since 1.2
18 | */
19 | options?: HighlightOptions;
20 | style?: StyleProp;
21 | }>;
22 |
23 | /**
24 | * A component that allows its children to be highlighted by the `HighlightOverlay` component.
25 | *
26 | * @since 1.0
27 | */
28 | const HighlightableElement = React.memo(
29 | ({ id, options, children, style }: HighlightableElementProps) => {
30 | const ref = useRef(null);
31 |
32 | const [_, { addElement, getRootRef }] = useHighlightableElements();
33 | const rootRef = getRootRef();
34 |
35 | useEffect(() => {
36 | const refVal = ref.current;
37 | if (refVal == null || rootRef == null) {
38 | return;
39 | }
40 |
41 | const timeoutId = setTimeout(() => {
42 | ref.current?.measureLayout(
43 | // This is a typing error on ReactNative's part. 'rootRef' is a valid reference.
44 | rootRef as unknown as HostComponent,
45 | (x, y, width, height) => {
46 | addElement(id, children, { x, y, width, height }, options);
47 | },
48 | () => {
49 | ref.current?.measureInWindow((x, y, width, height) => {
50 | addElement(id, children, { x, y, width, height }, options);
51 | });
52 | }
53 | );
54 | }, 0);
55 |
56 | return () => {
57 | clearTimeout(timeoutId);
58 | };
59 | // We don't want to re-run this effect when addElement or removeElement changes.
60 | // eslint-disable-next-line react-hooks/exhaustive-deps
61 | }, [id, children, rootRef]);
62 |
63 | return (
64 |
65 | {children}
66 |
67 | );
68 | }
69 | );
70 |
71 | export default HighlightableElement;
72 |
--------------------------------------------------------------------------------
/src/constructClipPath.ts:
--------------------------------------------------------------------------------
1 | import type { Bounds, ElementsRecord, HighlightOffset } from "./context/context";
2 |
3 | const NO_OFFSET: HighlightOffset = { x: 0, y: 0 };
4 |
5 | type ElementBounds = {
6 | startX: number;
7 | startY: number;
8 | endX: number;
9 | endY: number;
10 | };
11 |
12 | const M = (x: number, y: number) => `M ${x} ${y}`;
13 | const L = (x: number, y: number) => `L ${x} ${y}`;
14 | const arc = (toX: number, toY: number, radius: number) =>
15 | `A ${radius},${radius} 0 0 0 ${toX},${toY}`;
16 | const z = "z";
17 |
18 | const filledSquare = (parentBounds: ElementBounds): string =>
19 | [
20 | M(parentBounds.startX, parentBounds.startY),
21 | L(parentBounds.startX, parentBounds.endY),
22 | L(parentBounds.endX, parentBounds.endY),
23 | L(parentBounds.endX, parentBounds.startY),
24 | z,
25 | ].join(" ");
26 |
27 | const constructClipPath = (data: ElementsRecord[string], containerSize: Bounds): string => {
28 | const parentBounds = {
29 | startX: 0,
30 | startY: 0,
31 | endX: containerSize.width,
32 | endY: containerSize.height,
33 | };
34 |
35 | const { x: offsetX = 0, y: offsetY = 0 } = data.options?.offset ?? NO_OFFSET;
36 |
37 | switch (data.options?.mode) {
38 | case "circle": {
39 | const {
40 | bounds: { x, y, width, height },
41 | options: { padding = 0 },
42 | } = data;
43 | const radius = Math.max(width, height) / 2;
44 | return constructCircularPath(
45 | parentBounds,
46 | { cx: x + width / 2 + offsetX, cy: y + height / 2 + offsetY },
47 | radius + padding
48 | );
49 | }
50 | case "custom": {
51 | return constructCustomPath(data.options.createPath(data.bounds), parentBounds);
52 | }
53 | case "rectangle": // !Fallthrough
54 | default: {
55 | const padding = data.options?.padding ?? 0;
56 | const borderRadius = data.options?.borderRadius ?? 0;
57 |
58 | const startX = data.bounds.x - padding + offsetX;
59 | const endX = startX + data.bounds.width + padding * 2;
60 | const startY = data.bounds.y - padding + offsetY;
61 | const endY = startY + data.bounds.height + padding * 2;
62 | return constructRectangularPath(
63 | parentBounds,
64 | { startX, startY, endX, endY },
65 | borderRadius
66 | );
67 | }
68 | }
69 | };
70 |
71 | const constructRectangularPath = (
72 | parentBounds: ElementBounds,
73 | { startX, startY, endX, endY }: ElementBounds,
74 | borderRadius: number
75 | ): string => {
76 | return [
77 | filledSquare(parentBounds),
78 | M(startX, startY + borderRadius),
79 | L(startX, endY - borderRadius),
80 | arc(startX + borderRadius, endY, borderRadius),
81 | L(endX - borderRadius, endY),
82 | arc(endX, endY - borderRadius, borderRadius),
83 | L(endX, startY + borderRadius),
84 | arc(endX - borderRadius, startY, borderRadius),
85 | L(startX + borderRadius, startY),
86 | arc(startX, startY + borderRadius, borderRadius),
87 | ].join(" ");
88 | };
89 |
90 | const constructCircularPath = (
91 | parentBounds: ElementBounds,
92 | { cx, cy }: { cx: number; cy: number },
93 | radius: number
94 | ): string => {
95 | return [
96 | filledSquare(parentBounds),
97 | M(cx, cy),
98 | `m ${-radius} 0`,
99 | `a ${radius},${radius} 0 1,0 ${radius * 2},0`,
100 | `a ${radius},${radius} 0 1,0 ${-radius * 2},0`,
101 | ].join(" ");
102 | };
103 |
104 | const constructCustomPath = (userDefinedPath: string, parentBounds: ElementBounds): string =>
105 | [filledSquare(parentBounds), userDefinedPath].join(" ");
106 |
107 | export default constructClipPath;
108 |
--------------------------------------------------------------------------------
/src/context/HighlightableElementProvider.tsx:
--------------------------------------------------------------------------------
1 | import type { PropsWithChildren } from "react";
2 | import React, { useCallback, useMemo, useState } from "react";
3 | import { StyleSheet, View } from "react-native";
4 | import isEqual from "lodash.isequal";
5 |
6 | import type {
7 | AddElement,
8 | ElementsRecord,
9 | GetCurrentActiveOverlay,
10 | OverlayData,
11 | RemoveElement,
12 | RootRefGetter,
13 | } from "./context";
14 | import HighlightableElementContext from "./context";
15 |
16 | export type HighlightableElementProviderProps = PropsWithChildren<{
17 | /**
18 | * The reference to the root of the DOM. If (and only if) this is left as undefined,
19 | * this component will instantiate a View as a child and use that as the root instead.
20 | * You usually don't need to set this, unless either:
21 | * - The wrapper we provide is making your app look weird. This can happen when you use
22 | * tab bars / headers / etc.
23 | * - You have several providers for whatever reason (you probably shouldn't).
24 | *
25 | * @since 1.0
26 | */
27 | rootRef?: React.Component | null;
28 | }>;
29 |
30 | /**
31 | * The context provider that provides `HighlightOverlay` with the id's of all the
32 | * `HighlightableElement`s.
33 | *
34 | * If the `rootRef` prop is not set this provider must be placed top-level since it also serves as
35 | * the relative measuring point for the highlights.
36 | *
37 | * If the `rootRef` prop **is** set it only has to be above the `rootRef` and all `HighlightOverlay`
38 | * and `HighlightableElement` that is being used.
39 | *
40 | * @since 1.0
41 | */
42 | function HighlightableElementProvider({
43 | rootRef: externalRootRef,
44 | children,
45 | }: HighlightableElementProviderProps): JSX.Element {
46 | const [rootRef, setRootRef] = useState | null>(
47 | externalRootRef ?? null
48 | );
49 | const [elements, setElements] = useState({});
50 | const [currentActiveOverlay, setCurrentActiveOverlay] = useState(null);
51 |
52 | const addElement = useCallback(
53 | (id, node, bounds, options) => {
54 | if (
55 | elements[id] == null ||
56 | !isEqual(bounds, elements[id].bounds) ||
57 | !isEqual(options, elements[id].options)
58 | ) {
59 | setElements((oldElements) => ({ ...oldElements, [id]: { node, bounds, options } }));
60 | }
61 | },
62 | [elements]
63 | );
64 |
65 | const removeElement: RemoveElement = useCallback((id) => {
66 | setElements((oldElements) => {
67 | delete oldElements[id];
68 | return { ...oldElements };
69 | });
70 | }, []);
71 |
72 | const getRootRef = useCallback(
73 | () => externalRootRef ?? rootRef,
74 | [externalRootRef, rootRef]
75 | );
76 |
77 | const getCurrentActiveOverlay = useCallback(
78 | () => currentActiveOverlay,
79 | [currentActiveOverlay]
80 | );
81 |
82 | const contextValue = useMemo(
83 | () =>
84 | Object.freeze([
85 | elements,
86 | {
87 | addElement,
88 | removeElement,
89 | rootRef: externalRootRef ?? rootRef,
90 | getRootRef,
91 | setCurrentActiveOverlay,
92 | getCurrentActiveOverlay,
93 | },
94 | ] as const),
95 | [
96 | addElement,
97 | elements,
98 | externalRootRef,
99 | getCurrentActiveOverlay,
100 | getRootRef,
101 | removeElement,
102 | rootRef,
103 | ]
104 | );
105 |
106 | if (externalRootRef == null) {
107 | return (
108 |
109 |
110 | {children}
111 |
112 |
113 | );
114 | } else {
115 | return (
116 |
117 | {children}
118 |
119 | );
120 | }
121 | }
122 |
123 | const styles = StyleSheet.create({
124 | rootWrapper: {
125 | flex: 1,
126 | },
127 | });
128 |
129 | export default HighlightableElementProvider;
130 |
--------------------------------------------------------------------------------
/src/context/context.ts:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import type { HighlightOverlayProps, OverlayStyle } from "../HighlightOverlay";
4 |
5 | export type OverlayData = {
6 | entering: HighlightOverlayProps["entering"];
7 | exiting: HighlightOverlayProps["exiting"];
8 | onDismiss: HighlightOverlayProps["onDismiss"];
9 | } & Required;
10 |
11 | export type HighlightOffset = {
12 | x: number;
13 | y: number;
14 | };
15 |
16 | export type HighlightOptions = CommonOptions &
17 | (RectangleOptions | CircleOptions | CustomHighlightOptions);
18 |
19 | export type CommonOptions = {
20 | /**
21 | * If true, allows the user to click elements inside the highlight. Otherwise clicking inside the
22 | * highlight will act the same as clicking outside the highlight, calling `onDismiss`.
23 | * @default true
24 | * @since 1.0
25 | */
26 | // Typo - should be clickThrough (click-through is hyphenated).
27 | clickthroughHighlight?: boolean;
28 |
29 | /**
30 | * If you want your highlight to be offset slightly from its original position you can manually
31 | * specify an offset here. Especially useful if your highlight is inside of a scroll view
32 | * (see example project).
33 | *
34 | * @since 1.3
35 | */
36 | offset?: HighlightOffset;
37 | };
38 |
39 | export type RectangleOptions = {
40 | mode: "rectangle" | undefined;
41 | /**
42 | * The border radius of the rectangle.
43 | * @default 0
44 | * @since 1.0
45 | */
46 | borderRadius?: number;
47 | /**
48 | * The padding of the rectangle.
49 | * @default 0
50 | * @since 1.0
51 | */
52 | padding?: number;
53 | };
54 |
55 | export type CircleOptions = {
56 | mode: "circle";
57 | /**
58 | * The padding of the circle.
59 | * @default 0
60 | * @since 1.0
61 | */
62 | padding?: number;
63 | };
64 |
65 | export type CustomHighlightOptions = {
66 | mode: "custom";
67 | /**
68 | * Should return a valid SVG path.
69 | * @param bounds the bounds of the element that is being highlighted
70 | * @since 1.4
71 | */
72 | createPath: (bounds: Bounds) => string;
73 | };
74 |
75 | export type Bounds = {
76 | x: number;
77 | y: number;
78 | width: number;
79 | height: number;
80 | };
81 |
82 | export type ElementsRecord = Record<
83 | string,
84 | {
85 | node: React.ReactNode;
86 | bounds: Bounds;
87 | options?: HighlightOptions;
88 | }
89 | >;
90 |
91 | export type AddElement = (
92 | id: string,
93 | node: React.ReactNode,
94 | bounds: Bounds,
95 | options?: HighlightOptions
96 | ) => void;
97 |
98 | export type RemoveElement = (id: string) => void;
99 |
100 | export type RootRefGetter = () => React.Component | null;
101 |
102 | export type SetCurrentActiveOverlay = (data: OverlayData | null) => void;
103 |
104 | export type GetCurrentActiveOverlay = () => OverlayData | null;
105 |
106 | export type HighlightableElementContextType = readonly [
107 | /**
108 | * @since 1.0
109 | */
110 | elements: Readonly,
111 | actions: {
112 | /**
113 | * @since 1.0
114 | */
115 | readonly addElement: AddElement;
116 | /**
117 | * @since 1.0
118 | */
119 | readonly removeElement: RemoveElement;
120 | /**
121 | * @deprecated since version `1.3`, use `getRootRef()` instead.
122 | */
123 | readonly rootRef: React.Component | null;
124 | /**
125 | * @returns the reference to the root element used to calculate offsets for the highlights.
126 | * @since 1.3
127 | */
128 | readonly getRootRef: RootRefGetter;
129 | /**
130 | * Sets the data for the current active overlay. Set `null` when no overlay is active.
131 | * @since 1.3
132 | */
133 | readonly setCurrentActiveOverlay: SetCurrentActiveOverlay;
134 | /**
135 | * Get the data for the current active overlay, or `null` when no overlay is active.
136 | * @since 1.3
137 | */
138 | readonly getCurrentActiveOverlay: GetCurrentActiveOverlay;
139 | }
140 | ];
141 |
142 | const unimplemented = (name: string) => () => {
143 | throw new Error(
144 | `No implementation for '${name}' found! Did you forget to wrap your app in ?`
145 | );
146 | };
147 |
148 | const HighlightableElementContext = React.createContext([
149 | {},
150 | {
151 | addElement: unimplemented("addElement"),
152 | removeElement: unimplemented("removeElement"),
153 | rootRef: null,
154 | getRootRef: unimplemented("getRootRef"),
155 | setCurrentActiveOverlay: unimplemented("setCurrentActiveOverlay"),
156 | getCurrentActiveOverlay: unimplemented("getCurrentActiveOverlay"),
157 | },
158 | ]);
159 |
160 | export default HighlightableElementContext;
161 |
--------------------------------------------------------------------------------
/src/context/index.ts:
--------------------------------------------------------------------------------
1 | export {
2 | default as HighlightableElementProvider,
3 | HighlightableElementProviderProps,
4 | } from "./HighlightableElementProvider";
5 | export { default as useHighlightableElements } from "./useHighlightableElements";
6 |
--------------------------------------------------------------------------------
/src/context/useHighlightableElements.ts:
--------------------------------------------------------------------------------
1 | import { useContext } from "react";
2 |
3 | import HighlightableElementContext from "./context";
4 | import type { HighlightableElementContextType } from "./context";
5 |
6 | const useHighlightableElements = (): HighlightableElementContextType =>
7 | useContext(HighlightableElementContext);
8 |
9 | export default useHighlightableElements;
10 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | export { HighlightableElementProvider } from "./context";
2 | export { default as HighlightableElement } from "./HighlightableElement";
3 | export { default as HighlightOverlay } from "./HighlightOverlay";
4 | export { default as FadeDuringHighlight } from "./FadeDuringHighlight";
5 |
--------------------------------------------------------------------------------
/tsconfig.build.json:
--------------------------------------------------------------------------------
1 |
2 | {
3 | "extends": "./tsconfig",
4 | "exclude": ["example"]
5 | }
6 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": "./",
4 | "strict": true,
5 | "esModuleInterop": true,
6 | "target": "esnext",
7 | "module": "esnext",
8 | "lib": ["esnext"],
9 | "jsx": "react",
10 | "skipLibCheck": true,
11 |
12 | "paths": {
13 | "react-native-highlight-overlay": ["./src/index"]
14 | },
15 | "allowUnreachableCode": false,
16 | "allowUnusedLabels": false,
17 | "importsNotUsedAsValues": "error",
18 | "forceConsistentCasingInFileNames": true,
19 | "moduleResolution": "node",
20 | "noFallthroughCasesInSwitch": true,
21 | "noImplicitReturns": true,
22 | "noImplicitUseStrict": false,
23 | "noStrictGenericChecks": false,
24 | "noUnusedLocals": true,
25 | "noUnusedParameters": true,
26 | "resolveJsonModule": true,
27 | }
28 | }
29 |
--------------------------------------------------------------------------------