TutorialTrayContent.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) 2017 - 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 Heading from 'instructure-ui/lib/components/Heading'
  21. import Image from 'instructure-ui/lib/components/Image'
  22. import SVGWrapper from 'jsx/shared/SVGWrapper'
  23. const TutorialTrayContent = props => (
  24. <div className={props.name}>
  25. <Heading level="h2" as="h2" ellipsis>{props.heading}</Heading>
  26. <div className="NewUserTutorialTray__Subheading">
  27. <Heading level="h3" as="h3">{props.subheading}</Heading>
  28. </div>
  29. {props.children}
  30. {
  31. props.image
  32. ? <div className="NewUserTutorialTray__ImageContainer" aria-hidden="true">
  33. {/\.svg$/.test(props.image)
  34. ? <SVGWrapper url={props.image} />
  35. : <Image src={props.image} />}
  36. </div>
  37. : null
  38. }
  39. </div>
  40. )
  41. TutorialTrayContent.propTypes = {
  42. name: PropTypes.string.isRequired,
  43. heading: PropTypes.string.isRequired,
  44. subheading: PropTypes.string.isRequired,
  45. children: PropTypes.oneOfType([
  46. PropTypes.arrayOf(PropTypes.node),
  47. PropTypes.node
  48. ]),
  49. image: PropTypes.string
  50. };
  51. TutorialTrayContent.defaultProps = {
  52. children: [],
  53. image: null,
  54. name: ''
  55. }
  56. export default TutorialTrayContent