@atlaskit/editor-palette 1.4.3 → 1.5.0

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.
@@ -1,5 +1,6 @@
1
1
  // This import will be stripped on build
2
2
  // eslint-disable-next-line import/no-extraneous-dependencies
3
+ import { getTokenValue } from '@atlaskit/tokens';
3
4
 
4
5
  /**
5
6
  * This takes an adf hex color and returns a matching background palette
@@ -18,7 +19,7 @@
18
19
  * The exact output of this function is an implementation detail and should only be used when rendering
19
20
  * content to the user, on a client with a matching major version of `@atlaskit/tokens`.
20
21
  * - **DO NOT**: store the output of these functions in any user-generated content or back-end.
21
- * - **DO**: store the ADF hex color, and use these utilities at render time to display the themed version of the color
22
+ * - **DO**: store the ADF hex color, and use these utilities at render time to display the themed version of the color.
22
23
  */
23
24
  export function hexToEditorBackgroundPaletteColor(hexColor) {
24
25
  // Ts ignore used to allow use of conditional return type
@@ -27,37 +28,51 @@ export function hexToEditorBackgroundPaletteColor(hexColor) {
27
28
  const tokenData = editorBackgroundPalette[hexColor.toUpperCase()];
28
29
  return tokenData ? tokenData.token : undefined;
29
30
  }
30
- export function hexToEditorBackgroundPaletteColorTokenName(hexColor) {
31
+
32
+ /**
33
+ * Takes an ADF hex color and returns the rendered hex code for the associated background palette design token using getTokenValue.
34
+ * If the provided color does not exist in the Editor color palette, this function returns undefined.
35
+ *
36
+ * This should only be used when rendering content where CSS variables are not feasible, such as a non-CSS environment
37
+ * or to enable cross-app copy/paste.
38
+ *
39
+ * WARNING: If the rendered theme changes (such as from light -> dark mode) the value returned here will no longer match
40
+ * the surrounding UI and will need to be re-fetched.
41
+ * In addition, the values of tokens will differ between themes and the value for a given theme can and will change.
42
+ * - **DO NOT**: store the output of these functions in any user-generated content or back-end.
43
+ * - **DO**: store the ADF hex color, and use these utilities at render time to display the themed version of the color.
44
+ */
45
+ export function hexToEditorBackgroundPaletteRawValue(hexColor) {
31
46
  // Ts ignore used to allow use of conditional return type
32
47
  // (preferencing better type on consumption over safety in implementation)
33
48
  // @ts-ignore
34
49
  const tokenData = editorBackgroundPalette[hexColor.toUpperCase()];
35
- return tokenData ? tokenData.tokenName : undefined;
50
+ return tokenData ? tokenData.getValue(hexColor) : undefined;
36
51
  }
37
52
  // Colors taken from
38
53
  // https://hello.atlassian.net/wiki/spaces/DST/pages/1790979421/DSTRFC-002+-+Shifting+Editor+s+color+palette+to+design+tokens
39
-
40
- // values are asserted to improve generated type declarations
41
- // Modified structure as having tokenName, token
42
- // and possibly editorColorName in future will make it
43
- // simpler to link everything together.
54
+ /**
55
+ * Values are asserted to improve generated type declarations
56
+ * Using object structure as getValue() function needed for table values, and other
57
+ * properties may be needed in the future.
58
+ */
44
59
  export const editorBackgroundPalette = {
45
60
  // blue
46
61
  /** blue - light */
47
62
  ['#DEEBFF']: {
48
- tokenName: 'color.background.accent.blue.subtlest',
63
+ getValue: fallback => getTokenValue('color.background.accent.blue.subtlest', fallback),
49
64
  token: "var(--ds-background-accent-blue-subtlest, #DEEBFF)"
50
65
  },
51
66
  // source for hex code was legacy token B50
52
67
  /** blue - medium */
53
68
  ['#B3D4FF']: {
54
- tokenName: 'color.background.accent.blue.subtler',
69
+ getValue: fallback => getTokenValue('color.background.accent.blue.subtler', fallback),
55
70
  token: "var(--ds-background-accent-blue-subtler, #B3D4FF)"
56
71
  },
57
72
  // source for hex code was legacy token B75
58
73
  /** blue - strong */
59
74
  ['#4C9AFF']: {
60
- tokenName: 'color.background.accent.blue.subtle',
75
+ getValue: fallback => getTokenValue('color.background.accent.blue.subtle', fallback),
61
76
  token: "var(--ds-background-accent-blue-subtle, #4C9AFF)"
62
77
  },
63
78
  // source for hex code was legacy token B100
@@ -65,117 +80,114 @@ export const editorBackgroundPalette = {
65
80
  // teal
66
81
  /** teal - light */
67
82
  ['#E6FCFF']: {
68
- tokenName: 'color.background.accent.teal.subtlest',
83
+ getValue: fallback => getTokenValue('color.background.accent.teal.subtlest', fallback),
69
84
  token: "var(--ds-background-accent-teal-subtlest, #E6FCFF)" // source for hex code was legacy token T50,
70
85
  },
71
86
 
72
87
  /** teal - medium */
73
88
  ['#B3F5FF']: {
74
- tokenName: 'color.background.accent.teal.subtler',
89
+ getValue: fallback => getTokenValue('color.background.accent.teal.subtler', fallback),
75
90
  token: "var(--ds-background-accent-teal-subtler, #B3F5FF)" // source for hex code was legacy token T75,
76
91
  },
77
92
 
78
93
  /** teal - strong */
79
94
  ['#79E2F2']: {
80
- tokenName: 'color.background.accent.teal.subtle',
95
+ getValue: fallback => getTokenValue('color.background.accent.teal.subtle', fallback),
81
96
  token: "var(--ds-background-accent-teal-subtle, #79E2F2)" // source for hex code was legacy token T100,
82
97
  },
83
98
 
84
99
  // green
85
100
  /** green - light */
86
101
  ['#E3FCEF']: {
87
- tokenName: 'color.background.accent.green.subtlest',
102
+ getValue: fallback => getTokenValue('color.background.accent.green.subtlest', fallback),
88
103
  token: "var(--ds-background-accent-green-subtlest, #E3FCEF)" // source for hex code was legacy token G50,
89
104
  },
90
105
 
91
106
  /** green - medium */
92
107
  ['#ABF5D1']: {
93
- tokenName: 'color.background.accent.green.subtler',
108
+ getValue: fallback => getTokenValue('color.background.accent.green.subtler', fallback),
94
109
  token: "var(--ds-background-accent-green-subtler, #ABF5D1)" // source for hex code was legacy token G75,
95
110
  },
96
111
 
97
112
  /** green - strong */
98
113
  ['#57D9A3']: {
99
- tokenName: 'color.background.accent.green.subtle',
114
+ getValue: fallback => getTokenValue('color.background.accent.green.subtle', fallback),
100
115
  token: "var(--ds-background-accent-green-subtle, #57D9A3)" // source for hex code was legacy token G200,
101
116
  },
102
117
 
103
118
  // yellowOrange
104
119
  /** yellowOrange - light */
105
120
  ['#FFFAE6']: {
106
- tokenName: 'color.background.accent.yellow.subtlest',
121
+ getValue: fallback => getTokenValue('color.background.accent.yellow.subtlest', fallback),
107
122
  token: "var(--ds-background-accent-yellow-subtlest, #FFFAE6)" // source for hex code was legacy token Y50,
108
123
  },
109
124
 
110
125
  /** yellowOrange - medium */
111
126
  ['#FFF0B3']: {
112
- tokenName: 'color.background.accent.yellow.subtler',
127
+ getValue: fallback => getTokenValue('color.background.accent.yellow.subtler', fallback),
113
128
  token: "var(--ds-background-accent-yellow-subtler, #FFF0B3)" // source for hex code was legacy token Y75,
114
129
  },
115
130
 
116
131
  /** yellowOrange - strong */
117
132
  ['#FFC400']: {
118
- tokenName: 'color.background.accent.orange.subtle',
133
+ getValue: fallback => getTokenValue('color.background.accent.orange.subtle', fallback),
119
134
  token: "var(--ds-background-accent-orange-subtle, #FFC400)" // source for hex code was legacy token Y200,
120
135
  },
121
136
 
122
137
  // red
123
138
  /** red - light */
124
139
  ['#FFEBE6']: {
125
- tokenName: 'color.background.accent.red.subtlest',
140
+ getValue: fallback => getTokenValue('color.background.accent.red.subtlest', fallback),
126
141
  token: "var(--ds-background-accent-red-subtlest, #FFEBE6)" // source for hex code was legacy token R50,
127
142
  },
128
143
 
129
144
  /** red - medium */
130
145
  ['#FFBDAD']: {
131
- tokenName: 'color.background.accent.red.subtler',
146
+ getValue: fallback => getTokenValue('color.background.accent.red.subtler', fallback),
132
147
  token: "var(--ds-background-accent-red-subtler, #FFBDAD)" // source for hex code was legacy token R75,
133
148
  },
134
149
 
135
150
  /** red - strong */
136
151
  ['#FF8F73']: {
137
- tokenName: 'color.background.accent.red.subtle',
152
+ getValue: fallback => getTokenValue('color.background.accent.red.subtle', fallback),
138
153
  token: "var(--ds-background-accent-red-subtle, #FF8F73)" // source for hex code was legacy token R100,
139
154
  },
140
155
 
141
156
  // purple
142
157
  /** purple - light */
143
158
  ['#EAE6FF']: {
144
- tokenName: 'color.background.accent.purple.subtlest',
159
+ getValue: fallback => getTokenValue('color.background.accent.purple.subtlest', fallback),
145
160
  token: "var(--ds-background-accent-purple-subtlest, #EAE6FF)" // source for hex code was legacy token P50,
146
161
  },
147
162
 
148
163
  /** purple - medium */
149
164
  ['#C0B6F2']: {
150
- tokenName: 'color.background.accent.purple.subtler',
165
+ getValue: fallback => getTokenValue('color.background.accent.purple.subtler', fallback),
151
166
  token: "var(--ds-background-accent-purple-subtler, #C0B6F2)" // source for hex code was legacy token P75,
152
167
  },
153
168
 
154
169
  /** purple - strong */
155
170
  ['#998DD9']: {
156
- tokenName: 'color.background.accent.purple.subtle',
171
+ getValue: fallback => getTokenValue('color.background.accent.purple.subtle', fallback),
157
172
  token: "var(--ds-background-accent-purple-subtle, #998DD9)" // source for hex code was legacy token P100,
158
173
  },
159
174
 
160
175
  // whiteGray
161
176
  /** whiteGray - light */
162
177
  ['#FFFFFF']: {
163
- tokenName: 'elevation.surface',
178
+ getValue: fallback => getTokenValue('elevation.surface', fallback),
164
179
  token: "var(--ds-surface, #FFFFFF)" // source for hex code was legacy token N0,
165
180
  },
166
181
 
167
182
  /** whiteGray - medium */
168
183
  ['#F4F5F7']: {
169
- tokenName: 'color.background.accent.gray.subtlest',
184
+ getValue: fallback => getTokenValue('color.background.accent.gray.subtlest', fallback),
170
185
  token: "var(--ds-background-accent-gray-subtlest, #F4F5F7)" // source for hex code was legacy token N20,
171
186
  },
172
187
 
173
188
  /** whiteGray - strong */
174
189
  ['#B3BAC5']: {
175
- tokenName: 'color.background.accent.gray.subtle',
190
+ getValue: fallback => getTokenValue('color.background.accent.gray.subtle', fallback),
176
191
  token: "var(--ds-background-accent-gray-subtle, #B3BAC5)" // source for hex code was legacy token N60,
177
192
  }
178
- };
179
-
180
- const backgroundPaletteKeys = Object.keys(editorBackgroundPalette);
181
- const tokenNames = backgroundPaletteKeys.map(hexCode => editorBackgroundPalette[hexCode].tokenName);
193
+ };
@@ -1,4 +1,4 @@
1
- export { hexToEditorBackgroundPaletteColor, hexToEditorBackgroundPaletteColorTokenName } from './background';
1
+ export { hexToEditorBackgroundPaletteColor, hexToEditorBackgroundPaletteRawValue } from './background';
2
2
  export { hexToEditorBorderPaletteColor } from './border';
3
3
  export { hexToEditorTextPaletteColor } from './text';
4
- export { hexToEditorTableChartsPaletteColor, hexToEditorTableChartsPaletteColorTokenName } from './table-charts';
4
+ export { hexToEditorTableChartsPaletteColor, hexToEditorTableChartsPaletteRawValue } from './table-charts';
@@ -1,5 +1,6 @@
1
1
  // This import will be stripped on build
2
2
  // eslint-disable-next-line import/no-extraneous-dependencies
3
+ import { getTokenValue } from '@atlaskit/tokens';
3
4
 
4
5
  /**
5
6
  * This takes an adf hex color and returns a matching chart palette
@@ -27,12 +28,26 @@ export function hexToEditorTableChartsPaletteColor(hexColor) {
27
28
  const tokenData = editorTableChartsPalette[hexColor.toUpperCase()];
28
29
  return tokenData ? tokenData.token : undefined;
29
30
  }
30
- export function hexToEditorTableChartsPaletteColorTokenName(hexColor) {
31
+
32
+ /**
33
+ * Takes an ADF hex color and returns the rendered hex code for the associated chart palette design token using getTokenValue.
34
+ * If the provided color does not exist in the Editor color palette, this function returns undefined.
35
+ *
36
+ * This should only be used when rendering content where CSS variables are not feasible, such as a non-CSS environment
37
+ * or to enable cross-app copy/paste.
38
+ *
39
+ * WARNING: If the rendered theme changes (such as from light -> dark mode) the value returned here will no longer match
40
+ * the surrounding UI and will need to be re-fetched.
41
+ * In addition, the values of tokens will differ between themes and the value for a given theme can and will change.
42
+ * - **DO NOT**: store the output of these functions in any user-generated content or back-end.
43
+ * - **DO**: store the ADF hex color, and use these utilities at render time to display the themed version of the color.
44
+ */
45
+ export function hexToEditorTableChartsPaletteRawValue(hexColor) {
31
46
  // Ts ignore used to allow use of conditional return type
32
47
  // (preferencing better type on consumption over safety in implementation)
33
48
  // @ts-ignore
34
49
  const tokenData = editorTableChartsPalette[hexColor.toUpperCase()];
35
- return tokenData ? tokenData.tokenName : undefined;
50
+ return tokenData ? tokenData.getValue(hexColor) : undefined;
36
51
  }
37
52
  // Colors taken from
38
53
  // https://hello.atlassian.net/wiki/spaces/DST/pages/1790979421/DSTRFC-002+-+Shifting+Editor+s+color+palette+to+design+tokens
@@ -49,149 +64,147 @@ export function hexToEditorTableChartsPaletteColorTokenName(hexColor) {
49
64
  */
50
65
  const editorTableChartsPalette = {
51
66
  ['#7AB2FF']: {
52
- tokenName: 'color.background.accent.blue.subtle',
67
+ getValue: fallback => getTokenValue('color.background.accent.blue.subtle', fallback),
53
68
  token: "var(--ds-background-accent-blue-subtle, #7AB2FF)"
54
69
  },
55
70
  ['#60C6D2']: {
56
- tokenName: 'color.background.accent.teal.subtle',
71
+ getValue: fallback => getTokenValue('color.background.accent.teal.subtle', fallback),
57
72
  token: "var(--ds-background-accent-teal-subtle, #60C6D2)"
58
73
  },
59
74
  ['#6BE1B0']: {
60
- tokenName: 'color.background.accent.green.subtle',
75
+ getValue: fallback => getTokenValue('color.background.accent.green.subtle', fallback),
61
76
  token: "var(--ds-background-accent-green-subtle, #6BE1B0)"
62
77
  },
63
78
  ['#FFDB57']: {
64
- tokenName: 'color.background.accent.yellow.subtle',
79
+ getValue: fallback => getTokenValue('color.background.accent.yellow.subtle', fallback),
65
80
  token: "var(--ds-background-accent-yellow-subtle, #FFDB57)"
66
81
  },
67
82
  ['#FAA53D']: {
68
- tokenName: 'color.background.accent.orange.subtle',
83
+ getValue: fallback => getTokenValue('color.background.accent.orange.subtle', fallback),
69
84
  token: "var(--ds-background-accent-orange-subtle, #FAA53D)"
70
85
  },
71
86
  ['#FF8F73']: {
72
- tokenName: 'color.background.accent.red.subtle',
87
+ getValue: fallback => getTokenValue('color.background.accent.red.subtle', fallback),
73
88
  token: "var(--ds-background-accent-red-subtle, #FF8F73)"
74
89
  },
75
90
  ['#E774BB']: {
76
- tokenName: 'color.background.accent.magenta.subtle',
91
+ getValue: fallback => getTokenValue('color.background.accent.magenta.subtle', fallback),
77
92
  token: "var(--ds-background-accent-magenta-subtle, #E774BB)"
78
93
  },
79
94
  ['#B5A7FB']: {
80
- tokenName: 'color.background.accent.purple.subtle',
95
+ getValue: fallback => getTokenValue('color.background.accent.purple.subtle', fallback),
81
96
  token: "var(--ds-background-accent-purple-subtle, #B5A7FB)"
82
97
  },
83
98
  ['#8993A5']: {
84
- tokenName: 'color.background.accent.gray.subtler',
99
+ getValue: fallback => getTokenValue('color.background.accent.gray.subtler', fallback),
85
100
  token: "var(--ds-background-accent-gray-subtler, #8993A5)"
86
101
  },
87
102
  ['#247FFF']: {
88
- tokenName: 'color.chart.blue.bold',
103
+ getValue: fallback => getTokenValue('color.chart.blue.bold', fallback),
89
104
  token: "var(--ds-chart-blue-bold, #247FFF)"
90
105
  },
91
106
  ['#1D9AAA']: {
92
- tokenName: 'color.chart.teal.bold',
107
+ getValue: fallback => getTokenValue('color.chart.teal.bold', fallback),
93
108
  token: "var(--ds-chart-teal-bold, #1D9AAA)"
94
109
  },
95
110
  ['#23A971']: {
96
- tokenName: 'color.chart.green.bold',
111
+ getValue: fallback => getTokenValue('color.chart.green.bold', fallback),
97
112
  token: "var(--ds-chart-green-bold, #23A971)"
98
113
  },
99
114
  ['#FFBE33']: {
100
- tokenName: 'color.chart.yellow.bold',
115
+ getValue: fallback => getTokenValue('color.chart.yellow.bold', fallback),
101
116
  token: "var(--ds-chart-yellow-bold, #FFBE33)"
102
117
  },
103
118
  ['#D97008']: {
104
- tokenName: 'color.chart.orange.bold',
119
+ getValue: fallback => getTokenValue('color.chart.orange.bold', fallback),
105
120
  token: "var(--ds-chart-orange-bold, #D97008)"
106
121
  },
107
122
  ['#FC552C']: {
108
- tokenName: 'color.chart.red.bold',
123
+ getValue: fallback => getTokenValue('color.chart.red.bold', fallback),
109
124
  token: "var(--ds-chart-red-bold, #FC552C)"
110
125
  },
111
126
  ['#DA62AC']: {
112
- tokenName: 'color.chart.magenta.bold',
127
+ getValue: fallback => getTokenValue('color.chart.magenta.bold', fallback),
113
128
  token: "var(--ds-chart-magenta-bold, #DA62AC)"
114
129
  },
115
130
  ['#8B77EE']: {
116
- tokenName: 'color.chart.purple.bold',
131
+ getValue: fallback => getTokenValue('color.chart.purple.bold', fallback),
117
132
  token: "var(--ds-chart-purple-bold, #8B77EE)"
118
133
  },
119
134
  ['#8590A2']: {
120
- tokenName: 'color.chart.gray.bold',
135
+ getValue: fallback => getTokenValue('color.chart.gray.bold', fallback),
121
136
  token: "var(--ds-chart-gray-bold, #8590A2)"
122
137
  },
123
138
  ['#0055CC']: {
124
- tokenName: 'color.chart.blue.bolder',
139
+ getValue: fallback => getTokenValue('color.chart.blue.bolder', fallback),
125
140
  token: "var(--ds-chart-blue-bolder, #0055CC)"
126
141
  },
127
142
  ['#1D7F8C']: {
128
- tokenName: 'color.chart.teal.bolder',
143
+ getValue: fallback => getTokenValue('color.chart.teal.bolder', fallback),
129
144
  token: "var(--ds-chart-teal-bolder, #1D7F8C)"
130
145
  },
131
146
  ['#177D52']: {
132
- tokenName: 'color.chart.green.bolder',
147
+ getValue: fallback => getTokenValue('color.chart.green.bolder', fallback),
133
148
  token: "var(--ds-chart-green-bolder, #177D52)"
134
149
  },
135
150
  ['#FF9D00']: {
136
- tokenName: 'color.chart.yellow.bolder',
151
+ getValue: fallback => getTokenValue('color.chart.yellow.bolder', fallback),
137
152
  token: "var(--ds-chart-yellow-bolder, #FF9D00)"
138
153
  },
139
154
  ['#B65C02']: {
140
- tokenName: 'color.chart.orange.bolder',
155
+ getValue: fallback => getTokenValue('color.chart.orange.bolder', fallback),
141
156
  token: "var(--ds-chart-orange-bolder, #B65C02)"
142
157
  },
143
158
  ['#D32D03']: {
144
- tokenName: 'color.chart.red.bolder',
159
+ getValue: fallback => getTokenValue('color.chart.red.bolder', fallback),
145
160
  token: "var(--ds-chart-red-bolder, #D32D03)"
146
161
  },
147
162
  ['#CD519D']: {
148
- tokenName: 'color.chart.magenta.bolder',
163
+ getValue: fallback => getTokenValue('color.chart.magenta.bolder', fallback),
149
164
  token: "var(--ds-chart-magenta-bolder, #CD519D)"
150
165
  },
151
166
  ['#5A43D0']: {
152
- tokenName: 'color.chart.purple.bolder',
167
+ getValue: fallback => getTokenValue('color.chart.purple.bolder', fallback),
153
168
  token: "var(--ds-chart-purple-bolder, #5A43D0)"
154
169
  },
155
170
  ['#758195']: {
156
- tokenName: 'color.chart.gray.bolder',
171
+ getValue: fallback => getTokenValue('color.chart.gray.bolder', fallback),
157
172
  token: "var(--ds-chart-gray-bolder, #758195)"
158
173
  },
159
174
  ['#003884']: {
160
- tokenName: 'color.chart.blue.boldest',
175
+ getValue: fallback => getTokenValue('color.chart.blue.boldest', fallback),
161
176
  token: "var(--ds-chart-blue-boldest, #003884)"
162
177
  },
163
178
  ['#206B74']: {
164
- tokenName: 'color.chart.teal.boldest',
179
+ getValue: fallback => getTokenValue('color.chart.teal.boldest', fallback),
165
180
  token: "var(--ds-chart-teal-boldest, #206B74)"
166
181
  },
167
182
  ['#055C3F']: {
168
- tokenName: 'color.chart.green.boldest',
183
+ getValue: fallback => getTokenValue('color.chart.green.boldest', fallback),
169
184
  token: "var(--ds-chart-green-boldest, #055C3F)"
170
185
  },
171
186
  ['#946104']: {
172
- tokenName: 'color.chart.yellow.boldest',
187
+ getValue: fallback => getTokenValue('color.chart.yellow.boldest', fallback),
173
188
  token: "var(--ds-chart-yellow-boldest, #946104)"
174
189
  },
175
190
  ['#974F0C']: {
176
- tokenName: 'color.chart.orange.boldest',
191
+ getValue: fallback => getTokenValue('color.chart.orange.boldest', fallback),
177
192
  token: "var(--ds-chart-orange-boldest, #974F0C)"
178
193
  },
179
194
  ['#A32000']: {
180
- tokenName: 'color.chart.red.boldest',
195
+ getValue: fallback => getTokenValue('color.chart.red.boldest', fallback),
181
196
  token: "var(--ds-chart-red-boldest, #A32000)"
182
197
  },
183
198
  ['#943D73']: {
184
- tokenName: 'color.chart.magenta.boldest',
199
+ getValue: fallback => getTokenValue('color.chart.magenta.boldest', fallback),
185
200
  token: "var(--ds-chart-magenta-boldest, #943D73)"
186
201
  },
187
202
  ['#44368B']: {
188
- tokenName: 'color.chart.purple.boldest',
203
+ getValue: fallback => getTokenValue('color.chart.purple.boldest', fallback),
189
204
  token: "var(--ds-chart-purple-boldest, #44368B)"
190
205
  },
191
206
  ['#44546F']: {
192
- tokenName: 'color.chart.gray.boldest',
207
+ getValue: fallback => getTokenValue('color.chart.gray.boldest', fallback),
193
208
  token: "var(--ds-chart-gray-boldest, #44546F)"
194
209
  }
195
- };
196
- const tableChartsPaletteKeys = Object.keys(editorTableChartsPalette);
197
- const tokenNames = tableChartsPaletteKeys.map(hexCode => editorTableChartsPalette[hexCode].tokenName);
210
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-palette",
3
- "version": "1.4.3",
3
+ "version": "1.5.0",
4
4
  "sideEffects": false
5
5
  }
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  var _editorBackgroundPale;
3
3
  // This import will be stripped on build
4
4
  // eslint-disable-next-line import/no-extraneous-dependencies
5
+ import { getTokenValue } from '@atlaskit/tokens';
5
6
 
6
7
  /**
7
8
  * This takes an adf hex color and returns a matching background palette
@@ -20,7 +21,7 @@ var _editorBackgroundPale;
20
21
  * The exact output of this function is an implementation detail and should only be used when rendering
21
22
  * content to the user, on a client with a matching major version of `@atlaskit/tokens`.
22
23
  * - **DO NOT**: store the output of these functions in any user-generated content or back-end.
23
- * - **DO**: store the ADF hex color, and use these utilities at render time to display the themed version of the color
24
+ * - **DO**: store the ADF hex color, and use these utilities at render time to display the themed version of the color.
24
25
  */
25
26
  export function hexToEditorBackgroundPaletteColor(hexColor) {
26
27
  // Ts ignore used to allow use of conditional return type
@@ -29,85 +30,137 @@ export function hexToEditorBackgroundPaletteColor(hexColor) {
29
30
  var tokenData = editorBackgroundPalette[hexColor.toUpperCase()];
30
31
  return tokenData ? tokenData.token : undefined;
31
32
  }
32
- export function hexToEditorBackgroundPaletteColorTokenName(hexColor) {
33
+
34
+ /**
35
+ * Takes an ADF hex color and returns the rendered hex code for the associated background palette design token using getTokenValue.
36
+ * If the provided color does not exist in the Editor color palette, this function returns undefined.
37
+ *
38
+ * This should only be used when rendering content where CSS variables are not feasible, such as a non-CSS environment
39
+ * or to enable cross-app copy/paste.
40
+ *
41
+ * WARNING: If the rendered theme changes (such as from light -> dark mode) the value returned here will no longer match
42
+ * the surrounding UI and will need to be re-fetched.
43
+ * In addition, the values of tokens will differ between themes and the value for a given theme can and will change.
44
+ * - **DO NOT**: store the output of these functions in any user-generated content or back-end.
45
+ * - **DO**: store the ADF hex color, and use these utilities at render time to display the themed version of the color.
46
+ */
47
+ export function hexToEditorBackgroundPaletteRawValue(hexColor) {
33
48
  // Ts ignore used to allow use of conditional return type
34
49
  // (preferencing better type on consumption over safety in implementation)
35
50
  // @ts-ignore
36
51
  var tokenData = editorBackgroundPalette[hexColor.toUpperCase()];
37
- return tokenData ? tokenData.tokenName : undefined;
52
+ return tokenData ? tokenData.getValue(hexColor) : undefined;
38
53
  }
39
54
  // Colors taken from
40
55
  // https://hello.atlassian.net/wiki/spaces/DST/pages/1790979421/DSTRFC-002+-+Shifting+Editor+s+color+palette+to+design+tokens
41
-
42
- // values are asserted to improve generated type declarations
43
- // Modified structure as having tokenName, token
44
- // and possibly editorColorName in future will make it
45
- // simpler to link everything together.
56
+ /**
57
+ * Values are asserted to improve generated type declarations
58
+ * Using object structure as getValue() function needed for table values, and other
59
+ * properties may be needed in the future.
60
+ */
46
61
  export var editorBackgroundPalette = (_editorBackgroundPale = {}, _defineProperty(_editorBackgroundPale, '#DEEBFF', {
47
- tokenName: 'color.background.accent.blue.subtlest',
62
+ getValue: function getValue(fallback) {
63
+ return getTokenValue('color.background.accent.blue.subtlest', fallback);
64
+ },
48
65
  token: "var(--ds-background-accent-blue-subtlest, #DEEBFF)"
49
66
  }), _defineProperty(_editorBackgroundPale, '#B3D4FF', {
50
- tokenName: 'color.background.accent.blue.subtler',
67
+ getValue: function getValue(fallback) {
68
+ return getTokenValue('color.background.accent.blue.subtler', fallback);
69
+ },
51
70
  token: "var(--ds-background-accent-blue-subtler, #B3D4FF)"
52
71
  }), _defineProperty(_editorBackgroundPale, '#4C9AFF', {
53
- tokenName: 'color.background.accent.blue.subtle',
72
+ getValue: function getValue(fallback) {
73
+ return getTokenValue('color.background.accent.blue.subtle', fallback);
74
+ },
54
75
  token: "var(--ds-background-accent-blue-subtle, #4C9AFF)"
55
76
  }), _defineProperty(_editorBackgroundPale, '#E6FCFF', {
56
- tokenName: 'color.background.accent.teal.subtlest',
77
+ getValue: function getValue(fallback) {
78
+ return getTokenValue('color.background.accent.teal.subtlest', fallback);
79
+ },
57
80
  token: "var(--ds-background-accent-teal-subtlest, #E6FCFF)" // source for hex code was legacy token T50,
58
81
  }), _defineProperty(_editorBackgroundPale, '#B3F5FF', {
59
- tokenName: 'color.background.accent.teal.subtler',
82
+ getValue: function getValue(fallback) {
83
+ return getTokenValue('color.background.accent.teal.subtler', fallback);
84
+ },
60
85
  token: "var(--ds-background-accent-teal-subtler, #B3F5FF)" // source for hex code was legacy token T75,
61
86
  }), _defineProperty(_editorBackgroundPale, '#79E2F2', {
62
- tokenName: 'color.background.accent.teal.subtle',
87
+ getValue: function getValue(fallback) {
88
+ return getTokenValue('color.background.accent.teal.subtle', fallback);
89
+ },
63
90
  token: "var(--ds-background-accent-teal-subtle, #79E2F2)" // source for hex code was legacy token T100,
64
91
  }), _defineProperty(_editorBackgroundPale, '#E3FCEF', {
65
- tokenName: 'color.background.accent.green.subtlest',
92
+ getValue: function getValue(fallback) {
93
+ return getTokenValue('color.background.accent.green.subtlest', fallback);
94
+ },
66
95
  token: "var(--ds-background-accent-green-subtlest, #E3FCEF)" // source for hex code was legacy token G50,
67
96
  }), _defineProperty(_editorBackgroundPale, '#ABF5D1', {
68
- tokenName: 'color.background.accent.green.subtler',
97
+ getValue: function getValue(fallback) {
98
+ return getTokenValue('color.background.accent.green.subtler', fallback);
99
+ },
69
100
  token: "var(--ds-background-accent-green-subtler, #ABF5D1)" // source for hex code was legacy token G75,
70
101
  }), _defineProperty(_editorBackgroundPale, '#57D9A3', {
71
- tokenName: 'color.background.accent.green.subtle',
102
+ getValue: function getValue(fallback) {
103
+ return getTokenValue('color.background.accent.green.subtle', fallback);
104
+ },
72
105
  token: "var(--ds-background-accent-green-subtle, #57D9A3)" // source for hex code was legacy token G200,
73
106
  }), _defineProperty(_editorBackgroundPale, '#FFFAE6', {
74
- tokenName: 'color.background.accent.yellow.subtlest',
107
+ getValue: function getValue(fallback) {
108
+ return getTokenValue('color.background.accent.yellow.subtlest', fallback);
109
+ },
75
110
  token: "var(--ds-background-accent-yellow-subtlest, #FFFAE6)" // source for hex code was legacy token Y50,
76
111
  }), _defineProperty(_editorBackgroundPale, '#FFF0B3', {
77
- tokenName: 'color.background.accent.yellow.subtler',
112
+ getValue: function getValue(fallback) {
113
+ return getTokenValue('color.background.accent.yellow.subtler', fallback);
114
+ },
78
115
  token: "var(--ds-background-accent-yellow-subtler, #FFF0B3)" // source for hex code was legacy token Y75,
79
116
  }), _defineProperty(_editorBackgroundPale, '#FFC400', {
80
- tokenName: 'color.background.accent.orange.subtle',
117
+ getValue: function getValue(fallback) {
118
+ return getTokenValue('color.background.accent.orange.subtle', fallback);
119
+ },
81
120
  token: "var(--ds-background-accent-orange-subtle, #FFC400)" // source for hex code was legacy token Y200,
82
121
  }), _defineProperty(_editorBackgroundPale, '#FFEBE6', {
83
- tokenName: 'color.background.accent.red.subtlest',
122
+ getValue: function getValue(fallback) {
123
+ return getTokenValue('color.background.accent.red.subtlest', fallback);
124
+ },
84
125
  token: "var(--ds-background-accent-red-subtlest, #FFEBE6)" // source for hex code was legacy token R50,
85
126
  }), _defineProperty(_editorBackgroundPale, '#FFBDAD', {
86
- tokenName: 'color.background.accent.red.subtler',
127
+ getValue: function getValue(fallback) {
128
+ return getTokenValue('color.background.accent.red.subtler', fallback);
129
+ },
87
130
  token: "var(--ds-background-accent-red-subtler, #FFBDAD)" // source for hex code was legacy token R75,
88
131
  }), _defineProperty(_editorBackgroundPale, '#FF8F73', {
89
- tokenName: 'color.background.accent.red.subtle',
132
+ getValue: function getValue(fallback) {
133
+ return getTokenValue('color.background.accent.red.subtle', fallback);
134
+ },
90
135
  token: "var(--ds-background-accent-red-subtle, #FF8F73)" // source for hex code was legacy token R100,
91
136
  }), _defineProperty(_editorBackgroundPale, '#EAE6FF', {
92
- tokenName: 'color.background.accent.purple.subtlest',
137
+ getValue: function getValue(fallback) {
138
+ return getTokenValue('color.background.accent.purple.subtlest', fallback);
139
+ },
93
140
  token: "var(--ds-background-accent-purple-subtlest, #EAE6FF)" // source for hex code was legacy token P50,
94
141
  }), _defineProperty(_editorBackgroundPale, '#C0B6F2', {
95
- tokenName: 'color.background.accent.purple.subtler',
142
+ getValue: function getValue(fallback) {
143
+ return getTokenValue('color.background.accent.purple.subtler', fallback);
144
+ },
96
145
  token: "var(--ds-background-accent-purple-subtler, #C0B6F2)" // source for hex code was legacy token P75,
97
146
  }), _defineProperty(_editorBackgroundPale, '#998DD9', {
98
- tokenName: 'color.background.accent.purple.subtle',
147
+ getValue: function getValue(fallback) {
148
+ return getTokenValue('color.background.accent.purple.subtle', fallback);
149
+ },
99
150
  token: "var(--ds-background-accent-purple-subtle, #998DD9)" // source for hex code was legacy token P100,
100
151
  }), _defineProperty(_editorBackgroundPale, '#FFFFFF', {
101
- tokenName: 'elevation.surface',
152
+ getValue: function getValue(fallback) {
153
+ return getTokenValue('elevation.surface', fallback);
154
+ },
102
155
  token: "var(--ds-surface, #FFFFFF)" // source for hex code was legacy token N0,
103
156
  }), _defineProperty(_editorBackgroundPale, '#F4F5F7', {
104
- tokenName: 'color.background.accent.gray.subtlest',
157
+ getValue: function getValue(fallback) {
158
+ return getTokenValue('color.background.accent.gray.subtlest', fallback);
159
+ },
105
160
  token: "var(--ds-background-accent-gray-subtlest, #F4F5F7)" // source for hex code was legacy token N20,
106
161
  }), _defineProperty(_editorBackgroundPale, '#B3BAC5', {
107
- tokenName: 'color.background.accent.gray.subtle',
162
+ getValue: function getValue(fallback) {
163
+ return getTokenValue('color.background.accent.gray.subtle', fallback);
164
+ },
108
165
  token: "var(--ds-background-accent-gray-subtle, #B3BAC5)" // source for hex code was legacy token N60,
109
- }), _editorBackgroundPale);
110
- var backgroundPaletteKeys = Object.keys(editorBackgroundPalette);
111
- var tokenNames = backgroundPaletteKeys.map(function (hexCode) {
112
- return editorBackgroundPalette[hexCode].tokenName;
113
- });
166
+ }), _editorBackgroundPale);