MCPcopy Create free account
hub / github.com/callstack/react-native-paper / appendSnackLink

Function appendSnackLink

docs/public/2.0/scripts/snack.js:5–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3'use strict';
4
5function appendSnackLink() {
6 var usage = document.getElementById('usage');
7
8 if (usage) {
9 var pre = usage.nextElementSibling;
10
11 if (
12 pre &&
13 pre.firstChild.tagName === 'CODE' &&
14 pre.firstChild.className === 'language-js'
15 ) {
16 var link;
17 var insert = true;
18
19 if (pre.nextElementSibling && pre.nextElementSibling.dataset.snack) {
20 link = pre.nextElementSibling;
21 insert = false;
22 } else {
23 link = document.createElement('a');
24 link.dataset.snack = true;
25 link.target = '_blank';
26 link.innerHTML =
27 'Try this example on Snack <svg width="14px" height="14px" viewBox="0 0 16 16" style="vertical-align: -1px"><g stroke="none" stroke-width="1" fill="none"><polyline stroke="currentColor" points="8.5 0.5 15.5 0.5 15.5 7.5"></polyline><path d="M8,8 L15.0710678,0.928932188" stroke="currentColor"></path><polyline stroke="currentColor" points="9.06944444 3.5 1.5 3.5 1.5 14.5 12.5 14.5 12.5 6.93055556"></polyline></g></svg>';
28 }
29
30 var heading = document.querySelector('h1');
31 var href =
32 'https://snack.expo.io?name=' +
33 encodeURIComponent(
34 heading ? heading.textContent : document.title + ' Example'
35 ) +
36 '&description=' +
37 encodeURIComponent(window.location.href) +
38 '&code=' +
39 encodeURIComponent(pre.textContent) +
40 '&dependencies=react-native-paper';
41
42 if (link.href === href) {
43 return;
44 }
45
46 link.href = href;
47
48 if (insert) {
49 pre.insertAdjacentElement('afterend', link);
50 }
51 }
52 }
53}
54
55appendSnackLink();
56

Callers 1

snack.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…