DisabledTokenInput.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (C) 2016 - 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 React from 'react'
  19. import PropTypes from 'prop-types'
  20. import _ from 'underscore'
  21. const styles = {
  22. list: {
  23. backgroundColor: "#eeeeee"
  24. },
  25. label: {
  26. backgroundColor: "white",
  27. borderRadius: "3px"
  28. }
  29. };
  30. class DisabledTokenInput extends React.Component {
  31. static propTypes = {
  32. tokens: PropTypes.arrayOf(PropTypes.string)
  33. }
  34. renderTokens() {
  35. return _.map(this.props.tokens, function(token, index) {
  36. return (
  37. <li key={`token-${index}`} className="ic-token inline-flex">
  38. <span className="ic-token-label" style={styles.label}>{token}</span>
  39. </li>
  40. );
  41. });
  42. }
  43. render() {
  44. return(
  45. <ul tabIndex="0" aria-labelledby="assign-to-label" className="ic-tokens flex" style={styles.list}>
  46. {this.renderTokens()}
  47. </ul>
  48. );
  49. }
  50. }
  51. export default DisabledTokenInput