@codedoc/core
Version:
Create beautiful modern documentation websites.
35 lines • 1.36 kB
JavaScript
import { TabsStyle } from './style';
import { TabSelector$ } from './selector';
export function Tab(options, renderer, content) {
const $tab = renderer.create("div", { class: "tab", "data-tab-title": options.title || '', "data-tab-id": options.id || options.title || '' }, content);
if (options.selected)
$tab.classList.add('selected');
if (options.icon)
$tab.setAttribute('data-tab-icon', options.icon);
return $tab;
}
export function Tabs(_, renderer, content) {
const classes = this.theme.classes(TabsStyle);
const holder = renderer.create("fragment", null, content);
let first$;
let selected$;
holder.querySelectorAll('.tab').forEach(_tab$ => {
const tab$ = _tab$;
if (!first$)
first$ = tab$;
if (tab$.classList.contains('selected')) {
if (selected$)
tab$.classList.remove('selected');
else
selected$ = tab$;
}
});
first$ === null || first$ === void 0 ? void 0 : first$.classList.add('first');
if (!selected$)
first$ === null || first$ === void 0 ? void 0 : first$.classList.add('selected');
return renderer.create("div", { class: classes.tabs },
renderer.create(TabSelector$, null),
holder);
}
export { TabsStyle } from './style';
//# sourceMappingURL=index.js.map