feat(code-snippet): dispatch "expand," "collapse" events

This commit is contained in:
Eric Liu 2022-05-12 19:27:45 -07:00
commit db1265e099

View file

@ -1,4 +1,9 @@
<script> <script>
/**
* @event {null} expand
* @event {null} collapse
*/
/** /**
* Set the type of code snippet * Set the type of code snippet
* @type {"single" | "inline" | "multi"} * @type {"single" | "inline" | "multi"}
@ -117,6 +122,7 @@
if (code === undefined) setShowMoreLess(); if (code === undefined) setShowMoreLess();
if (code) tick().then(setShowMoreLess); if (code) tick().then(setShowMoreLess);
} }
$: if (type === "multi") dispatch(expanded ? "expand" : "collapse");
onMount(() => { onMount(() => {
return () => clearTimeout(timeout); return () => clearTimeout(timeout);