All Projects → jasongaare → React Native Walkthrough Tooltip

jasongaare / React Native Walkthrough Tooltip

Licence: mit
An inline wrapper for calling out React Native components via tooltip

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Native Walkthrough Tooltip

postel
tiny react library for building tooltips, flyovers, menus and more
Stars: ✭ 70 (-76.59%)
Mutual labels:  tooltip
Tooltips
(unmaintained) A small tooltips library for Android based on Material Design.
Stars: ✭ 14 (-95.32%)
Mutual labels:  tooltip
Vim Cool
A very simple plugin that makes hlsearch more useful.
Stars: ✭ 268 (-10.37%)
Mutual labels:  highlighting
react-change-highlight
✨ a react component to highlight changes constantly ⚡️
Stars: ✭ 79 (-73.58%)
Mutual labels:  highlighting
remark-highlight.js
Legacy plugin to highlight code blocks with highlight.js — please use `rehype-highlight` instead
Stars: ✭ 58 (-80.6%)
Mutual labels:  highlighting
odin.vim
Vim syntax highlighting for Ginger Bill's programming language, Odin. Derived from jansedivy's jai.vim.
Stars: ✭ 16 (-94.65%)
Mutual labels:  highlighting
ak-vue3
组件库包含了 AutoForm 自动表单、BackTop 返回顶部、Breadcrumb 面包屑、 Button 按钮、Cascader 级联选择器、Checkbox 多选框、Collapse 折叠面板、ColorPicker 颜色选择器、DataPicker 时间选择器、Dialog 弹层对话框、Alert 弹框、Echarts 图形图表、Form 表单、Input 输入框、Lazy 图片延时加载、Loading 加载等待、Menu 菜单、Pagination 分页、Progress 进度条、Radio 单选框、Select 选择器、Steps 步骤条、Swiper 图片轮播、Switch 开关、Table 表格、Tabs 标签页、Textarea 文本框、Tooltip 提示、Tr…
Stars: ✭ 24 (-91.97%)
Mutual labels:  tooltip
Vue Highlightjs
Syntax highlighting with highlight.js for Vue.js 2.x
Stars: ✭ 295 (-1.34%)
Mutual labels:  highlighting
core
🌈 light, fast, and easy to use, dependencies free javascript syntax highlighter, with automatic language detection
Stars: ✭ 40 (-86.62%)
Mutual labels:  highlighting
Easy Toggle State
A tiny JavaScript library to easily toggle the state of any HTML element in any contexts, and create UI components in no time.
Stars: ✭ 261 (-12.71%)
Mutual labels:  tooltip
Bootstrap-Confirmation
Bootstrap plugin for on-place confirm boxes using Popover
Stars: ✭ 303 (+1.34%)
Mutual labels:  tooltip
SmartVHDL
SublimeText Plugin for VHDL (highlight, autocompletion, navigation, ...)
Stars: ✭ 12 (-95.99%)
Mutual labels:  tooltip
jsPanel3
A jQuery Plugin to create highly configurable floating panels, modals, tooltips, hints/notifiers or contextmenus for use in a backend solution and other web applications.
Stars: ✭ 89 (-70.23%)
Mutual labels:  tooltip
react-popover
Customizable positioning for tooltips, menus, and any other DOM elements inside of a container
Stars: ✭ 13 (-95.65%)
Mutual labels:  tooltip
Rn Tourguide
🚩Make an interactive step by step tour guide for your react-native app (a rewrite of react-native-copilot)
Stars: ✭ 269 (-10.03%)
Mutual labels:  tooltip
react-ellipsis-text
React text ellipsify component
Stars: ✭ 28 (-90.64%)
Mutual labels:  tooltip
vscode-text-marker
Visual Studio Code Extension. Select text in your code and mark all matches. The marking colour is configurable
Stars: ✭ 61 (-79.6%)
Mutual labels:  highlighting
Python Syntax
Python syntax highlighting for Vim
Stars: ✭ 297 (-0.67%)
Mutual labels:  highlighting
Tooltip Sequence
A simple step by step tooltip helper for any site
Stars: ✭ 287 (-4.01%)
Mutual labels:  tooltip
v-tippy
Vue.js binding for Tippy.js
Stars: ✭ 54 (-81.94%)
Mutual labels:  tooltip

React Native Walkthrough Tooltip npm npm

React Native Walkthrough Tooltip is a fullscreen modal that highlights whichever element it wraps.
When not visible, the wrapped element is displayed normally.

Used by react-native-walkthrough: a lightweight walkthrough library for React Native using react-native-walkthrough-tooltip

Table of Contents

Installation

yarn add react-native-walkthrough-tooltip

Breaking Changes in Version 1.0

For Version 1.0, the library was refactored and simplified.

  • No more animated prop - if you want to have your tooltips animated, use the last stable version: 0.6.1. Hopefully animations can be added again in the sure (great idea for a PR!)
  • No more displayArea and childlessPlacementPadding props - these have been replaced with the displayInsets prop, which allows you to simply declare how many pixels in from each side of the screen to inset the area the tooltip may display.
  • Tooltips are now bound by the displayInsets - before if your content was larger than the displayArea prop, the tooltip would render outside of the display area. Now the tooltip should always resize to be inside the display area as defined by the displayInsets prop
  • Removed the "auto" option for placement - you must now specify a direction
  • Added the "center" option for childless placement - option to center the tooltip within the bounds of the displayInsets when it does not point to a child
  • Added useReactNativeModal prop - this allows you to enable/disable the usage of React Native's Modal component to render the tooltip content. It is true by default.

Changes to handling users pressing the tooltip child element:

  • No more onChildPress and onChildLongPress props - touches are now passed to the child by default. This allows you to maintain the original functionality of the child element. Further, the tooltip will also automatically dismiss on interaction with the child element.
  • Added closeOnChildInteraction prop - if you want the user to be able to interact with the child element, but not automatically dismiss the tooltip when they do so, set this to false (true by default)
  • Added allowChildInteraction prop - if you'd like to disable interaction with the child element, set this to false (true by default). When false, tapping on the child element will call onClose as if the user touched the background element.

Example Usage

To see an expo snack example, click here

import Tooltip from 'react-native-walkthrough-tooltip';

<Tooltip
  isVisible={this.state.toolTipVisible}
  content={<Text>Check this out!</Text>}
  placement="top"
  onClose={() => this.setState({ toolTipVisible: false })}
>
  <TouchableHighlight style={styles.touchable}>
    <Text>Press me</Text>
  </TouchableHighlight>
</Tooltip>

Screenshot

How it works

The tooltip wraps an element in place in your React Native rendering. When it renders, it measures the location of the element, using React Native's measure. When the tooltip is displayed, it renders a copy of the wrapped element positioned absolutely on the screen at the coordinates returned after measuring (see TooltipChildrenContext below if you need to tell the difference between the copy and the original element). This allows you to touch the element in the tooltip modal rendered above your current screen.

Props

Prop name Type Default value Description
accessible bool true Set this to false if you do not want the root touchable element to be accessible. See docs on accessible here
allowChildInteraction bool true By default, the user can touch and interact with the child element. When this prop is false, the user cannot interact with the child element while the tooltip is visible.
arrowSize Size { width: 16, height: 8 } The dimensions of the arrow on the bubble pointing to the highlighted element
backgroundColor string 'rgba(0,0,0,0.5)' Color of the fullscreen background beneath the tooltip. Overrides the backgroundStyle prop
childContentSpacing number 4 The distance between the tooltip-rendered child and the arrow pointing to it
closeOnChildInteraction bool true When child interaction is allowed, this prop determines if onClose should be called when the user interacts with the child element. Default is true (usually means the tooltip will dismiss once the user touches the element highlighted)
closeOnContentInteraction bool true this prop determines if onClose should be called when the user interacts with the content element. Default is true (usually means the tooltip will dismiss once the user touches the content element)
content function/Element <View /> This is the view displayed in the tooltip popover bubble
displayInsets object { top: 24, bottom: 24, left: 24, right: 24 } The number of pixels to inset the tooltip on the screen (think of it like padding). The tooltip bubble should never render outside of these insets, so you may need to adjust your content accordingly
disableShadow bool false When true, tooltips will not appear elevated. Disabling shadows will remove the warning: RCTView has a shadow set but cannot calculate shadow efficiently on IOS devices.
isVisible bool false When true, tooltip is displayed
onClose function null Callback fired when the user taps the tooltip background overlay
placement string "top" | "center" Where to position the tooltip - options: top, bottom, left, right, center. Default is top for tooltips rendered with children Default is center for tooltips rendered without children.

NOTE: center is only available with a childless placement, and the content will be centered within the bounds defined by the displayInsets.
showChildInTooltip bool true Set this to false if you do NOT want to display the child alongside the tooltip when the tooltip is visible
supportedOrientations array ["portrait", "landscape"] This prop allows you to control the supported orientations the tooltip modal can be displayed. It correlates directly with the prop for React Native's Modal component (has no effect if useReactNativeModal is false)
topAdjustment number 0 Value which provides additional vertical offest for the child element displayed in a tooltip. Commonly set to: Platform.OS === 'android' ? -StatusBar.currentHeight : 0 due to an issue with React Native's measure function on Android
useInteractionManager bool false Set this to true if you want the tooltip to wait to become visible until the callback for InteractionManager.runAfterInteractions is executed. Can be useful if you need to wait for navigation transitions to complete, etc. See docs on InteractionManager here
useReactNativeModal bool true By default, this library uses a <Modal> component from React Native. If you need to disable this, and simply render an absolutely positioned full-screen view, set useReactNativeModal={false}. This is especially useful if you desire to render a Tooltip while you have a different Modal rendered.

Style Props

The tooltip styles should work out-of-the-box for most use cases, however should you need you can customize the styles of the tooltip using these props.

Prop name Effect
arrowStyle Styles the triangle that points to the called out element
backgroundStyle Styles the overlay view that sits behind the tooltip, but over the current view
childrenWrapperStyle Styles the view that wraps cloned children
contentStyle Styles the content wrapper that surrounds the content element
tooltipStyle Styles the tooltip that wraps the arrow and content elements

Class definitions for props

  • Size is an object with properties: { width: number, height: number }

TooltipChildrenContext

React Context that can be used to distinguish "real" children rendered inside parent's layout from their copies rendered inside tooltip's modal. The duplicate child rendered in the tooltip modal is wrapped in a Context.Provider which provides object with prop tooltipDuplicate set to true, so informed decisions may be made, if necessary, based on where the child rendered.

import Tooltip, { TooltipChildrenContext } from 'react-native-walkthrough-tooltip';
...
<Tooltip>
  <ComponentA />
  <ComponentB>
    <TooltipChildrenContext.Consumer>
      {({ tooltipDuplicate }) => (
        // will only assign a ref to the original component
        <FlatList {...(!tooltipDuplicate && { ref: this.listRef })} />
      )}
    </TooltipChildrenContext.Consumer>
  </ComponentB>
</Tooltip>
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].