Slide.tsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import React, { useMemo } from 'react'
  21. import { useSelector, useDispatch } from 'react-redux'
  22. import { makeSelectLayerIdsBySlide } from '../selectors'
  23. import {
  24. SlideContainer,
  25. SlideContent,
  26. SlideBackground,
  27. DisplayContainer
  28. } from '../components/Container'
  29. import { ISlideParams } from '../../Viz/types'
  30. import PreviewLayer from './Layer'
  31. interface ISlideProps {
  32. slideId: number
  33. slideParams: ISlideParams
  34. }
  35. const Slide: React.FC<ISlideProps> = (props) => {
  36. const { slideId, slideParams } = props
  37. const selectLayerIdsBySlide = useMemo(makeSelectLayerIdsBySlide, [])
  38. const layerIds = useSelector((state) => selectLayerIdsBySlide(state, slideId))
  39. const {
  40. transitionGlobal,
  41. transitionStyleIn,
  42. transitionStyleOut,
  43. transitionSpeed,
  44. autoSlideGlobal,
  45. autoPlay,
  46. autoSlide
  47. } = slideParams
  48. const sectionProps = {}
  49. if (transitionGlobal === false) {
  50. sectionProps[
  51. 'data-transition'
  52. ] = `${transitionStyleIn} ${transitionStyleOut}`
  53. sectionProps['data-transition-speed'] = transitionSpeed
  54. }
  55. if (autoSlideGlobal === false) {
  56. sectionProps['data-autoslide'] = autoPlay !== false ? autoSlide * 1000 : 0
  57. }
  58. return (
  59. <section {...sectionProps} className="display-preview-slide">
  60. <DisplayContainer>
  61. <SlideContainer slideId={slideId} slideParams={slideParams}>
  62. <SlideBackground padding={0} fullscreen>
  63. <SlideContent>
  64. {layerIds.map((id) => (
  65. <PreviewLayer key={id} id={id} />
  66. ))}
  67. </SlideContent>
  68. </SlideBackground>
  69. </SlideContainer>
  70. </DisplayContainer>
  71. </section>
  72. )
  73. }
  74. export default Slide