Skip to content

Commit bd0d445

Browse files
jenstroegerpeyerluk
authored andcommitted
docs: Add example to illustrate styling the editable.
1 parent a3ba665 commit bd0d445

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

examples/index.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,29 @@ article {
356356
color: #49a345;
357357
}
358358

359+
/* ==========================================================================
360+
Styling
361+
========================================================================== */
362+
363+
.example-style-default {
364+
}
365+
.example-style-default:focus {
366+
}
367+
368+
.example-style-dark {
369+
padding: 0.5em;
370+
color: white;
371+
background-color: darkgrey;
372+
border: 1px solid darkgrey;
373+
border-radius: 4px;
374+
caret-color: yellow;
375+
}
376+
.example-style-dark:focus {
377+
outline: none;
378+
background-color: dimgrey;
379+
box-shadow: 0px 0px 8px black;
380+
}
381+
359382
/* ==========================================================================
360383
iFrame
361384
========================================================================== */

examples/index.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,33 @@ <h3>HTML</h3>
6666
</section>
6767

6868

69+
<!-- Styling -->
70+
71+
<section class="example-section space-after">
72+
<div class="section-content">
73+
<h2 class="example-title">Styling</h2>
74+
75+
<div class="styling-example example-sheet">
76+
<p class="example-style-default">
77+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.
78+
</p>
79+
</div>
80+
81+
<div class="code-example">
82+
<p>Style the editable element using CSS to match your page’s design.</p>
83+
<p>
84+
<label>For example:</label>
85+
<select name="editable-styles">
86+
<option value="default">Default</option>
87+
<option value="dark">Dark mode</option>
88+
</select>
89+
</p>
90+
</div>
91+
92+
</div>
93+
</section>
94+
95+
6996
<!-- Highlight -->
7097

7198
<section class="example-section space-after">

examples/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,24 @@ $(() => {
1919
editable.add('.formatting-example p')
2020
setupTooltip()
2121

22+
editable.add('.styling-example p')
23+
2224
const secondExample = document.querySelector('.formatting-example p')
2325
updateCode(secondExample)
2426

2527
editable.on('change', (elem) => {
2628
if (elem === secondExample) updateCode(elem)
2729
})
2830

31+
// Styling
32+
// -------
33+
34+
$('select[name="editable-styles"]').on('change', function () {
35+
$('.styling-example p')
36+
.removeClass('example-style-default example-style-dark')
37+
.addClass('example-style-' + $(this).val())
38+
})
39+
2940
// IFrame
3041
// ------
3142

0 commit comments

Comments
 (0)