all files / packages/gutter/ Gutter.js

0% Statements 0/20
0% Branches 0/2
0% Functions 0/8
0% Lines 0/20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68                                                                                                                                       
import { Toolbox } from '../../ui'
 
/*
  A default implementation to render the content for the overlay (aka popup) tools.
*/
class Gutter extends Toolbox {
 
  render($$) {
    let el = $$('div').addClass(this.getClassNames())
    el.addClass('sm-hidden')
    el.addClass('sm-theme-'+this.getTheme())
    let activeToolGroups = this.state.activeToolGroups
    let activeToolsEl = $$('div').addClass('se-active-tools')
 
    activeToolGroups.forEach((toolGroup) => {
      let toolGroupProps = Object.assign({}, toolGroup, {
        toolStyle: this.getToolStyle(),
        showIcons: true
      })
      activeToolsEl.append(
        $$(toolGroup.Class, toolGroupProps)
      )
    })
 
    el.append(activeToolsEl)
    return el
  }
 
  /*
    Override if you just want to use a different style
  */
  getToolStyle() {
    return 'outline-dark'
  }
 
  show(hints) {
    this.el.removeClass('sm-hidden')
    this._position(hints)
  }
 
  hide() {
    this.el.addClass('sm-hidden')
  }
 
  _position(hints) {
    if (hints) {
      // By default, gutter is centered (y-axis) and left of the scrollPane content (x-axis)
      this.el.css('top', hints.rectangle.top + hints.rectangle.height - hints.rectangle.height / 2)
      this.el.css('left', 0)
    }
  }
 
  getClassNames() {
    return 'sc-gutter'
  }
 
  getTheme() {
    return 'dark'
  }
 
  getActiveToolGroupNames() {
    return ['gutter']
  }
 
}
 
export default Gutter