mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
refactor(code-snippet): use afterUpdate
This commit is contained in:
parent
6a28583a85
commit
152cbcd1ab
1 changed files with 5 additions and 3 deletions
|
@ -11,6 +11,7 @@
|
||||||
export let light = false;
|
export let light = false;
|
||||||
export let style = undefined;
|
export let style = undefined;
|
||||||
|
|
||||||
|
import { afterUpdate } from 'svelte';
|
||||||
import ChevronDown16 from 'carbon-icons-svelte/lib/ChevronDown16';
|
import ChevronDown16 from 'carbon-icons-svelte/lib/ChevronDown16';
|
||||||
import { cx } from '../../lib';
|
import { cx } from '../../lib';
|
||||||
import Button from '../Button';
|
import Button from '../Button';
|
||||||
|
@ -22,10 +23,11 @@
|
||||||
let expanded = false;
|
let expanded = false;
|
||||||
let showMoreLess = false;
|
let showMoreLess = false;
|
||||||
|
|
||||||
$: expandText = expanded ? showLessText : showMoreText;
|
afterUpdate(() => {
|
||||||
$: if (codeRef) {
|
|
||||||
showMoreLess = type === 'multi' && codeRef.getBoundingClientRect().height > 255;
|
showMoreLess = type === 'multi' && codeRef.getBoundingClientRect().height > 255;
|
||||||
}
|
});
|
||||||
|
|
||||||
|
$: expandText = expanded ? showLessText : showMoreText;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if type === 'inline'}
|
{#if type === 'inline'}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue