Skip to content

Commit

Permalink
feat(block): improve block's content layout to allow scrolling (#7367)
Browse files Browse the repository at this point in the history
**Related Issue:** #5686 

## Summary

This applies @nwhittaker's
[suggestion](#5686 (comment))
(belated thanks! 🎉) to make scrolling setup easier within blocks.
  • Loading branch information
jcfranco authored Aug 3, 2023
1 parent 763b7ce commit ecbf17b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ calcite-handle {
}

.content {
@apply animate-in flex-1 relative;
@apply animate-in flex-1 relative min-h-0;
padding-block: var(--calcite-block-padding, theme("spacing.2"));
padding-inline: var(--calcite-block-padding, theme("spacing[2.5]"));
}
Expand Down
35 changes: 35 additions & 0 deletions packages/calcite-components/src/components/block/block.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,38 @@ export const loadingWithStatusIcon_TestOnly = (): string =>
<calcite-block heading="Invalid status" description="summary" status="invalid"> </calcite-block>
`;

export const scrollingContainerSetup_TestOnly = (): string => html`<style>
calcite-block {
height: 250px;
overflow: hidden;
}
.scroll-container {
height: 100%;
overflow-y: scroll;
}
p {
background: linear-gradient(to bottom, red, transparent);
height: 500px;
margin: 0;
}
</style>
<calcite-block heading="Should scroll to the gradient at the bottom" open>
<div class="scroll-container">
<p></p>
</div>
</calcite-block>
<script>
(async () => {
const block = document.querySelector("calcite-block");
await customElements.whenDefined("calcite-block");
await block.componentOnReady();
const scrollContainer = document.querySelector(".scroll-container");
scrollContainer.scrollTo(0, 500);
})();
</script>`;

scrollingContainerSetup_TestOnly.parameters = { chromatic: { delay: 500 } };

0 comments on commit ecbf17b

Please sign in to comment.