Skip to content

Commit bc18d36

Browse files
save file
1 parent 48a3ef5 commit bc18d36

File tree

1 file changed

+78
-36
lines changed

1 file changed

+78
-36
lines changed

html-components/list/web-editor/web-editor.html

Lines changed: 78 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,19 @@
112112
<link rel=stylesheet href='../css/component.css' crossorigin=anonymous>
113113

114114
<style>
115+
116+
#tabs
117+
{display:flex}
118+
119+
.tab
120+
{border-radius:5px 5px 0 0;cursor:pointer;flex:1;padding:5px 10px;border:1px solid transparent;text-align:center}
121+
122+
.active
123+
{background:lightyellow;border-color:lightblue}
124+
125+
.inactive
126+
{background:lightgray;border-color:gray}
127+
115128
</style>
116129

117130
</head>
@@ -128,44 +141,48 @@ <h2 slot=title>
128141
</time>
129142
</html-components-hdr>
130143

131-
<script>
132-
/*
133-
{
134-
let hdr = document.querySelector('html-components-hdr');
135-
hdr.querySelector('h2').textContent = component;
136-
hdr.querySelector('time').setAttribute('datetime',date);
137-
let d = new Date(date);
138-
let formatted = d.toLocaleDateString('en-GB',{day:'2-digit',month:'short',year:'numeric'});
139-
hdr.querySelector('time').textContent = formatted;
140-
}
141-
*/
142-
</script>
143-
144144

145-
<div id=readme class=markdown-body></div>
146-
147-
<hr>
145+
<div id=tabs>
146+
<div id=readme class='tab active'>
147+
readme
148+
</div>
149+
<div id=api class='tab inactive'>
150+
api
151+
</div>
152+
<div id=files class='tab inactive'>
153+
files
154+
</div>
155+
</div>
148156

149-
<section>
157+
<div id=view>
150158

151-
<h3>
152-
files
153-
<span style='font-size:16px;font-weight:normal'>
154-
( click to view )
155-
</span>
156-
</h3>
159+
<div id=readme class=markdown-body></div>
157160

158-
<dir-tree component></dir-tree>
161+
<div id=api class=markdown-body style='display:none'></div>
162+
163+
<section id=files style='display:none'>
164+
165+
<h3>
166+
files
167+
<span style='font-size:16px;font-weight:normal'>
168+
( click to view )
169+
</span>
170+
</h3>
171+
172+
<dir-tree component></dir-tree>
173+
174+
<div id=files-view-hdr>
175+
</div>
176+
177+
<div id=files-view>
178+
<snippet-html-console component></snippet-html-console>
179+
<web-editor component fullsize></web-editor>
180+
</div>
181+
182+
</section>
159183

160-
</section>
161-
162-
<div id=view-hdr>
163184
</div>
164185

165-
<div id=view style='display:none'>
166-
<snippet-html-console component></snippet-html-console>
167-
<web-editor component fullsize></web-editor>
168-
</div>
169186

170187

171188
<log-mod component></log-mod>
@@ -179,6 +196,7 @@ <h3>
179196
var cache = {};
180197

181198

199+
var btn = {};
182200
var callback = {};
183201
var show = {};
184202

@@ -190,8 +208,10 @@ <h3>
190208
async function initdom(){
191209
debug('initdom');
192210

211+
$('#tabs').onclick = btn.tabs;
212+
193213
var html = md.render(md_txt);
194-
$('#readme').innerHTML = html;
214+
$('#view #readme').innerHTML = html;
195215

196216
var keys = Object.keys(files.examples);
197217
var initial = keys[0];
@@ -201,12 +221,34 @@ <h3>
201221

202222
await show.examples(initial);
203223

204-
$('#view').style.display = '';
205-
206224

207225
}//initdom
208226

209227

228+
//:
229+
230+
231+
btn.tabs = function(e){debugger;
232+
233+
var tab = e.target;
234+
235+
var list = $.all('#tabs .tab');
236+
list.forEach(tab2=>{
237+
238+
if(tab.id!==tab2.id){
239+
tab2.classList.remove('active');
240+
tabs2.classList.add('inactive');
241+
$(`#view #${tab2.id}`).style.display = 'none';
242+
}
243+
244+
});
245+
246+
tab.classList.remove('inactive');
247+
tab.classList.add('active');
248+
tabs.style.display = '';
249+
250+
}//tabss
251+
210252
//:
211253

212254

@@ -226,7 +268,7 @@ <h3>
226268

227269
show.source = async function(file){
228270

229-
$('#view-hdr').textContent = 'source : '+file;
271+
$('#files-view-hdr').textContent = 'source : '+file;
230272
$('web-editor').style.display = '';
231273
$('snippet-html-console').style.display = 'none';
232274

@@ -248,7 +290,7 @@ <h3>
248290

249291
show.examples = async function(file){
250292

251-
$('#view-hdr').textContent = 'examples : '+file;
293+
$('#files-view-hdr').textContent = 'examples : '+file;
252294
$('web-editor').style.display = 'none';
253295
$('snippet-html-console').style.display = '';
254296

0 commit comments

Comments
 (0)