@cu-mkp/editioncrafter 1.3.1-beta.2 → 1.3.1-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,10 +55,16 @@ function TagFilterProvider(props) {
55
55
  }
56
56
  }
57
57
 
58
+ const clearTags = () => {
59
+ setTagsRight([])
60
+ setTagsLeft([])
61
+ }
62
+
58
63
  return {
59
64
  tagsLeft,
60
65
  tagsRight,
61
66
  toggleTag,
67
+ clearTags,
62
68
  }
63
69
  }, [location.pathname, navigate, searchParams, tagParamsLeft, tagParamsRight, tagsLeft, tagsRight])
64
70
 
@@ -4,6 +4,7 @@ const TagFilterContext = createContext({
4
4
  tagsLeft: [],
5
5
  tagsRight: [],
6
6
  toggleTag: () => null,
7
+ clearTags: () => null,
7
8
  })
8
9
 
9
10
  export default TagFilterContext
@@ -1,12 +1,13 @@
1
1
  import { Box, Button, Collapse, Divider, IconButton, Input, Typography } from '@material-ui/core'
2
2
  import ChevronLeftIcon from '@material-ui/icons/ChevronLeft'
3
3
  import TuneIcon from '@material-ui/icons/Tune'
4
- import { useCallback, useEffect, useMemo, useState } from 'react'
4
+ import { useCallback, useContext, useEffect, useMemo, useState } from 'react'
5
5
 
6
6
  import { useLocation, useNavigate } from 'react-router-dom'
7
7
  import { getObjs } from '../../common/lib/sql'
8
8
  import DocumentDetail from './DocumentDetail'
9
9
  // import DocumentFilters from './DocumentFilters'
10
+ import TagFilterContext from '../../EditionCrafter/context/TagFilterContext'
10
11
  import TagFilters from './TagFilters'
11
12
 
12
13
  function getData(db) {
@@ -90,6 +91,7 @@ function SurfaceBrowser(props) {
90
91
  const navigate = useNavigate()
91
92
  const location = useLocation()
92
93
  const selection = useMemo(() => getSelection(location.pathname), [location])
94
+ const { clearTags } = useContext(TagFilterContext)
93
95
 
94
96
  const navigateToSelection = useCallback((nextSelection) => {
95
97
  const folioID = nextSelection?.left ? `${nextSelection.left.localID}_${nextSelection.left.surfaceID}` : null
@@ -140,34 +142,45 @@ function SurfaceBrowser(props) {
140
142
  <Divider></Divider>
141
143
  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
142
144
  <Typography>Contents</Typography>
143
- <Button
144
- startIcon={<TuneIcon />}
145
- onClick={() => setShowFilters(current => (!current))}
146
- >
147
- Filter
145
+ <div>
148
146
  { tags && tags.length
149
147
  ? (
150
- <div style={{
151
- fontSize: 'small',
152
- backgroundColor: 'red',
153
- borderRadius: '999px',
154
- display: 'flex',
155
- justifyContent: 'center',
156
- alignItems: 'center',
157
- padding: '3px',
158
- color: 'white',
159
- height: '16px',
160
- width: '16px',
161
- position: 'absolute',
162
- top: '0',
163
- left: '-12px',
164
- }}
148
+ <Button
149
+ onClick={clearTags}
165
150
  >
166
- {tags.length}
167
- </div>
151
+ Clear All
152
+ </Button>
168
153
  )
169
154
  : null}
170
- </Button>
155
+ <Button
156
+ startIcon={<TuneIcon />}
157
+ onClick={() => setShowFilters(current => (!current))}
158
+ >
159
+ Filter
160
+ { tags && tags.length
161
+ ? (
162
+ <div style={{
163
+ fontSize: 'small',
164
+ backgroundColor: 'red',
165
+ borderRadius: '999px',
166
+ display: 'flex',
167
+ justifyContent: 'center',
168
+ alignItems: 'center',
169
+ padding: '3px',
170
+ color: 'white',
171
+ height: '16px',
172
+ width: '16px',
173
+ position: 'absolute',
174
+ top: '0',
175
+ left: '-12px',
176
+ }}
177
+ >
178
+ {tags.length}
179
+ </div>
180
+ )
181
+ : null}
182
+ </Button>
183
+ </div>
171
184
  </div>
172
185
  <Typography>
173
186
  {totalPages}
@@ -34,7 +34,6 @@ function getData(db) {
34
34
  function TagFilters(props) {
35
35
  const { onToggleSelected, filters, query } = props
36
36
  const data = useMemo(() => getData(props.db), [props.db])
37
- console.log(data.taxonomies)
38
37
  const [expanded, setExpanded] = useState(data.taxonomies?.map(() => (false)))
39
38
  const [displayedTags, setDisplayedTags] = useState({})
40
39
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cu-mkp/editioncrafter",
3
3
  "type": "module",
4
- "version": "1.3.1-beta.2",
4
+ "version": "1.3.1-beta.3",
5
5
  "private": false,
6
6
  "description": "A simple digital critical edition publication tool",
7
7
  "license": "MIT",