|
| 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 |
0 commit comments