BreadcrumbCollapsedContainer.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (C) 2015 - present Instructure, Inc.
  3. *
  4. * This file is part of Canvas.
  5. *
  6. * Canvas is free software: you can redistribute it and/or modify it under
  7. * the terms of the GNU Affero General Public License as published by the Free
  8. * Software Foundation, version 3 of the License.
  9. *
  10. * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
  11. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. * details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. import I18n from 'i18n!react_files'
  19. import React from 'react'
  20. import PropTypes from 'prop-types'
  21. import classnames from 'classnames'
  22. import filesEnv from 'compiled/react_files/modules/filesEnv'
  23. import customPropTypes from 'compiled/react_files/modules/customPropTypes'
  24. const BreadcrumbCollapsedContainer = React.createClass({
  25. displayName: 'BreadcrumbCollapsedContainer',
  26. propTypes: {
  27. foldersToContain: PropTypes.arrayOf(customPropTypes.folder).isRequired
  28. },
  29. getInitialState () {
  30. return {
  31. open: false
  32. };
  33. },
  34. open () {
  35. window.clearTimeout(this.timeout);
  36. this.setState({
  37. open: true
  38. });
  39. },
  40. close () {
  41. this.timeout = window.setTimeout(() => {
  42. this.setState({
  43. open: false
  44. });
  45. }, 100);
  46. },
  47. render () {
  48. var divClasses = classnames({
  49. 'open': this.state.open,
  50. 'closed': !this.state.open,
  51. 'popover': true,
  52. 'bottom': true,
  53. 'ef-breadcrumb-popover': true
  54. });
  55. return (
  56. <li href = '#'
  57. onMouseEnter={this.open}
  58. onMouseLeave={this.close}
  59. onFocus={this.open}
  60. onBlur={this.close}
  61. style={{position: 'relative'}}
  62. >
  63. <a href='#'>…</a>
  64. <div className={divClasses}>
  65. <div className='arrow' />
  66. <div className='popover-content'>
  67. <ul>
  68. {this.props.foldersToContain.map((folder) => {
  69. return (
  70. <li key={folder.cid}>
  71. <a
  72. href={(folder.urlPath()) ? `${filesEnv.baseUrl}/folder/${folder.urlPath()}`: filesEnv.baseUrl}
  73. activeClassName='active'
  74. className='ellipsis'
  75. >
  76. <i className='ef-big-icon icon-folder' />
  77. <span>{folder.get('name')}</span>
  78. </a>
  79. </li>
  80. );
  81. })}
  82. </ul>
  83. </div>
  84. </div>
  85. </li>
  86. );
  87. }
  88. });
  89. export default BreadcrumbCollapsedContainer