Skip to content

Commit

Permalink
All Example Pages: Add copy instructions and CodePen button to HTML s…
Browse files Browse the repository at this point in the history
…ource section (pull #3041)

Resolve issue #3027 with the following changes:
1. Direct readers to copy HTML source from codepen instead of from the example page.
2. Add an additional codepen button adjacent to the directions.

Note that if users copy the source directly from the example page, the code may not work as designed because of spacing differences between the HTML source file and the formatting of the source code for display within the web page. Thus, this change instructs users to open the source in codepen where the original spacing is preserved. It makes doing so easy by providing a codepen button adjacent to the instructions.

---------

Co-authored-by: Matt King <a11yThinker@gmail.com>
  • Loading branch information
ariellalgilmore and mcking65 committed Jul 27, 2024
1 parent cb74ba2 commit b28a984
Show file tree
Hide file tree
Showing 59 changed files with 201 additions and 122 deletions.
3 changes: 2 additions & 1 deletion content-templates/Example-Template.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,12 @@ <h2>Javascript and CSS Source Code</h2>

<section>
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/accordion/examples/accordion.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/alert/examples/alert.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/alertdialog/examples/alertdialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,14 @@ <h2 id="src_label">Javascript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex_alertdialog', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex_alertdialog', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/breadcrumb/examples/breadcrumb.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/button/examples/button.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'example', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'example', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/button/examples/button_idl.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'example', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'example', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/carousel/examples/carousel-1-prev-next.html
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/carousel/examples/carousel-2-tablist.html
Original file line number Diff line number Diff line change
Expand Up @@ -710,13 +710,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/checkbox/examples/checkbox-mixed.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/checkbox/examples/checkbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,15 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2>HTML Source Code</h2>
<h3 id="sc1_label">Simple Two-State Checkbox Example</h3>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div id="sc1_start_sep" role="separator" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of HTML for"></div>
<pre><code id="sc1"></code></pre>
<div id="sc1_end_sep" role="separator" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of HTML for"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,13 +531,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,13 +525,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/combobox/examples/combobox-datepicker.html
Original file line number Diff line number Diff line change
Expand Up @@ -710,13 +710,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/combobox/examples/combobox-select-only.html
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/combobox/examples/grid-combo.html
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/dialog-modal/examples/datepicker-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'example', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'example', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/dialog-modal/examples/dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/disclosure/examples/disclosure-faq.html
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,14 @@ <h2>JavaScript and CSS Source Code</h2>
</ul>
</section>

<section>
<section class="example-code">
<h2 id="sc1_label">HTML Source Code</h2>
<p id="sc1_description">To copy the following HTML code, please open it in CodePen.</p>
<div role="separator" id="sc1_start_sep" aria-labelledby="sc1_start_sep sc1_label" aria-label="Start of"></div>
<pre><code id="sc1"></code></pre>
<div role="separator" id="sc1_end_sep" aria-labelledby="sc1_end_sep sc1_label" aria-label="End of"></div>
<script>
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files');
sourceCode.add('sc1', 'ex1', 'ex_label', 'css_js_files', 'sc1_description');
sourceCode.make();
</script>
</section>
Expand Down
Loading

0 comments on commit b28a984

Please sign in to comment.