|
1 | 1 | import React from 'react'; |
2 | 2 | import PropTypes from 'prop-types'; |
3 | 3 | import {observer} from 'mobx-react-lite'; |
4 | | -import {Button, ButtonGroup, Icon} from '@blueprintjs/core'; |
| 4 | +import classnames from 'classnames'; |
| 5 | +import {Button, ButtonGroup, Icon, Intent} from '@blueprintjs/core'; |
5 | 6 | import {StoresContext} from '../Context'; |
6 | 7 | import {NodeCategories} from '../../datasets/tree'; |
7 | 8 |
|
8 | 9 | const Options = observer((props) => { |
9 | 10 | const stores = React.useContext(StoresContext); |
10 | | - const {activeNode} = stores.uiStore; |
| 11 | + const {activeNode, activeWidget, widgets} = stores.uiStore; |
11 | 12 | const [confirmDelete, setConfirmDelete] = React.useState(false); |
| 13 | + const {errors, hints, info, warning} = stores.lintStore; |
| 14 | + |
| 15 | + const lintSpec = () => { |
| 16 | + if (activeWidget === widgets.lint) { |
| 17 | + stores.uiStore.toggleWidget(stores.uiStore.widgets.lint); |
| 18 | + } else { |
| 19 | + stores.uiStore.setActiveWidget(stores.uiStore.widgets.lint); |
| 20 | + } |
| 21 | + }; |
12 | 22 |
|
13 | 23 | return ( |
14 | | - <div className="border-b border-transparent PanelActionBar w-full flex items-center px-5 py-2"> |
| 24 | + <div |
| 25 | + className={classnames( |
| 26 | + 'border-b PanelActionBar w-full flex items-center px-5 py-2', |
| 27 | + { |
| 28 | + 'border-transparent': !activeWidget, |
| 29 | + }, |
| 30 | + )}> |
15 | 31 | {activeNode && activeNode.category === NodeCategories.SourceMap && ( |
16 | 32 | <div className="flex items-center"> |
17 | 33 | <Button |
@@ -50,13 +66,54 @@ const Options = observer((props) => { |
50 | 66 | text="Code" |
51 | 67 | onClick={() => props.onToggleView('code')} |
52 | 68 | /> |
| 69 | + </ButtonGroup> |
| 70 | + </div> |
| 71 | + <div className="ml-3"> |
| 72 | + <ButtonGroup> |
53 | 73 | <Button |
54 | 74 | active={props.view === 'docs'} |
55 | 75 | small |
56 | 76 | icon={<Icon size={14} icon="book" />} |
57 | 77 | text="Preview" |
58 | 78 | onClick={() => props.onToggleView('preview')} |
59 | 79 | /> |
| 80 | + <Button |
| 81 | + active={stores.uiStore.activeWidget === stores.uiStore.widgets.lint} |
| 82 | + small |
| 83 | + text={ |
| 84 | + <div className="flex justify-center"> |
| 85 | + <Icon |
| 86 | + size={14} |
| 87 | + icon="error" |
| 88 | + intent={Intent.DANGER} |
| 89 | + className="m-auto pl-2 pr-1" |
| 90 | + /> |
| 91 | + <span className="counter m-auto">{errors.length}</span> |
| 92 | + <Icon |
| 93 | + size={14} |
| 94 | + intent={Intent.WARNING} |
| 95 | + icon="warning-sign" |
| 96 | + className="m-auto pl-2 pr-1" |
| 97 | + /> |
| 98 | + <span className="counter m-auto">{warning.length}</span> |
| 99 | + <Icon |
| 100 | + size={14} |
| 101 | + icon="info-sign" |
| 102 | + intent={Intent.PRIMARY} |
| 103 | + className="m-auto pl-2 pr-1" |
| 104 | + /> |
| 105 | + <span className="counter m-auto">{info.length}</span> |
| 106 | + <Icon |
| 107 | + size={14} |
| 108 | + icon="lightbulb" |
| 109 | + intent={Intent.SUCCESS} |
| 110 | + className="m-auto pl-2 pr-1" |
| 111 | + /> |
| 112 | + <span className="counter m-auto">{hints.length}</span> |
| 113 | + </div> |
| 114 | + } |
| 115 | + onClick={() => lintSpec()} |
| 116 | + /> |
60 | 117 | </ButtonGroup> |
61 | 118 | </div> |
62 | 119 | <div className="ml-3"> |
|
0 commit comments