@vixoniccom/news-internal 0.4.21-dev.24 → 0.4.21-dev.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build.zip CHANGED
Binary file
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "author": {
9
9
  "name": ""
10
10
  },
11
- "version": "0.4.21-dev.24",
11
+ "version": "0.4.21-dev.26",
12
12
  "scripts": {
13
13
  "prepublish": "vixonic-module-packager --mode=build",
14
14
  "watch": "vixonic-module-packager --mode=watch",
@@ -26,7 +26,7 @@ export const NewsContainer: React.FunctionComponent<Props> = (props) => {
26
26
  }, [currentIndex, props.items])
27
27
 
28
28
  const startTimeout = () => {
29
- const showTime = props.data?.parameters?.showTime || 10
29
+ const showTime = props.data?.parameters?.showTime ?? 10
30
30
  const time = showTime * 1000
31
31
  timerRef.current = window.setTimeout(nextItem, time)
32
32
  }
@@ -37,39 +37,53 @@ export const NewsContainer: React.FunctionComponent<Props> = (props) => {
37
37
  setCurrentIndex(newIndex)
38
38
  }
39
39
 
40
- if (parameters.template === 'gradient') {
41
- return <TransitionGroup className='main-container' style={{
42
- backgroundColor: parameters.gradientBackgroundColor || 'red'
43
- }}>
44
- {item ?
45
- <CSSTransition key={item.id} classNames={parameters.animationType || 'fade'} timeout={(1750 / (animationSpeed || 1)) * 2}>
46
- <div className={'news-item-container'}>
47
- {
48
- <GradientItem parameters={parameters} item={item} />
49
- }
50
- </div>
51
- </CSSTransition>
52
- : <FormattedText text={defaultMessage || 'No hay cumpleaños para mostrar'} format={parameters.defaultMessageFormat} />
53
- }
54
- </TransitionGroup>
55
-
56
- } else {
57
- return <TransitionGroup className='main-container' style={{
40
+ const getContainerStyles = () => {
41
+ if (parameters.template === 'gradient') {
42
+ return { backgroundColor: parameters.gradientBackgroundColor || 'red' }
43
+ }
44
+ return {
58
45
  padding: parameters.padding,
59
46
  backgroundImage: parameters.background && `url("${downloadsPath}/${parameters.background.filename}")`
60
- }}>
61
- {item ?
62
- <CSSTransition key={item.id} classNames={parameters.animationType || 'fade'} timeout={(1750 / (animationSpeed || 1)) * 2}>
63
- <div className={'news-item-container'}>
64
- {parameters.template === 'gallery'
65
- ? <GalleryItem parameters={parameters} item={item} />
66
- : <StandardItem parameters={parameters} item={item} />
67
- }
68
- </div>
69
- </CSSTransition>
70
- :<FormattedText text={defaultMessage || 'No hay noticias para mostrar'} format={parameters.defaultMessageFormat} />
47
+ }
48
+ }
71
49
 
72
- }
73
- </TransitionGroup>
50
+ const renderNewsItem = (item: NewsItem) => {
51
+ if (parameters.template === 'gradient') {
52
+ return <GradientItem parameters={parameters} item={item} />
53
+ }
54
+ if (parameters.template === 'gallery') {
55
+ return <GalleryItem parameters={parameters} item={item} />
56
+ }
57
+ return <StandardItem parameters={parameters} item={item} />
58
+ }
59
+
60
+ if (props.items.length === 0 || !item) {
61
+ return (
62
+ <div className='main-container' style={getContainerStyles()}>
63
+ <div style={{
64
+ width: '100%',
65
+ height: '100%',
66
+ display: 'flex',
67
+ justifyContent: 'center',
68
+ alignItems: 'center'
69
+ }}>
70
+ <FormattedText text={defaultMessage || 'No hay noticias para mostrar'} format={parameters.defaultMessageFormat} />
71
+ </div>
72
+ </div>
73
+ )
74
74
  }
75
+
76
+ return (
77
+ <TransitionGroup className='main-container' style={getContainerStyles()}>
78
+ <CSSTransition
79
+ key={item.id}
80
+ classNames={parameters.animationType || 'fade'}
81
+ timeout={(1750 / (animationSpeed || 1)) * 2}
82
+ >
83
+ <div className={'news-item-container'}>
84
+ {renderNewsItem(item)}
85
+ </div>
86
+ </CSSTransition>
87
+ </TransitionGroup>
88
+ )
75
89
  }