Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit bd5c78b

Browse files
authored
feat(prototypes): add prototype for custom scrollbar for menu, dialog, popup and list (#1962)
* custom scrollbar for menu, dialog, popup and list
1 parent 6db9dfe commit bd5c78b

4 files changed

Lines changed: 108 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
2727

2828
### Documentation
2929
- Fix 'RTL' and 'Theme it' in examples @miroslavstastny ([#2020](https://github.com/stardust-ui/react/pull/2020))
30+
- Prototype for custom scrollbar for menu, dialog, popup and list @jurokapsiar ([#1962](https://github.com/stardust-ui/react/pull/1962))
3031

3132
### Performance
3233
- Remove redundant usages of `Box` component in `Attachment`, `Popup` and `Tooltip` @layershifter ([#2023](https://github.com/stardust-ui/react/pull/2023))

docs/src/components/Sidebar/Sidebar.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ class Sidebar extends React.Component<any, any> {
281281
title: { content: 'Chat Messages', as: NavLink, to: '/prototype-chat-messages' },
282282
public: true,
283283
},
284+
{
285+
key: 'customscrollbar',
286+
title: { content: 'Custom Scrollbar', as: NavLink, to: '/prototype-custom-scrollbar' },
287+
public: true,
288+
},
284289
{
285290
key: 'customtoolbar',
286291
title: { content: 'Custom Styled Toolbar', as: NavLink, to: '/prototype-custom-toolbar' },
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import * as React from 'react'
2+
import * as _ from 'lodash'
3+
import Scrollbars from 'react-custom-scrollbars'
4+
import { Text, Menu, List, Button, Popup, Dialog } from '@stardust-ui/react'
5+
import { PrototypeSection, ComponentPrototype } from '../Prototypes'
6+
7+
const ScrollbarMenuPrototype = () => {
8+
const items = [
9+
{
10+
key: 'with-scrollbar',
11+
content: 'Submenu with scrollbar',
12+
menu: {
13+
as: Scrollbars,
14+
items: _.times(50, (i: number) => `Menu Item No. ${i}`),
15+
style: { height: '20rem' },
16+
},
17+
},
18+
{
19+
key: 'without-scrollbar',
20+
content: 'Submenu without scrollbar',
21+
menu: _.times(5, (i: number) => `Menu Item No. ${i}`),
22+
},
23+
]
24+
25+
return <Menu items={items} />
26+
}
27+
28+
const ScrollbarPopupPrototype = () => {
29+
const lines = _.times(50, i => <p key={i}>Long long text line {i}</p>)
30+
31+
return (
32+
<Popup
33+
trigger={<Button content="Open popup" />}
34+
content={{
35+
// NOTE: because scrollbars uses an abs positioned container to fake scroll
36+
// the consumer must specify a width/height value to show the scrollable area
37+
styles: { width: '20rem' },
38+
content: <Scrollbars style={{ height: '20rem' }}>{lines}</Scrollbars>,
39+
}}
40+
/>
41+
)
42+
}
43+
44+
const ScrollbarDialogPrototype = () => {
45+
const lines = _.times(50, i => <p key={i}>Long long text line {i}</p>)
46+
47+
return (
48+
<Dialog
49+
trigger={<Button content="Open dialog" />}
50+
header="Dialog with scrollbar"
51+
cancelButton="Close"
52+
content={{
53+
styles: { width: '100%' },
54+
content: <Scrollbars style={{ height: '20rem' }}>{lines}</Scrollbars>,
55+
}}
56+
/>
57+
)
58+
}
59+
60+
const ScrollbarListPrototype = () => {
61+
const items = _.times(50, (i: number) => ({
62+
header: `Header ${i}`,
63+
content: `Content ${i}`,
64+
key: `item-${i}`,
65+
}))
66+
67+
return (
68+
<Scrollbars style={{ height: '20rem' }}>
69+
<List selectable items={items} />
70+
</Scrollbars>
71+
)
72+
}
73+
74+
const CustomScrollbarPrototypes: React.FC = () => {
75+
return (
76+
<PrototypeSection title="Custom Scrollbar">
77+
<Text>
78+
Note: Stardust does not provide custom scrollbars. It is possible to integrate Stardust
79+
components with any custom scrollbars framework.
80+
</Text>
81+
<ComponentPrototype title="Menu" description="Scrollbar can be integrated in Menu">
82+
<ScrollbarMenuPrototype />
83+
</ComponentPrototype>
84+
<ComponentPrototype title="Popup" description="Scrollbar can be integrated in Popup content">
85+
<ScrollbarPopupPrototype />
86+
</ComponentPrototype>
87+
<ComponentPrototype
88+
title="Dialog"
89+
description="Scrollbar can be integrated in Dialog content"
90+
>
91+
<ScrollbarDialogPrototype />
92+
</ComponentPrototype>
93+
<ComponentPrototype title="List" description="Scrollbar can be integrated in selectable List">
94+
<ScrollbarListPrototype />
95+
</ComponentPrototype>
96+
</PrototypeSection>
97+
)
98+
}
99+
100+
export default CustomScrollbarPrototypes

docs/src/routes.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import NestedPopupsAndDialogsPrototype from './prototypes/NestedPopupsAndDialogs
4444
import VirtualizedTreePrototype from './prototypes/VirtualizedTree'
4545
import CopyToClipboardPrototype from './prototypes/CopyToClipboard'
4646
import ParticipantsListPrototype from './prototypes/ParticipantsList'
47+
import CustomScrollbarPrototype from './prototypes/customScrollbar'
4748
import EditorToolbarPrototype from './prototypes/EditorToolbar'
4849

4950
const Routes = () => (
@@ -63,6 +64,7 @@ const Routes = () => (
6364
<Route exact path="/quick-start" component={QuickStart} />
6465
<Route exact path="/prototype-chat-pane" component={ChatPanePrototype} />
6566
<Route exact path="/prototype-chat-messages" component={ChatMessagesPrototype} />
67+
<Route exact path="/prototype-custom-scrollbar" component={CustomScrollbarPrototype} />
6668
<Route exact path="/prototype-custom-toolbar" component={CustomToolbarPrototype} />
6769
<Route exact path="/prototype-async-shorthand" component={AsyncShorthandPrototype} />
6870
<Route exact path="/prototype-employee-card" component={EmployeeCardPrototype} />

0 commit comments

Comments
 (0)