@cooperco/cooper-component-library 0.1.132 → 0.1.134

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.
@@ -0,0 +1,81 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: function (migration) {
5
+ const tileContent = migration.editContentType('tileContent')
6
+
7
+ // Convert the shared Media field (API id `image`) from a single Link to an
8
+ // Array. VideoTile stores its video on this same field (Image | Video union
9
+ // since 0077), so the array must keep both content types. Existing entries
10
+ // are wrapped as a one-item list so Icon/Image/Video/stacked tiles keep
11
+ // their current media.
12
+ tileContent
13
+ .createField('images', {
14
+ name: 'Media',
15
+ type: 'Array',
16
+ required: false,
17
+ items: {
18
+ type: 'Link',
19
+ linkType: 'Entry',
20
+ validations: [{ linkContentType: ['image', 'video'] }],
21
+ },
22
+ })
23
+ .validations([{ size: { max: 10 } }])
24
+ tileContent.changeFieldControl('images', 'builtin', 'entryLinksEditor', {
25
+ helpText:
26
+ 'Single image or video for most tile types. For Image Stacked Animated tiles, add multiple square images to show a carousel.',
27
+ })
28
+ tileContent.moveField('images').beforeField('headline')
29
+
30
+ migration.transformEntries({
31
+ contentType: 'tileContent',
32
+ from: ['image'],
33
+ to: ['images'],
34
+ transformEntryForLocale: async (fromFields, currentLocale) => {
35
+ if (!fromFields.image || !fromFields.image[currentLocale]) {
36
+ return
37
+ }
38
+ return {
39
+ images: [fromFields.image[currentLocale]],
40
+ }
41
+ },
42
+ })
43
+
44
+ tileContent.deleteField('image')
45
+ },
46
+
47
+ // @ts-check
48
+ /** @type { import('contentful-migration').MigrationFunction } */
49
+ down: function (migration) {
50
+ const tileContent = migration.editContentType('tileContent')
51
+
52
+ tileContent.createField('image', {
53
+ name: 'Media',
54
+ type: 'Link',
55
+ linkType: 'Entry',
56
+ required: false,
57
+ validations: [{ linkContentType: ['image', 'video'] }],
58
+ })
59
+ tileContent.changeFieldControl('image', 'builtin', 'entryLinkEditor', {
60
+ helpText:
61
+ 'For Tile type image stacked animated, please use a square image.',
62
+ })
63
+ tileContent.moveField('image').beforeField('headline')
64
+
65
+ migration.transformEntries({
66
+ contentType: 'tileContent',
67
+ from: ['images'],
68
+ to: ['image'],
69
+ transformEntryForLocale: async (fromFields, currentLocale) => {
70
+ if (!fromFields.images || !fromFields.images[currentLocale]) {
71
+ return
72
+ }
73
+ return {
74
+ image: fromFields.images[currentLocale][0],
75
+ }
76
+ },
77
+ })
78
+
79
+ tileContent.deleteField('images')
80
+ },
81
+ }
@@ -0,0 +1,81 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: function (migration) {
5
+ const tileContent = migration.editContentType('tileContent')
6
+
7
+ // Convert the shared Media field (API id `image`) from a single Link to an
8
+ // Array. VideoTile stores its video on this same field (Image | Video union
9
+ // since 0077), so the array must keep both content types. Existing entries
10
+ // are wrapped as a one-item list so Icon/Image/Video/stacked tiles keep
11
+ // their current media.
12
+ tileContent
13
+ .createField('images', {
14
+ name: 'Media',
15
+ type: 'Array',
16
+ required: false,
17
+ items: {
18
+ type: 'Link',
19
+ linkType: 'Entry',
20
+ validations: [{ linkContentType: ['image', 'video'] }],
21
+ },
22
+ })
23
+ .validations([{ size: { max: 10 } }])
24
+ tileContent.changeFieldControl('images', 'builtin', 'entryLinksEditor', {
25
+ helpText:
26
+ 'Single image or video for most tile types. For Image Stacked Animated tiles, add multiple square images to show a carousel.',
27
+ })
28
+ tileContent.moveField('images').beforeField('headline')
29
+
30
+ migration.transformEntries({
31
+ contentType: 'tileContent',
32
+ from: ['image'],
33
+ to: ['images'],
34
+ transformEntryForLocale: async (fromFields, currentLocale) => {
35
+ if (!fromFields.image || !fromFields.image[currentLocale]) {
36
+ return
37
+ }
38
+ return {
39
+ images: [fromFields.image[currentLocale]],
40
+ }
41
+ },
42
+ })
43
+
44
+ tileContent.deleteField('image')
45
+ },
46
+
47
+ // @ts-check
48
+ /** @type { import('contentful-migration').MigrationFunction } */
49
+ down: function (migration) {
50
+ const tileContent = migration.editContentType('tileContent')
51
+
52
+ tileContent.createField('image', {
53
+ name: 'Media',
54
+ type: 'Link',
55
+ linkType: 'Entry',
56
+ required: false,
57
+ validations: [{ linkContentType: ['image', 'video'] }],
58
+ })
59
+ tileContent.changeFieldControl('image', 'builtin', 'entryLinkEditor', {
60
+ helpText:
61
+ 'For Tile type image stacked animated, please use a square image.',
62
+ })
63
+ tileContent.moveField('image').beforeField('headline')
64
+
65
+ migration.transformEntries({
66
+ contentType: 'tileContent',
67
+ from: ['images'],
68
+ to: ['image'],
69
+ transformEntryForLocale: async (fromFields, currentLocale) => {
70
+ if (!fromFields.images || !fromFields.images[currentLocale]) {
71
+ return
72
+ }
73
+ return {
74
+ image: fromFields.images[currentLocale][0],
75
+ }
76
+ },
77
+ })
78
+
79
+ tileContent.deleteField('images')
80
+ },
81
+ }
@@ -130,12 +130,14 @@ export const tileContentFragment = gql `
130
130
  }
131
131
  }
132
132
  }
133
- image {
134
- ... on Image {
135
- ...imageFragment
136
- }
137
- ... on Video {
138
- ...videoFragment
133
+ imagesCollection(limit: 10) {
134
+ items {
135
+ ... on Image {
136
+ ...imageFragment
137
+ }
138
+ ... on Video {
139
+ ...videoFragment
140
+ }
139
141
  }
140
142
  }
141
143
  backgroundColor
@@ -139,12 +139,14 @@ export const tileContentFragment: DocumentNode = gql`
139
139
  }
140
140
  }
141
141
  }
142
- image {
143
- ... on Image {
144
- ...imageFragment
145
- }
146
- ... on Video {
147
- ...videoFragment
142
+ imagesCollection(limit: 10) {
143
+ items {
144
+ ... on Image {
145
+ ...imageFragment
146
+ }
147
+ ... on Video {
148
+ ...videoFragment
149
+ }
148
150
  }
149
151
  }
150
152
  backgroundColor
@@ -139,12 +139,14 @@ export const tileContentFragment: DocumentNode = gql`
139
139
  }
140
140
  }
141
141
  }
142
- image {
143
- ... on Image {
144
- ...imageFragment
145
- }
146
- ... on Video {
147
- ...videoFragment
142
+ imagesCollection(limit: 10) {
143
+ items {
144
+ ... on Image {
145
+ ...imageFragment
146
+ }
147
+ ... on Video {
148
+ ...videoFragment
149
+ }
148
150
  }
149
151
  }
150
152
  backgroundColor
@@ -0,0 +1,81 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: function (migration) {
5
+ const tileContent = migration.editContentType('tileContent')
6
+
7
+ // Convert the shared Media field (API id `image`) from a single Link to an
8
+ // Array. VideoTile stores its video on this same field (Image | Video union
9
+ // since 0077), so the array must keep both content types. Existing entries
10
+ // are wrapped as a one-item list so Icon/Image/Video/stacked tiles keep
11
+ // their current media.
12
+ tileContent
13
+ .createField('images', {
14
+ name: 'Media',
15
+ type: 'Array',
16
+ required: false,
17
+ items: {
18
+ type: 'Link',
19
+ linkType: 'Entry',
20
+ validations: [{ linkContentType: ['image', 'video'] }],
21
+ },
22
+ })
23
+ .validations([{ size: { max: 10 } }])
24
+ tileContent.changeFieldControl('images', 'builtin', 'entryLinksEditor', {
25
+ helpText:
26
+ 'Single image or video for most tile types. For Image Stacked Animated tiles, add multiple square images to show a carousel.',
27
+ })
28
+ tileContent.moveField('images').beforeField('headline')
29
+
30
+ migration.transformEntries({
31
+ contentType: 'tileContent',
32
+ from: ['image'],
33
+ to: ['images'],
34
+ transformEntryForLocale: async (fromFields, currentLocale) => {
35
+ if (!fromFields.image || !fromFields.image[currentLocale]) {
36
+ return
37
+ }
38
+ return {
39
+ images: [fromFields.image[currentLocale]],
40
+ }
41
+ },
42
+ })
43
+
44
+ tileContent.deleteField('image')
45
+ },
46
+
47
+ // @ts-check
48
+ /** @type { import('contentful-migration').MigrationFunction } */
49
+ down: function (migration) {
50
+ const tileContent = migration.editContentType('tileContent')
51
+
52
+ tileContent.createField('image', {
53
+ name: 'Media',
54
+ type: 'Link',
55
+ linkType: 'Entry',
56
+ required: false,
57
+ validations: [{ linkContentType: ['image', 'video'] }],
58
+ })
59
+ tileContent.changeFieldControl('image', 'builtin', 'entryLinkEditor', {
60
+ helpText:
61
+ 'For Tile type image stacked animated, please use a square image.',
62
+ })
63
+ tileContent.moveField('image').beforeField('headline')
64
+
65
+ migration.transformEntries({
66
+ contentType: 'tileContent',
67
+ from: ['images'],
68
+ to: ['image'],
69
+ transformEntryForLocale: async (fromFields, currentLocale) => {
70
+ if (!fromFields.images || !fromFields.images[currentLocale]) {
71
+ return
72
+ }
73
+ return {
74
+ image: fromFields.images[currentLocale][0],
75
+ }
76
+ },
77
+ })
78
+
79
+ tileContent.deleteField('images')
80
+ },
81
+ }
@@ -139,12 +139,14 @@ export const tileContentFragment: DocumentNode = gql`
139
139
  }
140
140
  }
141
141
  }
142
- image {
143
- ... on Image {
144
- ...imageFragment
145
- }
146
- ... on Video {
147
- ...videoFragment
142
+ imagesCollection(limit: 10) {
143
+ items {
144
+ ... on Image {
145
+ ...imageFragment
146
+ }
147
+ ... on Video {
148
+ ...videoFragment
149
+ }
148
150
  }
149
151
  }
150
152
  backgroundColor
@@ -0,0 +1,81 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: function (migration) {
5
+ const tileContent = migration.editContentType('tileContent')
6
+
7
+ // Convert the shared Media field (API id `image`) from a single Link to an
8
+ // Array. VideoTile stores its video on this same field (Image | Video union
9
+ // since 0077), so the array must keep both content types. Existing entries
10
+ // are wrapped as a one-item list so Icon/Image/Video/stacked tiles keep
11
+ // their current media.
12
+ tileContent
13
+ .createField('images', {
14
+ name: 'Media',
15
+ type: 'Array',
16
+ required: false,
17
+ items: {
18
+ type: 'Link',
19
+ linkType: 'Entry',
20
+ validations: [{ linkContentType: ['image', 'video'] }],
21
+ },
22
+ })
23
+ .validations([{ size: { max: 10 } }])
24
+ tileContent.changeFieldControl('images', 'builtin', 'entryLinksEditor', {
25
+ helpText:
26
+ 'Single image or video for most tile types. For Image Stacked Animated tiles, add multiple square images to show a carousel.',
27
+ })
28
+ tileContent.moveField('images').beforeField('headline')
29
+
30
+ migration.transformEntries({
31
+ contentType: 'tileContent',
32
+ from: ['image'],
33
+ to: ['images'],
34
+ transformEntryForLocale: async (fromFields, currentLocale) => {
35
+ if (!fromFields.image || !fromFields.image[currentLocale]) {
36
+ return
37
+ }
38
+ return {
39
+ images: [fromFields.image[currentLocale]],
40
+ }
41
+ },
42
+ })
43
+
44
+ tileContent.deleteField('image')
45
+ },
46
+
47
+ // @ts-check
48
+ /** @type { import('contentful-migration').MigrationFunction } */
49
+ down: function (migration) {
50
+ const tileContent = migration.editContentType('tileContent')
51
+
52
+ tileContent.createField('image', {
53
+ name: 'Media',
54
+ type: 'Link',
55
+ linkType: 'Entry',
56
+ required: false,
57
+ validations: [{ linkContentType: ['image', 'video'] }],
58
+ })
59
+ tileContent.changeFieldControl('image', 'builtin', 'entryLinkEditor', {
60
+ helpText:
61
+ 'For Tile type image stacked animated, please use a square image.',
62
+ })
63
+ tileContent.moveField('image').beforeField('headline')
64
+
65
+ migration.transformEntries({
66
+ contentType: 'tileContent',
67
+ from: ['images'],
68
+ to: ['image'],
69
+ transformEntryForLocale: async (fromFields, currentLocale) => {
70
+ if (!fromFields.images || !fromFields.images[currentLocale]) {
71
+ return
72
+ }
73
+ return {
74
+ image: fromFields.images[currentLocale][0],
75
+ }
76
+ },
77
+ })
78
+
79
+ tileContent.deleteField('images')
80
+ },
81
+ }