Skip to content

Commit 6874971

Browse files
Add style example
1 parent 034769a commit 6874971

File tree

1 file changed

+57
-7
lines changed

1 file changed

+57
-7
lines changed

demo/index.html

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@
3333
text-align: center;
3434
border-top: 1px solid #000;
3535
}
36+
37+
/* Loading Style */
38+
code-block {
39+
font-family: Consolas, Monaco, monospace;
40+
display: block;
41+
overflow-x: auto;
42+
font-size: 80%;
43+
background: #fff;
44+
}
45+
code-block:not(:has(textarea)):not(:has(pre)) {
46+
padding: 1em;
47+
}
48+
code-block textarea {
49+
box-sizing: border-box;
50+
border: 0;
51+
width: 100%;
52+
padding: 1em;
53+
font-size: inherit;
54+
font-family: inherit;
55+
}
3656
</style>
3757
<!-- <script src="../lib/html-code-block-element.common.min.js" defer></script> -->
3858
<!-- <script src="https://cdn.jsdelivr.net/npm/@heppokofrontend/html-code-block-element/lib/html-code-block-element.core.min.js" defer></script> -->
@@ -45,6 +65,31 @@ <h1>HTMLCodeBlockElement</h1>
4565

4666
<p>Code block custom element with syntax highlighting and copy button.</p>
4767

68+
<p>It is recommended that the following CSS be loaded for before JavaScript works</p>
69+
70+
<code-block language="css">
71+
<textarea>
72+
code-block {
73+
font-family: Consolas, Monaco, monospace;
74+
display: block;
75+
overflow-x: auto;
76+
font-size: 80%;
77+
background: #fff;
78+
}
79+
code-block:not(:has(textarea)):not(:has(pre)) {
80+
padding: 1em;
81+
}
82+
code-block textarea {
83+
box-sizing: border-box;
84+
border: 0;
85+
width: 100%;
86+
padding: 1em;
87+
font-size: inherit;
88+
font-family: inherit;
89+
}
90+
</textarea>
91+
</code-block>
92+
4893
<h2>With escaped text</h2>
4994

5095
<h3>Source</h3>
@@ -81,9 +126,9 @@ <h3>Result</h3>
81126

82127
<h2>Playground</h2>
83128

84-
<code-block language="js" id="cb">// this is placeholder</code-block>
129+
<code-block language="js" id="cb">// this is placeholder (code-block#cb)</code-block>
85130

86-
<p>Let's run these JS on this page.</p>
131+
<p>Let's paste these in conosole to run JS on this page.</p>
87132

88133
<code-block language="js" label="Example: HTML" controls>
89134
<textarea>
@@ -92,26 +137,31 @@ <h2>Playground</h2>
92137
<h2>Hello world</h2>
93138

94139
<p class="example">This is sample markup.</p>
95-
</div>`;</textarea>
140+
</div>`;
141+
</textarea>
96142
</code-block>
97143

98144
<code-block language="js" label="Example: CSS" controls>
99-
<textarea>cb.language = 'css';
145+
<textarea>
146+
cb.language = 'css';
100147
cb.value = `body {
101148
/* This is sample css */
102149
font-size: 100px;
103-
}`;</textarea>
150+
}`;
151+
</textarea>
104152
</code-block>
105153

106154
<code-block language="js" label="Example: JSON" controls>
107-
<textarea>cb.language = 'json';
155+
<textarea>
156+
cb.language = 'json';
108157
cb.value = `{
109158
"items": [
110159
100,
111160
null,
112161
"This is sample json"
113162
]
114-
}`;</textarea>
163+
}`;
164+
</textarea>
115165
</code-block>
116166
</main>
117167
<footer>

0 commit comments

Comments
 (0)