|
| 1 | +import React from 'react' |
| 2 | +import type {Meta} from '@storybook/react' |
| 3 | +import ActionBar from '.' |
| 4 | +import { |
| 5 | + BoldIcon, |
| 6 | + CodeIcon, |
| 7 | + ItalicIcon, |
| 8 | + SearchIcon, |
| 9 | + LinkIcon, |
| 10 | + FileAddedIcon, |
| 11 | + HeadingIcon, |
| 12 | + QuoteIcon, |
| 13 | + ListUnorderedIcon, |
| 14 | + ListOrderedIcon, |
| 15 | + TasklistIcon, |
| 16 | +} from '@primer/octicons-react' |
| 17 | +import {MarkdownInput} from '../MarkdownEditor/_MarkdownInput' |
| 18 | +import {ViewSwitch} from '../MarkdownEditor/_ViewSwitch' |
| 19 | +import type {MarkdownViewMode} from '../MarkdownEditor/_ViewSwitch' |
| 20 | +import {Box} from '../..' |
| 21 | + |
| 22 | +export default { |
| 23 | + title: 'Drafts/Components/ActionBar', |
| 24 | +} as Meta<typeof ActionBar> |
| 25 | + |
| 26 | +export const Default = () => ( |
| 27 | + <ActionBar> |
| 28 | + <ActionBar.IconButton icon={BoldIcon} aria-label="Default"></ActionBar.IconButton> |
| 29 | + <ActionBar.IconButton icon={ItalicIcon} aria-label="Default"></ActionBar.IconButton> |
| 30 | + <ActionBar.IconButton icon={CodeIcon} aria-label="Default"></ActionBar.IconButton> |
| 31 | + <ActionBar.IconButton icon={LinkIcon} aria-label="Default"></ActionBar.IconButton> |
| 32 | + <ActionBar.Divider /> |
| 33 | + <ActionBar.IconButton icon={FileAddedIcon} aria-label="Default"></ActionBar.IconButton> |
| 34 | + <ActionBar.IconButton icon={SearchIcon} aria-label="Default"></ActionBar.IconButton> |
| 35 | + <ActionBar.IconButton icon={FileAddedIcon} aria-label="Default"></ActionBar.IconButton> |
| 36 | + <ActionBar.IconButton icon={SearchIcon} aria-label="Default"></ActionBar.IconButton> |
| 37 | + <ActionBar.IconButton icon={FileAddedIcon} aria-label="Default"></ActionBar.IconButton> |
| 38 | + <ActionBar.IconButton icon={SearchIcon} aria-label="Default"></ActionBar.IconButton> |
| 39 | + <ActionBar.IconButton icon={FileAddedIcon} aria-label="Default"></ActionBar.IconButton> |
| 40 | + <ActionBar.IconButton icon={SearchIcon} aria-label="Default"></ActionBar.IconButton> |
| 41 | + </ActionBar> |
| 42 | +) |
| 43 | + |
| 44 | +export const SmallActionBar = () => ( |
| 45 | + <ActionBar size="small"> |
| 46 | + <ActionBar.IconButton icon={BoldIcon} aria-label="Default"></ActionBar.IconButton> |
| 47 | + <ActionBar.IconButton icon={ItalicIcon} aria-label="Default"></ActionBar.IconButton> |
| 48 | + <ActionBar.IconButton icon={CodeIcon} aria-label="Default"></ActionBar.IconButton> |
| 49 | + <ActionBar.IconButton icon={LinkIcon} aria-label="Default"></ActionBar.IconButton> |
| 50 | + <ActionBar.Divider /> |
| 51 | + <ActionBar.IconButton icon={FileAddedIcon} aria-label="Default"></ActionBar.IconButton> |
| 52 | + <ActionBar.IconButton icon={SearchIcon} aria-label="Default"></ActionBar.IconButton> |
| 53 | + </ActionBar> |
| 54 | +) |
| 55 | + |
| 56 | +export const CommentBox = () => { |
| 57 | + const [view, setView] = React.useState<MarkdownViewMode>('edit') |
| 58 | + const loadPreview = React.useCallback(() => { |
| 59 | + //console.log('loadPreview') |
| 60 | + }, []) |
| 61 | + const [value, setValue] = React.useState('') |
| 62 | + return ( |
| 63 | + <Box |
| 64 | + sx={{ |
| 65 | + maxWidth: 800, |
| 66 | + display: 'flex', |
| 67 | + flexDirection: 'column', |
| 68 | + width: '100%', |
| 69 | + borderColor: 'border.default', |
| 70 | + borderWidth: 1, |
| 71 | + borderStyle: 'solid', |
| 72 | + borderRadius: 2, |
| 73 | + minInlineSize: 'auto', |
| 74 | + bg: 'canvas.default', |
| 75 | + color: 'fg.default', |
| 76 | + }} |
| 77 | + > |
| 78 | + <Box |
| 79 | + sx={{ |
| 80 | + display: 'flex', |
| 81 | + flexDirection: 'row', |
| 82 | + backgroundColor: 'canvas.subtle', |
| 83 | + borderTopLeftRadius: 2, |
| 84 | + borderTopRightRadius: 2, |
| 85 | + justifyContent: 'space-between', |
| 86 | + }} |
| 87 | + as="header" |
| 88 | + > |
| 89 | + <Box sx={{width: '50%'}}> |
| 90 | + <ViewSwitch |
| 91 | + selectedView={view} |
| 92 | + onViewSelect={setView} |
| 93 | + //disabled={fileHandler?.uploadProgress !== undefined} |
| 94 | + onLoadPreview={loadPreview} |
| 95 | + /> |
| 96 | + </Box> |
| 97 | + <Box sx={{width: '50%'}}> |
| 98 | + <ActionBar> |
| 99 | + <ActionBar.IconButton icon={HeadingIcon} aria-label="Heading"></ActionBar.IconButton> |
| 100 | + <ActionBar.IconButton icon={BoldIcon} aria-label="Bold"></ActionBar.IconButton> |
| 101 | + <ActionBar.IconButton icon={ItalicIcon} aria-label="Italic"></ActionBar.IconButton> |
| 102 | + <ActionBar.IconButton icon={CodeIcon} aria-label="Insert Code"></ActionBar.IconButton> |
| 103 | + <ActionBar.IconButton icon={LinkIcon} aria-label="Insert Link"></ActionBar.IconButton> |
| 104 | + <ActionBar.Divider /> |
| 105 | + <ActionBar.IconButton icon={QuoteIcon} aria-label="Insert Quote"></ActionBar.IconButton> |
| 106 | + <ActionBar.IconButton icon={ListUnorderedIcon} aria-label="Unordered List"></ActionBar.IconButton> |
| 107 | + <ActionBar.IconButton icon={ListOrderedIcon} aria-label="Ordered List"></ActionBar.IconButton> |
| 108 | + <ActionBar.IconButton icon={TasklistIcon} aria-label="Task List"></ActionBar.IconButton> |
| 109 | + </ActionBar> |
| 110 | + </Box> |
| 111 | + </Box> |
| 112 | + <MarkdownInput |
| 113 | + value={value} |
| 114 | + visible={view === 'edit'} |
| 115 | + onChange={e => { |
| 116 | + setValue(e.target.value) |
| 117 | + }} |
| 118 | + id={'markdowninput'} |
| 119 | + isDraggedOver={false} |
| 120 | + minHeightLines={5} |
| 121 | + maxHeightLines={35} |
| 122 | + monospace={false} |
| 123 | + pasteUrlsAsPlainText={false} |
| 124 | + /> |
| 125 | + </Box> |
| 126 | + ) |
| 127 | +} |
0 commit comments