Selaa lähdekoodia

Add new support button

customisations
alemart 8 kuukautta sitten
vanhempi
commit
c6e463c632
3 muutettua tiedostoa jossa 77 lisäystä ja 57 poistoa
  1. 3
    57
      docs_overrides/js/extra.js
  2. 26
    0
      docs_overrides/main.html
  3. 48
    0
      docs_overrides/style/extra.css

+ 3
- 57
docs_overrides/js/extra.js Näytä tiedosto

@@ -1,65 +1,11 @@
1
-document.addEventListener('DOMContentLoaded', () => {
1
+document.addEventListener('DOMContentLoaded', function() {
2 2
 
3 3
     //
4 4
     // Open links in a new window
5 5
     //
6 6
 
7
-    document.querySelectorAll('a._blank').forEach(link => {
8
-        link.target = '_blank';
7
+    document.querySelectorAll('a._blank').forEach(function(a) {
8
+        a.target = '_blank';
9 9
     });
10 10
 
11
-    //
12
-    // Support button
13
-    //
14
-
15
-    if(document.getElementById('splash'))
16
-        return;
17
-
18
-    const support = document.createElement('a');
19
-    const heart = document.createElement('img');
20
-    const text = document.createTextNode('Support');
21
-
22
-    heart.src = 'https://github.githubassets.com/images/icons/emoji/unicode/2764.png';
23
-    heart.style.width = '24px';
24
-    //heart.style.paddingRight = '8px';
25
-    heart.classList.add('gemoji', 'heart');
26
-
27
-    support.href = 'https://alemart.github.io/encantar-js/support-my-work';
28
-    support.target = '_blank';
29
-    support.role = 'button';
30
-    support.style.display = 'flex';
31
-    support.style.alignItems = 'center';
32
-    support.style.position = 'fixed';
33
-    support.style.right = '16px';
34
-    support.style.bottom = '16px';
35
-    support.style.padding = '12px';// '0 20px';
36
-    //support.style.height = '48px';
37
-    support.style.color = 'var(--md-primary-fg-color)';
38
-    support.style.backgroundColor = 'var(--md-primary-bg-color)';
39
-    support.style.fontWeight = 'bold';
40
-    support.style.fontSize = '16px';
41
-    support.style.fontFamily = 'var(--md-text-font) sans-serif';
42
-    support.style.cursor = 'pointer';
43
-    support.style.borderWidth = '2px';
44
-    support.style.borderStyle = 'solid';
45
-    support.style.borderColor = 'var(--md-primary-fg-color)';
46
-    support.style.borderRadius = '100px';
47
-    support.style.transition = 'color 125ms,background-color 125ms,border-color 125ms';
48
-
49
-    support.addEventListener('pointerenter', () => {
50
-        support.style.backgroundColor = 'var(--md-accent-fg-color)';
51
-        support.style.borderColor = 'var(--md-accent-fg-color)';
52
-        support.style.color = 'var(--md-accent-bg-color)';
53
-    });
54
-
55
-    support.addEventListener('pointerleave', () => {
56
-        support.style.backgroundColor = 'var(--md-primary-bg-color)';
57
-        support.style.borderColor = 'var(--md-primary-fg-color)';
58
-        support.style.color = 'var(--md-primary-fg-color)';
59
-    });
60
-
61
-    support.appendChild(heart);
62
-    //support.appendChild(text);
63
-    document.body.appendChild(support);
64
-
65 11
 });

+ 26
- 0
docs_overrides/main.html Näytä tiedosto

@@ -20,4 +20,30 @@
20 20
 
21 21
 {% block content %}
22 22
 {{ super() }}
23
+{% endblock %}
24
+
25
+{% block footer %}
26
+<button id="support-button" onclick="document.getElementById('support-widget').classList.toggle('invisible')">
27
+    &#x1F468;&#x200D;&#x1F4BB; Need help?
28
+</button>
29
+<section id="support-widget" class="md-typeset invisible">
30
+    <h4>Technical support</h4>
31
+    <p>You can request technical help at <a class="support-link"></a></p>
32
+    <ul>
33
+        <li>Get expert guidance on how to create your AR experience with encantar.js</li>
34
+        <li>Ask technical questions</li>
35
+    </ul>
36
+</section>
37
+<script>
38
+document.addEventListener('DOMContentLoaded', function() {
39
+    var salad = 'nbjmup;tvqqpsuAfodboubs/efw';
40
+    var link = salad.split('').map(c => String.fromCharCode(c.charCodeAt(0)-1)).join('');
41
+    document.querySelectorAll('a.support-link').forEach(function(a) {
42
+        a.href = link;
43
+        if(a.innerText.length == 0)
44
+            a.innerText = link.substring(7);
45
+    });
46
+});
47
+</script>
48
+{{ super() }}
23 49
 {% endblock %}

+ 48
- 0
docs_overrides/style/extra.css Näytä tiedosto

@@ -28,3 +28,51 @@
28 28
     height: auto;
29 29
     max-width: 100%;
30 30
 }
31
+
32
+#support-widget {
33
+    position: fixed;
34
+    bottom: 80px;
35
+    right: 16px;
36
+    padding: 0 12px;
37
+    width: 256px;
38
+    font-size: 0.8rem;
39
+    color: var(--md-default-fg-color);
40
+    background-color: var(--md-primary-bg-color);
41
+    border-color: var(--md-primary-fg-color);
42
+    border-width: 2px;
43
+    border-style: solid;
44
+    border-radius: 16px;
45
+    transform: scaleY(1);
46
+    transform-origin: bottom;
47
+    transition: transform 0.25s ease;
48
+    z-index: 1000;
49
+}
50
+
51
+#support-widget.invisible {
52
+    transform: scaleY(0);
53
+}
54
+
55
+#support-button {
56
+    position: fixed;
57
+    right: 16px;
58
+    bottom: 16px;
59
+    padding: 12px;
60
+    color: var(--md-primary-fg-color);
61
+    background-color: var(--md-primary-bg-color);
62
+    font-weight: bold;
63
+    font-size: 0.8rem;
64
+    font-family: sans-serif;
65
+    cursor: pointer;
66
+    border-width: 2px;
67
+    border-style: solid;
68
+    border-color: var(--md-primary-fg-color);
69
+    border-radius: 32px;
70
+    transition: color 125ms, background-color 125ms, border-color 125ms;
71
+    z-index: 1000;
72
+}
73
+
74
+#support-button:hover {
75
+    color: var(--md-accent-bg-color);
76
+    border-color: var(--md-accent-fg-color);
77
+    background-color: var(--md-accent-fg-color);
78
+}

Loading…
Peruuta
Tallenna