1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { useSearchParams } from 'react-router-dom';
5 import Overlay from './Overlay';
6 import { useOpenSeadragon } from './OpenSeadragon';
440 const getClassName = key => {
441 const classNames = [];
442 if (strongEG.includes(key)) {
443 classNames.push('strong-eg');
445 if (weakEG.includes(key)) {
446 classNames.push('weak-eg');
448 if (kick.includes(key)) {
449 classNames.push('kick');
451 if (dark.includes(key)) {
452 classNames.push('dark');
455 camera[key].forEach(c => {
456 classNames.push(`cam-${c}`);
459 return classNames.join(' ');
462 const UWSuperTiles = ({ show }) => {
463 const { storePosition, viewer } = useOpenSeadragon();
464 const [, setSearchParams] = useSearchParams();
466 const onClick = React.useCallback(e => {
467 if (e.originalTarget.tagName !== 'A') return;
468 if (e.originalTarget.className !== 'cell-link') return;
469 const key = e.originalTarget.dataset.key;
471 const x = (parseInt(key[1], 16) + 0.5) / 16;
472 const y = (parseInt(key[0], 16) + 0.5) / 16;
473 if (viewer && viewer.viewport) {
475 setSearchParams({ x, y, z: 4 });
476 viewer.element.scrollIntoView();
478 }, [storePosition, viewer]);
480 return <Overlay onClick={onClick} page={3} x={0} y={0} width={1} height={1}>
481 <div className={`uw-super-tiles ${show ? '' : 'd-none'}`}>
482 {[...Array(16).keys()].map(x =>
483 [...Array(16).keys()].map(y => {
484 const key = `${x.toString(16).toUpperCase()}${y.toString(16).toUpperCase()}`;
485 return <div className={getClassName(key)} key={key}>
486 <p className="cell-id">{key}</p>
488 <p className="cell-drop">
489 <a className="cell-link" data-key={dropMap[key]}>
490 {`▶ ${dropMap[key]}`}
501 UWSuperTiles.propTypes = {
502 show: PropTypes.bool,
505 export default UWSuperTiles;