Skip to content
Snippets Groups Projects
Select Git revision
  • 77769ed5501583da30c444d88622e1bead1f5be3
  • demo_ci_gitlab_pages default
  • demo_gitlab_ci
  • 5-images-in-annotations
  • 5-final-images
  • 5-chpk-images-in-annot
  • tetras-main protected
  • 5-rebase-images-in-annot
  • 5-wip-images-in-annot
  • tmp
  • 1-edit-annotations-on-videos
  • 5-old-images-in-annotations
  • old_demo_ci_gitlab_pages
  • images_annotations
  • wip
  • devsetup
  • wip-annot-video-ui
  • wip-annotations-on-videos
  • master
  • v0.4.0_react16
  • wip-debugging-annotations
21 results

jest.config.js

Blame
  • Forked from IIIF / Mirador / Mirador annotations
    Source project has a limited visibility.
    CanvasAnnotations.js 2.52 KiB
    import { compose } from 'redux';
    import { connect } from 'react-redux';
    import { withTranslation } from 'react-i18next';
    import { withStyles } from '@material-ui/core/styles';
    import { withPlugins } from '../extend/withPlugins';
    import * as actions from '../state/actions';
    import {
      getAnnotationResourcesByMotivationForCanvas,
      getCanvasLabel,
      getSelectedAnnotationId,
      getConfig,
      getWindow,
    } from '../state/selectors';
    import { CanvasAnnotations } from '../components/CanvasAnnotations';
    
    /**
     * @param {Array} resources
     * @return {Array} [{ id: 'abc123', content: 'Annotation Content' }, ...]
     */
    function getIdAndContentOfResources(resources) {
      return resources.map((resource, i) => ({
        content: resource.chars,
        id: resource.id,
        tags: resource.tags,
        targetId: resource.targetId,
      }));
    }
    
    /** For connect */
    const mapStateToProps = (state, { canvasId, windowId }) => ({
      annotations: getIdAndContentOfResources(
        getAnnotationResourcesByMotivationForCanvas(state, { canvasId, windowId }),
      ),
      autoScroll: getWindow(state, { windowId }).autoScrollAnnotationList,
      htmlSanitizationRuleSet: getConfig(state).annotations.htmlSanitizationRuleSet,
      label: getCanvasLabel(state, {
        canvasId,
        windowId,
      }),
      selectedAnnotationId: getSelectedAnnotationId(state, { windowId }),
    });
    
    /**
     * mapDispatchToProps - to hook up connect
     * @memberof WindowSideBarAnnotationsPanel
     * @private
     */
    const mapDispatchToProps = {
      deselectAnnotation: actions.deselectAnnotation,
      hoverAnnotation: actions.hoverAnnotation,
      selectAnnotation: actions.selectAnnotation,
    };
    
    /** For withStyles */
    const styles = theme => ({
      annotationListItem: {
        '&$hovered': {
          backgroundColor: theme.palette.action.hover,
        },
        '&:hover,&:focus': {
          backgroundColor: theme.palette.action.hover,
        },
        borderBottom: `0.5px solid ${theme.palette.divider}`,
        cursor: 'pointer',
        whiteSpace: 'normal',
      },
      chip: {
        backgroundColor: theme.palette.background.paper,
        marginRight: theme.spacing(0.5),
        marginTop: theme.spacing(1),
      },
      hovered: {},
      manifestOpeningIcon: {
        width: '30%',
      },
      manifestOpeningLink: {
        width: '70%',
      },
      manifestOpeningWrapper: {
        display: 'flex',
      },
      sectionHeading: {
        paddingLeft: theme.spacing(2),
        paddingRight: theme.spacing(1),
        paddingTop: theme.spacing(2),
      },
    });
    
    const enhance = compose(
      withTranslation(),
      withStyles(styles),
      connect(mapStateToProps, mapDispatchToProps),
      withPlugins('CanvasAnnotations'),
    );
    
    export default enhance(CanvasAnnotations);