-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathpage-code-snippets.html
245 lines (170 loc) · 5.61 KB
/
page-code-snippets.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
---
layout: default
title: Code Snippets
permalink: /code-snippets/
id: code-snippets
is_searchable: true
---
<div class="sui-floating-notices">
<div role="alert" id="library-warning" class="sui-notice" aria-live="assertive"></div>
</div>
<section class="sui-row-with-sidenav">
<!-- Navigation -->
<div class="sui-sidenav" role="navigation">
<ul class="sui-vertical-tabs sui-sidenav-hide-md">
<li class="sui-vertical-tab current">
<a href="#" role="button" data-tab="default">Default</a>
</li>
<li class="sui-vertical-tab">
<a href="#" role="button" data-tab="no-copy">No-Copy Button</a>
</li>
<li class="sui-vertical-tab">
<a href="#" role="button" data-tab="documentation">Documentation</a>
</li>
</ul>
<div class="sui-sidenav-settings">
<div class="sui-form-field sui-sidenav-hide-lg">
<select class="sui-select">
<option value="default">Default</option>
<option value="no-copy">No-Copy Button</option>
<option value="documentation">Documentation</option>
</select>
</div>
</div>
</div>
<!-- TAB: Default -->
<div class="sui-box" data-tab="default">
<div class="sui-box-header">
<h2 class="sui-box-title">Default</h2>
</div>
<div class="sui-box-body">
<p>This element is meant to be used to display code. By default, it will place a copy button on top right of the container, that way users can easily copy snippet content to clipboard.</p>
<pre class="sui-code-snippet">
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</pre>
<div class="demo-code-block" style="margin-top: 15px;">
<pre class="sui-code-snippet html">
<pre class="sui-code-snippet">
... content goes here ...
</pre>
</pre>
</div>
</div>
</div>
<!-- TAB: No-Copy Button -->
<div class="sui-box" data-tab="no-copy" style="display: none;">
<div class="sui-box-header">
<h2 class="sui-box-title">Default</h2>
</div>
<div class="sui-box-body">
<p>There are cases when you gonna need to get rid off the copy button. For those cases, you can add <code>sui-no-copy</code> class.</p>
<pre class="sui-code-snippet sui-no-copy">
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</pre>
<div class="demo-code-block" style="margin-top: 15px;">
<pre class="sui-code-snippet html">
<pre class="sui-code-snippet sui-no-copy">
... content goes here ...
</pre>
</pre>
</div>
</div>
</div>
<!-- TAB: Documentation -->
<div class="sui-box" data-tab="documentation" style="display: none;">
<div class="sui-box-body">
<!-- ROW: Specifications -->
<div
id="showcase-specs"
utilities="true"
utilities-page="{{ site.baseurl }}/utilities/"
monochrome="true"
rtl-lang="false"
></div>
<!-- ROW: Clipboard Library -->
<div class="sui-box-settings-row">
<div class="sui-box-settings-col-1">
<h3 class="sui-settings-label">Clipboard Library</h3>
</div>
<div class="sui-box-settings-col-2">
<div class="sui-notice sui-notice-info">
<div class="sui-notice-content">
<div class="sui-notice-message">
<p>Code Snippets uses <a href="https://clipboardjs.com/" target="_blank" rel="noreferrer">clipboard.js</a> library that you will need to grab from its page and load it on your plugin but starting from <strong>WordPress v5.2</strong> this library is included in the WordPress installation.</p>
</div>
</div>
</div>
<div class="demo-code-block">
<pre class="sui-code-snippet php">
global $wp_version;
/**
* Queue clipboard.js from your plugin if WP's version is below 5.2.0
* since it's only included from 5.2.0 on.
*/
// Use 'clipboard' as the handle so it matches WordPress' handle for the script.
if ( version_compare( $wp_version, '5.2', '<' ) ) {
wp_enqueue_script( 'clipboard', 'yourpath/clipboard.js', array(), $version, true );
}
// Here, include 'clipboard' as a dependency along with 'jquery'.
wp_enqueue_script( 'shared-ui', 'yourpath/shared-ui.min.js', array( 'jquery', 'clipboard' ), $plugin_sui_version, true );
</pre>
</div>
</div>
</div>
<!-- ROW: JS Instantiation -->
<div class="sui-box-settings-row">
<div class="sui-box-settings-col-1">
<span class="sui-settings-label">JS Instantiation</span>
</div>
<div class="sui-box-settings-col-2">
<div class="demo-code-block">
<pre class="sui-code-snippet sui-no-copy js">
// Initiate all sui-code-snippet
SUI.suiCodeSnippet();
// Initiate single sui-code-snippet
$( '.my-selector' ).SUICodeSnippet();
</pre>
</div>
</div>
</div>
<!-- ROW: JS API -->
<div class="sui-box-settings-row">
<div class="sui-box-settings-col-1">
<span class="sui-settings-label">JS API</span>
</div>
<div class="sui-box-settings-col-2">
<div class="demo-code-block">
<pre class="sui-code-snippet sui-no-copy js">
// Initiate with custom copy text
$( '.my-selector' ).SUICodeSnippet({
'copyText': 'Copy .htaccess', // button text
'copiedText': '.htaccess copied', // tooltip text when copied
});
// Get Clipboard.JS inistance
const clipboard = $( '.my-selector' ).data( 'SUICodeSnippet' ).getClipboardJs();
clipboard.on( 'success', function( e ) {
alert( 'Copied!' );
});
// Destroy instance
$( '.my-selector' ).data( 'SUICodeSnippet' ).destroy();
</pre>
</div>
</div>
</div>
</div>
</div>
</section>