<commit_before>import React, {PropTypes} from 'react';
import {
  TOOL_NONE, TOOL_PAN, TOOL_ZOOM_IN, TOOL_ZOOM_OUT,
  POSITION_TOP, POSITION_RIGHT, POSITION_BOTTOM, POSITION_LEFT,
} from '../constants';

import {fitToViewer} from '../features/zoom';
import IconCursor from './icon-cursor';
import IconPan from './icon-pan';
import IconZoomIn from './icon-zoom-in';
import IconZoomOut from './icon-zoom-out';
import IconFit from './icon-fit';

import Link from '../ui/link';

let isHorizontal = position => [POSITION_TOP, POSITION_BOTTOM].includes(position);

let calcToolbarStyle = position => {
  return {
    //position
    position: "absolute",
    transform: [POSITION_TOP, POSITION_BOTTOM].includes(position) ? "translate(-50%, 0px)" : "none",
    top: [POSITION_LEFT, POSITION_RIGHT, POSITION_TOP].includes(position) ? "5px" : "unset",
    left: [POSITION_TOP, POSITION_BOTTOM].includes(position) ? "50%" : (POSITION_LEFT === position ? "5px" : "unset"),
    right: [POSITION_RIGHT].includes(position) ? "5px" : "unset",
    bottom: [POSITION_BOTTOM].includes(position) ? "5px" : "unset",

    //inner styling
    backgroundColor: "rgba(19, 20, 22, 0.90)",
    borderRadius: "2px",
    display: "flex",
    flexDirection: isHorizontal(position) ? "row" : "column",
    padding: isHorizontal(position) ? "3px 5px 3px 3px" : "5px 3px 3px 3px"
  };
};

let calcElementStyle = (position, active, hover) => {
  return {
    display: "block",
    width: "24px",
    height: "24px",
    padding: isHorizontal(position) ? "2px 1px" : "1px 2px",
    color: active || hover ? '#1CA6FC' : '#FFF',
    transition: hover ? "color 200ms ease" : "unset"
  };
};

export default function Toolbar({tool, value, onChangeValue, onChangeTool, position}) {

  let handleChangeTool = (event, tool) => {
    onChangeTool(tool);
    event.stopPropagation();
    event.preventDefault();
  };

  let handleFit = event => {
    onChangeValue(fitToViewer(value));
    event.stopPropagation();
    event.preventDefault();
  };

  return (
    <div style={calcToolbarStyle(position)}>
      <Link<commit_msg>fix bootstrap toolbar compatibility<commit_after>import React, {PropTypes} from 'react';
import {
  TOOL_NONE, TOOL_PAN, TOOL_ZOOM_IN, TOOL_ZOOM_OUT,
  POSITION_TOP, POSITION_RIGHT, POSITION_BOTTOM, POSITION_LEFT,
} from '../constants';

import {fitToViewer} from '../features/zoom';
import IconCursor from './icon-cursor';
import IconPan from './icon-pan';
import IconZoomIn from './icon-zoom-in';
import IconZoomOut from './icon-zoom-out';
import IconFit from './icon-fit';

import Link from '../ui/link';

let isHorizontal = position => [POSITION_TOP, POSITION_BOTTOM].includes(position);

let calcToolbarStyle = position => {
  return {
    //position
    position: "absolute",
    transform: [POSITION_TOP, POSITION_BOTTOM].includes(position) ? "translate(-50%, 0px)" : "none",
    top: [POSITION_LEFT, POSITION_RIGHT, POSITION_TOP].includes(position) ? "5px" : "unset",
    left: [POSITION_TOP, POSITION_BOTTOM].includes(position) ? "50%" : (POSITION_LEFT === position ? "5px" : "unset"),
    right: [POSITION_RIGHT].includes(position) ? "5px" : "unset",
    bottom: [POSITION_BOTTOM].includes(position) ? "5px" : "unset",

    //inner styling
    backgroundColor: "rgba(19, 20, 22, 0.90)",
    borderRadius: "2px",
    display: "flex",
    flexDirection: isHorizontal(position) ? "row" : "column",
    padding: isHorizontal(position) ? "1px 2px" : "2px 1px"
  };
};

let calcElementStyle = (position, active, hover) => {
  return {
    display: "block",
    width: "24px",
    height: "24px",
    margin: isHorizontal(position) ? "2px 1px" : "1px 2px",
    color: active || hover ? '#1CA6FC' : '#FFF',
    transition: hover ? "color 200ms ease" : "unset"
  };
};

export default function Toolbar({tool, value, onChangeValue, onChangeTool, position}) {

  let handleChangeTool = (event, tool) => {
    onChangeTool(tool);
    event.stopPropagation();
    event.preventDefault();
  };

  let handleFit = event => {
    onChangeValue(fitToViewer(value));
    event.stopPropagation();
    event.preventDefault();
  };

  return (
    <div style={calcToolbarStyle(position)}>
      <Link
{'fraction_non_alphanumeric': 0.15911814042655165, 'fraction_numerical': 0.01821231727773784, 'mean_word_length': 4.243718592964824, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2103549', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1397, 'n_words': 324}