@@ -18,6 +18,14 @@ import {
1818} from "./components/WrappedFlexItem" ;
1919import { Test } from "./components/Test" ;
2020import { generateTextOfSize } from "./fixtures" ;
21+ import { RadioInputGroup , RadioInput } from "@instructure/ui-radio-input" ;
22+ import { IconInfoLine } from "@instructure/ui-icons" ;
23+ import { Tooltip } from "@instructure/ui-tooltip" ;
24+
25+ const DEFAULT_NUM_ITEMS = 1 ;
26+ const DEFAULT_ITEM_SIZE = 1024 * 32 ; // 32KiB
27+ const DEFAULT_CHUNK_SIZE = 1024 * 25 ; // 25 KiB
28+ const DEFAULT_MAX_CHUNKS_STORED = 5000 ;
2129
2230// For demonstration/testing purposes.
2331// Do *not* store cacheKey to localStorage in production.
@@ -33,13 +41,6 @@ if (!initialCacheBuster) {
3341 localStorage . cacheBuster = initialCacheBuster ;
3442}
3543
36- const DEFAULT_NUM_ITEMS = 1 ;
37-
38- // Default item size set to 32KB
39- const DEFAULT_ITEM_SIZE = 1024 * 32 ;
40- const DEFAULT_CHUNK_SIZE = 1024 * 25 ; // 25 KiB
41- const DEAFULT_MAX_CHUNKS_STORED = 5000 ;
42-
4344const getInitialItemSize = ( ) => {
4445 const params = new URLSearchParams ( window . location . hash . slice ( 1 ) ) ;
4546 const sizeParam = params . get ( "size" ) ;
@@ -67,8 +68,8 @@ const App = () => {
6768 const [ itemCount , setItemCount ] = useState < number | null > ( null ) ;
6869 const [ maxTotalChunksStored , setMaxTotalChunksStored ] = useState < number > (
6970 ( ) => {
70- const stored = localStorage . getItem ( " maxTotalChunksStored" ) ;
71- return stored ? Number . parseInt ( stored , 10 ) : DEAFULT_MAX_CHUNKS_STORED ;
71+ const stored = localStorage . maxTotalChunksStored ;
72+ return stored ? Number . parseInt ( stored , 10 ) : DEFAULT_MAX_CHUNKS_STORED ;
7273 } ,
7374 ) ;
7475
@@ -303,7 +304,22 @@ const App = () => {
303304
304305 < WrappedFlexItem >
305306 < NumberInput
306- renderLabel = "Item size (KiB):"
307+ renderLabel = {
308+ < Flex alignItems = "end" direction = "row" >
309+ < Flex . Item as = "div" >
310+ < View margin = "0 xx-small 0 0" > Item size (KiB)</ View >
311+ </ Flex . Item >
312+ < Tooltip
313+ color = "primary-inverse"
314+ renderTip = "When an item exceeds this size, it splits into multiple chunks."
315+ offsetY = "5px"
316+ >
317+ < Flex . Item as = "div" >
318+ < IconInfoLine />
319+ </ Flex . Item >
320+ </ Tooltip >
321+ </ Flex >
322+ }
307323 onChange = { ( e ) => {
308324 const newValue = Math . max (
309325 Number . parseInt ( e . target . value || "0" , 10 ) * 1024 ,
@@ -317,7 +333,6 @@ const App = () => {
317333 onDecrement = { ( ) => {
318334 setItemSize ( ( prev ) => Math . max ( prev - 1024 , 1024 ) ) ;
319335 } }
320- isRequired
321336 value = { Math . round ( itemSize / 1024 ) } // Display in KiB
322337 />
323338 </ WrappedFlexItem >
@@ -332,7 +347,7 @@ const App = () => {
332347 < WrappedFlexItem >
333348 < NumberInput
334349 disabled
335- renderLabel = "Chunk size (KiB): "
350+ renderLabel = "Chunk size (KiB)"
336351 onChange = { ( e ) => {
337352 const newValue = Math . max (
338353 Number . parseInt ( e . target . value || "0" , 10 ) * 1024 ,
@@ -352,7 +367,22 @@ const App = () => {
352367
353368 < WrappedFlexItem >
354369 < NumberInput
355- renderLabel = "Max total chunks:"
370+ renderLabel = {
371+ < Flex alignItems = "end" >
372+ < Flex . Item as = "div" >
373+ < View margin = "0 xx-small 0 0" > Max total chunks</ View >
374+ </ Flex . Item >
375+ < Tooltip
376+ color = "primary-inverse"
377+ renderTip = "During cleanup, idb-cache removes the oldest surplus chunks."
378+ offsetY = "5px"
379+ >
380+ < Flex . Item as = "div" >
381+ < IconInfoLine />
382+ </ Flex . Item >
383+ </ Tooltip >
384+ </ Flex >
385+ }
356386 onChange = { ( e ) => {
357387 const newValue =
358388 Number . parseInt ( e . target . value || "0" , 10 ) || 1 ;
@@ -367,6 +397,33 @@ const App = () => {
367397 value = { maxTotalChunksStored }
368398 />
369399 </ WrappedFlexItem >
400+
401+ < WrappedFlexItem >
402+ < RadioInputGroup
403+ name = "priority"
404+ defaultValue = "normal"
405+ description = {
406+ < Flex alignItems = "end" >
407+ < Flex . Item as = "div" >
408+ < View margin = "0 xx-small 0 0" > Priority</ View >
409+ </ Flex . Item >
410+ < Tooltip
411+ color = "primary-inverse"
412+ renderTip = "Low priority delays start of operations slightly to reduce load on event loop."
413+ offsetY = "5px"
414+ >
415+ < Flex . Item as = "div" >
416+ < IconInfoLine />
417+ </ Flex . Item >
418+ </ Tooltip >
419+ </ Flex >
420+ }
421+ variant = "toggle"
422+ >
423+ < RadioInput label = "Normal" value = "normal" />
424+ < RadioInput label = "Low" value = "low" />
425+ </ RadioInputGroup >
426+ </ WrappedFlexItem >
370427 </ WrappedFlexContainer >
371428
372429 < Heading level = "h2" margin = "medium 0 small 0" >
0 commit comments