@vixoniccom/news-internal 0.4.21-dev.17 → 0.4.21-dev.19

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.17",
11
+ "version": "0.4.21-dev.19",
12
12
  "scripts": {
13
13
  "prepublish": "vixonic-module-packager --mode=build",
14
14
  "watch": "vixonic-module-packager --mode=watch",
@@ -10,16 +10,37 @@ export type Props = {
10
10
 
11
11
  export const App: React.FunctionComponent<Props> = ({ data }) => {
12
12
  const [news, setNews] = useState<NewsItem[]>([])
13
+
14
+ const getPrefixBySize = (n: any, size: string, prefix: string): string => {
15
+ const prefixMap: { [key: string]: string } = {
16
+ 'short': n[`${prefix}Short`],
17
+ 'medium': n[`${prefix}Medium`],
18
+ 'large': n[`${prefix}Large`],
19
+ 'extra-large': n[`${prefix}ExtraLarge`]
20
+ }
21
+ return prefixMap[size] || n[`${prefix}Medium`] || ''
22
+ }
13
23
 
14
24
  const parseNews = (data?: VixonicData): NewsItem[] => {
15
25
  if (!data) return []
16
- const { news } = data.parameters
26
+ const { news, newsSizeSelect } = data.parameters
17
27
  const parsedNews = news?.map((n) => {
18
28
  const { image, ...rest } = n
19
29
  let parsedImage
20
30
  const qrUrl = n.qrCodeUrl
21
31
  if (image?.filename) parsedImage = `${data.downloadsPath}/${image.filename}`
22
- return { ...rest, image: parsedImage, id: uuid(), qrCodeUrl: qrUrl }
32
+
33
+ let title = getPrefixBySize(n, newsSizeSelect || 'medium', 'title')
34
+ let description = getPrefixBySize(n, newsSizeSelect || 'medium', 'description')
35
+
36
+ return {
37
+ ...rest,
38
+ title,
39
+ description,
40
+ image: parsedImage,
41
+ id: uuid(),
42
+ qrCodeUrl: qrUrl
43
+ }
23
44
  }).filter((n) => {
24
45
  const { expirationDate } = n
25
46
  const today = dayjs()
@@ -18,7 +18,7 @@ export const TextContainer: React.FunctionComponent<Props> = (props) => {
18
18
  height: '100%',
19
19
  flex: 1
20
20
  }}>
21
- {parameters.titleEnabled && <FormattedText text={item.titleShort || item.titleMedium || item.titleLarge || item.titleExtraLarge || ''} unit={'px'}
21
+ {parameters.titleEnabled && <FormattedText text={item.title || ''} unit={'px'}
22
22
  format={parameters.titleFormat} lineHeight={parameters.titleLineHeight}
23
23
  style={
24
24
  (parameters.textSeparation && parameters.titleEnabled && parameters.descriptionEnabled)
@@ -26,7 +26,7 @@ export const TextContainer: React.FunctionComponent<Props> = (props) => {
26
26
  : undefined
27
27
  } multiline />
28
28
  }
29
- {parameters.descriptionEnabled && <FormattedHtmlText html={item.descriptionShort || item.descriptionMedium || item.descriptionLarge || item.descriptionExtraLarge || ''} unit={'px'}
29
+ {parameters.descriptionEnabled && <FormattedHtmlText html={item.description || ''} unit={'px'}
30
30
  format={parameters.descriptionFormat} lineHeight={parameters.descriptionLineHeight}
31
31
  defaults={{ fontSize: 10, fontColor: 'black', alignment: 'left' }}
32
32
  multiline />
package/src/global.d.ts CHANGED
@@ -1,13 +1,7 @@
1
1
  type NewsItem = {
2
2
  id: string
3
- titleShort?: string
4
- descriptionShort?: string
5
- titleMedium?: string
6
- descriptionMedium?: string
7
- titleLarge?: string
8
- descriptionLarge?: string
9
- titleExtraLarge?: string
10
- descriptionExtraLarge?: string
3
+ title?: string
4
+ description?: string
11
5
  image?: string
12
6
  qrCodeUrl?: string
13
7
  qrCodeTitle?: string