') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); GitHub - Risez25/react-native-tips: Helper to show tips when you launch your react-native for the first time · GitHub
Skip to content

Repository files navigation

react-native-tips

Build Status

This module is used to create tips on your app to help your new users to understand how is your app.

Ios Android 
alt textalt text

How to install

Via NPM

# Install via npm
npm install react-native-tips --save
# Install via yarn
yarn add react-native-tips

How to use it

To use it, simply import it into yours components

importTipsfrom'react-native-tips'

Example

The most basic example of this module is to use it like this :

importReactfrom'react'import{View,Button}from'react-native'importTipsfrom'react-native-tips'constMyButton=(props={})=>(<View><Tipsvisibletext="This is a tips !"><Buttontitle="Hello world !"></Tips></View>
)
export default MyButton

Configuration

Properties of Tips:

PropertyTypeRequirementDescription
childrennodeOptionalThe children of Tips are elements that will be highlighted when the tips will be visible
positionenum (top, left, right, bottom or none)Default: topDefine the position of your tips related to the children.
visible BooleanDefault: falseSet the visibility of your Tips
textStringOptionalText inside the Tips.
contentnodeOptionalUse this property if you want to add more than a simple text inside your Tips.
onRequestClosefunctionOptionalTriggered when the user tap on the screen.
onRequestNextfunctionOptional Triggered when the user tap on the screen. (See #waterfall-tips for more.)
style ObjectOptionalOverride the style of your tips
modalStyleObjectOptionalOverride the style of the Modal Component (react-native) 
contentStyleObjectOptionalOverride the style of the content of the Modal (used for positionning the highlight elements and tips)
textStyleObjectOptionalOverride the style of the text inside the Tips
offsetLeftNumberOptionalAdd an offset of the Tips in x axis.
offsetTopNumberOptionalAdd an offset of the Tips in y axis.

Waterfall Tips

You sometimes need to show tips one after another. This module as an helper to execute this scheme. You can use new Tips.Waterfall() to create a new helper that help to you to show/hide tips in waterfall.

importReact,{PureComponent}from'react'import{View,Button,Text}from'react-native'importTipsfrom'react-native-tips'exportdefaultclassMyButtonextendsPureComponent{constructor(props){super(props)// 1st step - Create your helper with keys that will represent your tipsthis.waterfallTips=newTips.Waterfall(['myTips1','myTips2'])this.state={tipsVisible: null}// This method will trigger the changement of tipsthis.handleNextTips=this.handleNextTips.bind(this)}componentDidMount(){// the 'start' method will set the first Tips key into your state.this.setState({tipsVisible: this.waterfallTips.start()})}handleNextTips(){// the 'next' method will set the next tips key into your state until it has no more keys.this.setState({tipsVisible: this.waterfallTips.next()})}render(){const{ tipsVisible }=this.statereturn(<View><Tipsvisible={tipsVisible==='myTips1'}onRequestNext={this.handleNextTips}><Buttontext="My button"></Tips><Tipsvisible={tipsVisible==='myTips2'}onRequestNext={this.handleNextTips}><Text>My text</Text></Tips></View>
)
}}

methods of Tips.Waterfall:

MethodDescription
new Tips.Waterfall(indexes: Array< String >): Tips.WaterfallInstanciate a new waterfallTips helper.
start(): StringStart the waterfall and set the first index has the current index.
isVisible(index: String): BooleanCheck if the index passed in parameter is the current index.
createIndex(index: String): StringCreate a new index key.
next(): StringSet the next index has the current index. If it was the last key, the value will be null
previous(): StringSet the previous index has the current index. If it was the first key, the value will be the first key.

About

Helper to show tips when you launch your react-native for the first time

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages