fix(expandable-tile): use css to ensure max-height value

This commit is contained in:
Eric Liu 2019-12-31 15:19:47 -08:00
commit 23a0de3f2a
2 changed files with 8 additions and 9 deletions

View file

@ -3,17 +3,17 @@
export { className as class }; export { className as class };
export let expanded = false; export let expanded = false;
export let id = Math.random(); export let id = Math.random();
export let light = false;
export let style = undefined;
export let tabindex = '0';
export let tileCollapsedIconText = 'Interact to expand Tile'; export let tileCollapsedIconText = 'Interact to expand Tile';
export let tileExpandedIconText = 'Interact to collapse Tile'; export let tileExpandedIconText = 'Interact to collapse Tile';
export let tileMaxHeight = 0; export let tileMaxHeight = 0;
export let tilePadding = 0; export let tilePadding = 0;
export let tabindex = '0';
export let light = false;
export let style = undefined;
import { onMount, afterUpdate } from 'svelte'; import { onMount, 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, css } from '../../lib';
let tile = undefined; let tile = undefined;
let tileContent = undefined; let tileContent = undefined;
@ -37,8 +37,8 @@
<div <div
bind:this={tile} bind:this={tile}
style={expanded ? undefined : `max-height: ${tileMaxHeight + tilePadding}px`}
class={cx('--tile', '--tile--expandable', expanded && '--tile--is-expanded', light && '--tile--light', className)} class={cx('--tile', '--tile--expandable', expanded && '--tile--is-expanded', light && '--tile--light', className)}
style={expanded ? undefined : css([style, `max-height: ${tileMaxHeight + tilePadding}px`])}
on:click on:click
on:click={() => { on:click={() => {
expanded = !expanded; expanded = !expanded;
@ -54,8 +54,7 @@
on:mouseenter on:mouseenter
on:mouseleave on:mouseleave
{tabindex} {tabindex}
{id} {id}>
{style}>
<div bind:this={tileContent}> <div bind:this={tileContent}>
<div bind:this={aboveTheFold} class={cx('--tile-content')}> <div bind:this={aboveTheFold} class={cx('--tile-content')}>
<slot name="above" /> <slot name="above" />

View file

@ -1,11 +1,11 @@
<script> <script>
let className = undefined; let className = undefined;
export { className as class }; export { className as class };
export let direction = 'bottom';
export let align = 'center'; export let align = 'center';
export let direction = 'bottom';
export let id = Math.random(); export let id = Math.random();
export let tooltipText = '';
export let style = undefined; export let style = undefined;
export let tooltipText = '';
import { cx } from '../../lib'; import { cx } from '../../lib';
</script> </script>