Skip to content
Snippets Groups Projects
Select Git revision
  • 75ea2ea9674615c98230f67936069f6a4f0f4030
  • mui5-annotation-on-video-stable default
  • get_setter_canvasSizeInformations
  • fix-error-div-into-p
  • annotation-on-video-v2
  • detached
  • annotation-on-video-r17
  • mui5
  • mui5-react-18
  • jacob-test
  • annotation-on-video protected
  • master
  • test-antoinev1
  • 20-fetch-thumbnail-on-annotation
  • add-research-field
  • Save
  • add-plugin
  • 14-wip-no-seek-to
  • 14-bug-on-video-time-control
  • 9_wip_videotests
  • _upgrade_material_ui
  • latest-tetras-16
  • v3.3.0
  • v3.2.0
  • v3.1.1
  • v3.1.0
  • v3.0.0
  • v3.0.0-rc.7
  • v3.0.0-rc.6
  • v3.0.0-rc.5
  • v3.0.0-rc.4
  • v3.0.0-rc.3
  • v3.0.0-rc.2
  • v3.0.0-rc.1
  • v3.0.0-beta.10
  • v3.0.0-beta.9
  • v3.0.0-beta.8
  • v3.0.0-beta.7
  • v3.0.0-beta.6
  • v3.0.0-beta.5
  • v3.0.0-beta.3
41 results

WindowSideBarButtons.js

Blame
  • WindowSideBarButtons.js 2.17 KiB
    import { compose } from 'redux';
    import { connect } from 'react-redux';
    import { withStyles } from '@material-ui/core';
    import { fade } from '@material-ui/core/styles/colorManipulator';
    import { withTranslation } from 'react-i18next';
    import * as actions from '../state/actions';
    import {
      getCompanionWindowForPosition,
      getSelectedCanvas,
      getSelectedCanvasAnnotations,
      getAnnotationResourcesByMotivation,
    } from '../state/selectors';
    import { WindowSideBarButtons } from '../components/WindowSideBarButtons';
    
    
    /**
     * mapDispatchToProps - used to hook up connect to action creators
     * @memberof WindowSideButtons
     * @private
     */
    const mapDispatchToProps = (dispatch, { windowId }) => ({
      addCompanionWindow: content => dispatch(
        actions.addCompanionWindow(windowId, { content, position: 'left' }),
      ),
    });
    
    
    /**
     * mapStateToProps - used to hook up connect to state
     * @memberof WindowSideButtons
     * @private
     */
    const mapStateToProps = (state, { windowId }) => ({
      hasAnnotations: getAnnotationResourcesByMotivation(
        getSelectedCanvasAnnotations(state, (getSelectedCanvas(state, windowId) || {}).id),
        ['oa:commenting', 'sc:painting'],
      ).length > 0,
      sideBarPanel: (getCompanionWindowForPosition(state, windowId, 'left') || {}).content,
    });
    
    /** */
    const style = theme => ({
      tabsFlexContainer: {
        flexDirection: 'column',
      },
      tabsIndicator: {
        display: 'none',
      },
      tab: {
        minWidth: 'auto',
        borderRight: '4px solid transparent',
        '&:hover': {
          textDecoration: 'none',
          backgroundColor: fade(theme.palette.text.primary, theme.palette.action.hoverOpacity),
          // Reset on touch devices, it doesn't add specificity
          '@media (hover: none)': {
            backgroundColor: 'transparent',
          },
          '&$disabled': {
            backgroundColor: 'transparent',
          },
        },
      },
      tabSelected: {
        backgroundColor: theme.palette.secondary.light,
        borderRight: `4px solid ${theme.palette.secondary.main}`,
        '&:hover': {
          backgroundColor: theme.palette.secondary.light,
        },
      },
    });
    
    const enhance = compose(
      withTranslation(),
      withStyles(style),
      connect(mapStateToProps, mapDispatchToProps),
    );
    
    export default enhance(WindowSideBarButtons);