<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://unpkg.com/xnew@5.0.x/dist/xnew.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
</head>
<body class="relative m-0 p-0 w-full h-screen overflow-hidden">
<div id="main" class="relative w-full h-full"></div>
<script>
xnew('#main', (self) => {
xnew.nest('<div class="p-2">')
xnew(MyAccordion)
});
function MyAccordion(frame) {
xnew.extend(xnew.AccordionFrame);
xnew.nest('<div class="w-64 border rounded-lg">');
xnew((button) => {
xnew.extend(xnew.AccordionButton);
xnew(xnew.AccordionBullet, { type: 'arrow' });
xnew('<div class="my-2 select-none cursor-pointer">', 'accordion (click me!)');
});
xnew((content) => {
xnew.extend(xnew.AccordionContent, { open: true, duration: 300, easing: 'ease' });
xnew.nest('<div class="p-2 border-t">');
xnew('<span>', 'Content');
xnew('<ul>', () => {
xnew('<li class="ml-2">', '1st item');
xnew('<li class="ml-2">', '2nd item');
xnew('<li class="ml-2">', '3rd item');
});
});
frame.on('-open', () => {
console.log('-open');
})
frame.on('-close', () => {
console.log('-close');
})
}
</script>
</body>
</html>