Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Scrollbar component #315

Merged
merged 16 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/react-styled-ui/src/Scrollbar/Scrollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Scrollbar = forwardRef((
{
onScroll,
onUpdate,
autoHide = false,
alwaysShow = false,
autoHideDelay = 1000,
thumbSize,
thumbMinSize = 30,
Expand All @@ -35,6 +35,7 @@ const Scrollbar = forwardRef((
},
ref,
) => {
const autoHide = !alwaysShow;
let hideTracksTimeout;
let viewScrollLeft = 0;
let viewScrollTop = 0;
Expand Down
9 changes: 5 additions & 4 deletions packages/styled-ui-docs/pages/scrollbar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
<Menu width="160px">
<MenuButton width="100%">Select an option</MenuButton>
<MenuList width="100%" height={200}>
<Scrollbar autoHide>
<Scrollbar>
<MenuItem>List item 1</MenuItem>
<MenuItem>List item 2</MenuItem>
<MenuItem>List item 3</MenuItem>
Expand Down Expand Up @@ -69,6 +69,7 @@ function CustomScrollbar({

return (
<Scrollbar
alwaysShow
renderView={renderScrollView}
renderTrackHorizontal={renderScrollTrack}
renderTrackVertical={renderScrollTrack}
Expand Down Expand Up @@ -259,10 +260,10 @@ render(

| Name | Type | Default | Description |
| :--- | :--- | :------ | :---------- |
| autoHide | boolean | false | Enable auto-hide mode. |
| alwaysShow | boolean | false | Enable always-show mode. |
cheton marked this conversation as resolved.
Show resolved Hide resolved
| autoHideDelay | number | 1000 | Hide delay in ms. |
| autoHeight | boolean | false | Enable auto-height mode. |
cheton marked this conversation as resolved.
Show resolved Hide resolved
| autoHeightMax | number | 200 | Set a maximum height for auto-height mode. |
| autoHeightMax | number | 200 | Set a maximum height for auto-height mode. default is `200px`. |
cheton marked this conversation as resolved.
Show resolved Hide resolved
| autoHeightMin | number | 0 | Set a minimum height for auto-height mode. |
| onScroll | function | | Event handler. |
| onUpdate | function({ values, hasHorizontalScrollbar, hasVerticalScrollbar }) | | Called whenever the component is updated. |
Expand All @@ -271,5 +272,5 @@ render(
| renderTrackVertical | function | | Vertical track element. |
| renderThumbHorizontal | function | | Horizontal thumb element. |
| renderThumbVertical | function | | Vertical thumb element. |
cheton marked this conversation as resolved.
Show resolved Hide resolved
| thumbMinSize | number | 30 | Minimal thumb size. |
| thumbMinSize | number | 30 | Minimal thumb size. default is `30px`. |
| thumbSize | number | | Set a fixed size for thumbs. |