@zendeskgarden/react-typography 8.40.1 → 8.42.2

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/dist/index.cjs.js CHANGED
@@ -81,7 +81,7 @@ function _objectWithoutProperties(source, excluded) {
81
81
  var COMPONENT_ID$9 = 'typography.blockquote';
82
82
  var StyledBlockquote = styled__default['default'].blockquote.attrs({
83
83
  'data-garden-id': COMPONENT_ID$9,
84
- 'data-garden-version': '8.40.1'
84
+ 'data-garden-version': '8.42.2'
85
85
  }).withConfig({
86
86
  displayName: "StyledBlockquote",
87
87
  componentId: "sc-1tt3ye0-0"
@@ -141,7 +141,7 @@ var fontStyles = function fontStyles(props) {
141
141
  };
142
142
  var StyledFont = styled__default['default'].div.attrs({
143
143
  'data-garden-id': COMPONENT_ID$8,
144
- 'data-garden-version': '8.40.1'
144
+ 'data-garden-version': '8.42.2'
145
145
  }).withConfig({
146
146
  displayName: "StyledFont",
147
147
  componentId: "sc-1iildbo-0"
@@ -156,7 +156,7 @@ StyledFont.defaultProps = {
156
156
  };
157
157
 
158
158
  var COMPONENT_ID$7 = 'typography.code';
159
- var colorStyles$2 = function colorStyles(props) {
159
+ var colorStyles$3 = function colorStyles(props) {
160
160
  var hue = props.hue || 'neutralHue';
161
161
  var backgroundColor = reactTheming.getColor(hue, 200, props.theme);
162
162
  var shade = hue === 'yellow' ? 800 : 700;
@@ -165,7 +165,7 @@ var colorStyles$2 = function colorStyles(props) {
165
165
  };
166
166
  var StyledCode = styled__default['default'](StyledFont).attrs({
167
167
  'data-garden-id': COMPONENT_ID$7,
168
- 'data-garden-version': '8.40.1',
168
+ 'data-garden-version': '8.42.2',
169
169
  as: 'code'
170
170
  }).withConfig({
171
171
  displayName: "StyledCode",
@@ -173,7 +173,7 @@ var StyledCode = styled__default['default'](StyledFont).attrs({
173
173
  })(["border-radius:", ";padding:1.5px;", ";", ";"], function (props) {
174
174
  return props.theme.borderRadii.sm;
175
175
  }, function (props) {
176
- return colorStyles$2(props);
176
+ return colorStyles$3(props);
177
177
  }, function (props) {
178
178
  return reactTheming.retrieveComponentStyles(COMPONENT_ID$7, props);
179
179
  });
@@ -185,21 +185,21 @@ StyledCode.defaultProps = {
185
185
  };
186
186
 
187
187
  var COMPONENT_ID$6 = 'typography.codeblock';
188
- var colorStyles$1 = function colorStyles(props) {
188
+ var colorStyles$2 = function colorStyles(props) {
189
189
  var backgroundColor = reactTheming.getColor('neutralHue', props.isLight ? 100 : 1000, props.theme);
190
190
  var foregroundColor = props.isLight ? props.theme.colors.foreground : reactTheming.getColor('neutralHue', 300, props.theme);
191
191
  return styled.css(["background-color:", ";color:", ";"], backgroundColor, foregroundColor);
192
192
  };
193
193
  var StyledCodeBlock = styled__default['default'].pre.attrs({
194
194
  'data-garden-id': COMPONENT_ID$6,
195
- 'data-garden-version': '8.40.1'
195
+ 'data-garden-version': '8.42.2'
196
196
  }).withConfig({
197
197
  displayName: "StyledCodeBlock",
198
198
  componentId: "sc-5wky57-0"
199
199
  })(["display:table;margin:0;padding:", "px;box-sizing:border-box;width:100%;direction:ltr;white-space:pre;counter-reset:linenumber;", ";", ";"], function (props) {
200
200
  return props.theme.space.base * 3;
201
201
  }, function (props) {
202
- return colorStyles$1(props);
202
+ return colorStyles$2(props);
203
203
  }, function (props) {
204
204
  return reactTheming.retrieveComponentStyles(COMPONENT_ID$6, props);
205
205
  });
@@ -210,7 +210,7 @@ StyledCodeBlock.defaultProps = {
210
210
  var COMPONENT_ID$5 = 'typography.codeblock_container';
211
211
  var StyledCodeBlockContainer = styled__default['default'].div.attrs({
212
212
  'data-garden-id': COMPONENT_ID$5,
213
- 'data-garden-version': '8.40.1'
213
+ 'data-garden-version': '8.42.2'
214
214
  }).withConfig({
215
215
  displayName: "StyledCodeBlockContainer",
216
216
  componentId: "sc-14zgbfw-0"
@@ -224,19 +224,48 @@ StyledCodeBlockContainer.defaultProps = {
224
224
  };
225
225
 
226
226
  var COMPONENT_ID$4 = 'typography.codeblock_code';
227
- var highlightStyles = function highlightStyles(props) {
228
- var hue = props.isLight ? props.theme.palette.black : props.theme.palette.white;
229
- var backgroundColor = reactTheming.getColor(hue, 600, props.theme, 0.1);
227
+ var colorStyles$1 = function colorStyles(props) {
228
+ var backgroundColor;
229
+ if (props.diff) {
230
+ var hue;
231
+ switch (props.diff) {
232
+ case 'hunk':
233
+ hue = 'royal';
234
+ break;
235
+ case 'add':
236
+ hue = 'lime';
237
+ break;
238
+ case 'delete':
239
+ hue = 'crimson';
240
+ break;
241
+ case 'change':
242
+ hue = 'lemon';
243
+ break;
244
+ }
245
+ backgroundColor = reactTheming.getColor(hue, 400, props.theme, 0.2);
246
+ } else if (props.isHighlighted) {
247
+ var _hue = props.isLight ? props.theme.palette.black : props.theme.palette.white;
248
+ backgroundColor = reactTheming.getColor(_hue, 600, props.theme, 0.1);
249
+ }
230
250
  return styled.css(["background-color:", ";"], backgroundColor);
231
251
  };
232
252
  var lineNumberStyles = function lineNumberStyles(props) {
233
- var padding = "".concat(props.theme.space.base * 6, "px");
234
253
  var color = reactTheming.getColor('neutralHue', props.isLight ? 600 : 500, props.theme);
235
- return styled.css(["&::before{display:table-cell;padding-right:", ";width:1px;text-align:right;color:", ";content:counter(linenumber);counter-increment:linenumber;}"], padding, color);
254
+ var padding;
255
+ if (props.language && props.language === 'diff') {
256
+ padding = 0;
257
+ } else if (props.size === 'sm') {
258
+ padding = props.theme.space.base * 4;
259
+ } else if (props.size === 'lg') {
260
+ padding = props.theme.space.base * 7;
261
+ } else {
262
+ padding = props.theme.space.base * 6;
263
+ }
264
+ return "\n &::before {\n display: table-cell;\n padding-right: ".concat(padding, "px;\n width: 1px;\n text-align: right;\n color: ").concat(color, ";\n content: counter(linenumber);\n counter-increment: linenumber;\n }\n ");
236
265
  };
237
266
  var StyledCodeBlockLine = styled__default['default'](StyledFont).attrs({
238
267
  'data-garden-id': COMPONENT_ID$4,
239
- 'data-garden-version': '8.40.1',
268
+ 'data-garden-version': '8.42.2',
240
269
  as: 'code',
241
270
  isMonospace: true
242
271
  }).withConfig({
@@ -245,7 +274,7 @@ var StyledCodeBlockLine = styled__default['default'](StyledFont).attrs({
245
274
  })(["display:table-row;height:", ";direction:ltr;", ";", ";&::after{display:inline-block;width:", "px;content:'';}", ";"], function (props) {
246
275
  return props.theme.lineHeights[props.size];
247
276
  }, function (props) {
248
- return props.isHighlighted && highlightStyles(props);
277
+ return colorStyles$1(props);
249
278
  }, function (props) {
250
279
  return props.isNumbered && lineNumberStyles(props);
251
280
  }, function (props) {
@@ -266,7 +295,11 @@ var colorStyles = function colorStyles(props) {
266
295
  builtin: palette.teal[400],
267
296
  comment: props.isLight ? palette.lime[600] : palette.mint[400],
268
297
  constant: props.isLight ? palette.azure[400] : palette.blue[500],
298
+ coord: props.isLight ? palette.purple[600] : palette.blue[200],
299
+ deleted: props.isLight ? palette.red[700] : palette.red[200],
300
+ diff: props.isLight ? palette.yellow[800] : palette.yellow[200],
269
301
  function: props.isLight ? palette.orange['M600'] : palette.yellow[300],
302
+ inserted: props.isLight ? palette.green[700] : palette.green[200],
270
303
  keyword: palette.fuschia['M400'],
271
304
  name: props.isLight ? palette.crimson[400] : palette.blue[300],
272
305
  number: props.isLight ? palette.green[600] : palette.green[300],
@@ -274,15 +307,15 @@ var colorStyles = function colorStyles(props) {
274
307
  regex: palette.red[400],
275
308
  value: props.isLight ? palette.red[700] : palette.crimson['M400']
276
309
  };
277
- return styled.css(["&.builtin,&.class-name,&.tag:not(.punctuation):not(.attr-name):not(.attr-value):not(.script){color:", ";}&.doctype,&.prolog,&.tag.punctuation:not(.attr-value):not(.script):not(.spread){color:", ";}&.attribute.value,&.attr-value,&.atrule,&.cdata,&.string,&.url.content{color:", ";}&.constant,&.interpolation-punctuation{color:", ";}&.attr-name,&.attr-value.spread,&.environment,&.interpolation,&.parameter,&.property,&.property-access,&.variable{color:", ";}&.parameter.punctuation,&.attr-name + .attr-value.punctuation{color:inherit;}&.regex{color:", ";}&.boolean,&.bold,&.entity,&.important,&.tag:not(.punctuation):not(.attr-name):not(.attr-value):not(.script):not(.class-name){color:", ";}&.number,&.unit{color:", ";}&.assign-left,&.function,&.selector:not(.attribute){color:", ";}&.atrule.rule,&.keyword{color:", ";}&.blockquote,&.comment,&.shebang{color:", ";}", ".language-css &.plain{color:", ";}"], colors.builtin, colors.punctuation, colors.value, colors.constant, colors.name, colors.regex, colors.boolean, colors.number, colors.function, colors.keyword, colors.comment, StyledCodeBlock, colors.value);
310
+ return styled.css(["&.builtin,&.class-name,&.tag:not(.punctuation):not(.attr-name):not(.attr-value):not(.script){color:", ";}&.doctype,&.prolog,&.tag.punctuation:not(.attr-value):not(.script):not(.spread){color:", ";}&.attribute.value,&.attr-value,&.atrule,&.cdata,&.string,&.url.content{color:", ";}&.constant,&.interpolation-punctuation{color:", ";}&.attr-name,&.attr-value.spread,&.environment,&.interpolation,&.parameter,&.property,&.property-access,&.variable{color:", ";}&.parameter.punctuation,&.attr-name + .attr-value.punctuation{color:inherit;}&.regex{color:", ";}&.boolean,&.bold:not(.diff),&.entity,&.important,&.tag:not(.punctuation):not(.attr-name):not(.attr-value):not(.script):not(.class-name){color:", ";}&.number,&.unit{color:", ";}&.assign-left,&.function,&.selector:not(.attribute){color:", ";}&.atrule.rule,&.keyword{color:", ";}&.blockquote,&.comment,&.shebang{color:", ";}", ".language-css &&.plain{color:", ";}", ".language-diff &&.coord{color:", ";}", ".language-diff &&.deleted{color:", ";}", ".language-diff &&.diff{color:", ";}", ".language-diff &&.inserted{color:", ";}"], colors.builtin, colors.punctuation, colors.value, colors.constant, colors.name, colors.regex, colors.boolean, colors.number, colors.function, colors.keyword, colors.comment, StyledCodeBlock, colors.value, StyledCodeBlock, colors.coord, StyledCodeBlock, colors.deleted, StyledCodeBlock, colors.diff, StyledCodeBlock, colors.inserted);
278
311
  };
279
312
  var StyledCodeBlockToken = styled__default['default'].span.attrs({
280
313
  'data-garden-id': COMPONENT_ID$3,
281
- 'data-garden-version': '8.40.1'
314
+ 'data-garden-version': '8.42.2'
282
315
  }).withConfig({
283
316
  displayName: "StyledCodeBlockToken",
284
317
  componentId: "sc-1hkshdq-0"
285
- })(["display:inline-block;&.bold{font-weight:", ";}&.italic{font-style:italic;}", ";", ";"], function (props) {
318
+ })(["display:inline-block;&.bold:not(.diff){font-weight:", ";}&.coord{padding-left:0.75em;}&.italic{font-style:italic;}&.prefix{width:2em;text-align:center;}", ";", ";"], function (props) {
286
319
  return props.theme.fontWeights.semibold;
287
320
  }, function (props) {
288
321
  return colorStyles(props);
@@ -296,7 +329,7 @@ StyledCodeBlockToken.defaultProps = {
296
329
  var COMPONENT_ID$2 = 'typography.ellipsis';
297
330
  var StyledEllipsis = styled__default['default'].div.attrs({
298
331
  'data-garden-id': COMPONENT_ID$2,
299
- 'data-garden-version': '8.40.1'
332
+ 'data-garden-version': '8.42.2'
300
333
  }).withConfig({
301
334
  displayName: "StyledEllipsis",
302
335
  componentId: "sc-1u4uqmy-0"
@@ -323,7 +356,7 @@ var StyledIcon = styled__default['default'](function (_ref) {
323
356
  return React__default['default'].cloneElement(React.Children.only(children), props);
324
357
  }).attrs({
325
358
  'data-garden-id': COMPONENT_ID$1,
326
- 'data-garden-version': '8.40.1'
359
+ 'data-garden-version': '8.42.2'
327
360
  }).withConfig({
328
361
  displayName: "StyledIcon",
329
362
  componentId: "sc-10rfb5b-0"
@@ -343,7 +376,7 @@ var listStyles = function listStyles(props) {
343
376
  var ORDERED_ID$1 = 'typography.ordered_list';
344
377
  var StyledOrderedList = styled__default['default'].ol.attrs({
345
378
  'data-garden-id': ORDERED_ID$1,
346
- 'data-garden-version': '8.40.1'
379
+ 'data-garden-version': '8.42.2'
347
380
  }).withConfig({
348
381
  displayName: "StyledList__StyledOrderedList",
349
382
  componentId: "sc-jdbsfi-0"
@@ -358,7 +391,7 @@ StyledOrderedList.defaultProps = {
358
391
  var UNORDERED_ID$1 = 'typography.unordered_list';
359
392
  var StyledUnorderedList = styled__default['default'].ul.attrs({
360
393
  'data-garden-id': UNORDERED_ID$1,
361
- 'data-garden-version': '8.40.1'
394
+ 'data-garden-version': '8.42.2'
362
395
  }).withConfig({
363
396
  displayName: "StyledList__StyledUnorderedList",
364
397
  componentId: "sc-jdbsfi-1"
@@ -382,7 +415,7 @@ var listItemStyles = function listItemStyles(props) {
382
415
  var ORDERED_ID = 'typography.ordered_list_item';
383
416
  var StyledOrderedListItem = styled__default['default'](StyledFont).attrs({
384
417
  'data-garden-id': ORDERED_ID,
385
- 'data-garden-version': '8.40.1',
418
+ 'data-garden-version': '8.42.2',
386
419
  as: 'li'
387
420
  }).withConfig({
388
421
  displayName: "StyledListItem__StyledOrderedListItem",
@@ -407,7 +440,7 @@ StyledOrderedListItem.defaultProps = {
407
440
  var UNORDERED_ID = 'typography.unordered_list_item';
408
441
  var StyledUnorderedListItem = styled__default['default'](StyledFont).attrs({
409
442
  'data-garden-id': UNORDERED_ID,
410
- 'data-garden-version': '8.40.1',
443
+ 'data-garden-version': '8.42.2',
411
444
  as: 'li'
412
445
  }).withConfig({
413
446
  displayName: "StyledListItem__StyledUnorderedListItem",
@@ -425,7 +458,7 @@ StyledUnorderedListItem.defaultProps = {
425
458
  var COMPONENT_ID = 'typography.paragraph';
426
459
  var StyledParagraph = styled__default['default'].p.attrs({
427
460
  'data-garden-id': COMPONENT_ID,
428
- 'data-garden-version': '8.40.1'
461
+ 'data-garden-version': '8.42.2'
429
462
  }).withConfig({
430
463
  displayName: "StyledParagraph",
431
464
  componentId: "sc-zkuftz-0"
@@ -615,6 +648,7 @@ Blockquote.defaultProps = {
615
648
  };
616
649
 
617
650
  var _excluded$5 = ["children", "containerProps", "highlightLines", "isLight", "isNumbered", "language", "size"];
651
+ var LANGUAGES = ['markup', 'bash', 'clike', 'c', 'cpp', 'css', 'javascript', 'jsx', 'coffeescript', 'actionscript', 'css-extr', 'diff', 'git', 'go', 'graphql', 'handlebars', 'json', 'less', 'makefile', 'markdown', 'objectivec', 'ocaml', 'python', 'reason', 'sass', 'scss', 'sql', 'stylus', 'tsx', 'typescript', 'wasm', 'yaml'];
618
652
  var CodeBlock = React__default['default'].forwardRef(function (_ref, ref) {
619
653
  var children = _ref.children,
620
654
  containerProps = _ref.containerProps,
@@ -626,14 +660,11 @@ var CodeBlock = React__default['default'].forwardRef(function (_ref, ref) {
626
660
  other = _objectWithoutProperties(_ref, _excluded$5);
627
661
  var containerRef = React.useRef(null);
628
662
  var code = Array.isArray(children) ? children[0] : children;
629
- var _size;
630
- if (size === 'small') {
631
- _size = 'sm';
632
- } else if (size === 'medium') {
633
- _size = 'md';
634
- } else {
635
- _size = 'lg';
636
- }
663
+ var SIZES = {
664
+ small: 'sm',
665
+ medium: 'md',
666
+ large: 'lg'
667
+ };
637
668
  var dependency = React.useMemo(function () {
638
669
  return [size, children];
639
670
  }, [size, children]);
@@ -641,13 +672,33 @@ var CodeBlock = React__default['default'].forwardRef(function (_ref, ref) {
641
672
  containerRef: containerRef,
642
673
  dependency: dependency
643
674
  });
675
+ var getDiff = function getDiff(line) {
676
+ var retVal;
677
+ if (language === 'diff') {
678
+ var token = line.find(function (value) {
679
+ return !(value.empty || value.content === '');
680
+ });
681
+ if (token) {
682
+ if (token.types.includes('deleted')) {
683
+ retVal = 'delete';
684
+ } else if (token.types.includes('inserted')) {
685
+ retVal = 'add';
686
+ } else if (token.types.includes('coord')) {
687
+ retVal = 'hunk';
688
+ } else if (token.types.includes('diff')) {
689
+ retVal = 'change';
690
+ }
691
+ }
692
+ }
693
+ return retVal;
694
+ };
644
695
  return React__default['default'].createElement(StyledCodeBlockContainer, _extends({}, containerProps, {
645
696
  ref: containerRef,
646
697
  tabIndex: containerTabIndex
647
698
  }), React__default['default'].createElement(Highlight__default['default'], {
648
699
  Prism: Highlight.Prism,
649
700
  code: code ? code.trim() : '',
650
- language: language || 'tsx'
701
+ language: LANGUAGES.includes(language) ? language : 'tsx'
651
702
  }, function (_ref2) {
652
703
  var className = _ref2.className,
653
704
  tokens = _ref2.tokens,
@@ -662,10 +713,12 @@ var CodeBlock = React__default['default'].forwardRef(function (_ref, ref) {
662
713
  line: line
663
714
  }), {
664
715
  key: index,
716
+ language: language,
665
717
  isHighlighted: highlightLines && highlightLines.includes(index + 1),
666
718
  isLight: isLight,
667
719
  isNumbered: isNumbered,
668
- size: _size
720
+ diff: getDiff(line),
721
+ size: size ? SIZES[size] : undefined
669
722
  }), line.map(function (token, tokenKey) {
670
723
  return React__default['default'].createElement(StyledCodeBlockToken, _extends({}, getTokenProps({
671
724
  token: token
package/dist/index.esm.js CHANGED
@@ -70,7 +70,7 @@ function _objectWithoutProperties(source, excluded) {
70
70
  var COMPONENT_ID$9 = 'typography.blockquote';
71
71
  var StyledBlockquote = styled.blockquote.attrs({
72
72
  'data-garden-id': COMPONENT_ID$9,
73
- 'data-garden-version': '8.40.1'
73
+ 'data-garden-version': '8.42.2'
74
74
  }).withConfig({
75
75
  displayName: "StyledBlockquote",
76
76
  componentId: "sc-1tt3ye0-0"
@@ -130,7 +130,7 @@ var fontStyles = function fontStyles(props) {
130
130
  };
131
131
  var StyledFont = styled.div.attrs({
132
132
  'data-garden-id': COMPONENT_ID$8,
133
- 'data-garden-version': '8.40.1'
133
+ 'data-garden-version': '8.42.2'
134
134
  }).withConfig({
135
135
  displayName: "StyledFont",
136
136
  componentId: "sc-1iildbo-0"
@@ -145,7 +145,7 @@ StyledFont.defaultProps = {
145
145
  };
146
146
 
147
147
  var COMPONENT_ID$7 = 'typography.code';
148
- var colorStyles$2 = function colorStyles(props) {
148
+ var colorStyles$3 = function colorStyles(props) {
149
149
  var hue = props.hue || 'neutralHue';
150
150
  var backgroundColor = getColor(hue, 200, props.theme);
151
151
  var shade = hue === 'yellow' ? 800 : 700;
@@ -154,7 +154,7 @@ var colorStyles$2 = function colorStyles(props) {
154
154
  };
155
155
  var StyledCode = styled(StyledFont).attrs({
156
156
  'data-garden-id': COMPONENT_ID$7,
157
- 'data-garden-version': '8.40.1',
157
+ 'data-garden-version': '8.42.2',
158
158
  as: 'code'
159
159
  }).withConfig({
160
160
  displayName: "StyledCode",
@@ -162,7 +162,7 @@ var StyledCode = styled(StyledFont).attrs({
162
162
  })(["border-radius:", ";padding:1.5px;", ";", ";"], function (props) {
163
163
  return props.theme.borderRadii.sm;
164
164
  }, function (props) {
165
- return colorStyles$2(props);
165
+ return colorStyles$3(props);
166
166
  }, function (props) {
167
167
  return retrieveComponentStyles(COMPONENT_ID$7, props);
168
168
  });
@@ -174,21 +174,21 @@ StyledCode.defaultProps = {
174
174
  };
175
175
 
176
176
  var COMPONENT_ID$6 = 'typography.codeblock';
177
- var colorStyles$1 = function colorStyles(props) {
177
+ var colorStyles$2 = function colorStyles(props) {
178
178
  var backgroundColor = getColor('neutralHue', props.isLight ? 100 : 1000, props.theme);
179
179
  var foregroundColor = props.isLight ? props.theme.colors.foreground : getColor('neutralHue', 300, props.theme);
180
180
  return css(["background-color:", ";color:", ";"], backgroundColor, foregroundColor);
181
181
  };
182
182
  var StyledCodeBlock = styled.pre.attrs({
183
183
  'data-garden-id': COMPONENT_ID$6,
184
- 'data-garden-version': '8.40.1'
184
+ 'data-garden-version': '8.42.2'
185
185
  }).withConfig({
186
186
  displayName: "StyledCodeBlock",
187
187
  componentId: "sc-5wky57-0"
188
188
  })(["display:table;margin:0;padding:", "px;box-sizing:border-box;width:100%;direction:ltr;white-space:pre;counter-reset:linenumber;", ";", ";"], function (props) {
189
189
  return props.theme.space.base * 3;
190
190
  }, function (props) {
191
- return colorStyles$1(props);
191
+ return colorStyles$2(props);
192
192
  }, function (props) {
193
193
  return retrieveComponentStyles(COMPONENT_ID$6, props);
194
194
  });
@@ -199,7 +199,7 @@ StyledCodeBlock.defaultProps = {
199
199
  var COMPONENT_ID$5 = 'typography.codeblock_container';
200
200
  var StyledCodeBlockContainer = styled.div.attrs({
201
201
  'data-garden-id': COMPONENT_ID$5,
202
- 'data-garden-version': '8.40.1'
202
+ 'data-garden-version': '8.42.2'
203
203
  }).withConfig({
204
204
  displayName: "StyledCodeBlockContainer",
205
205
  componentId: "sc-14zgbfw-0"
@@ -213,19 +213,48 @@ StyledCodeBlockContainer.defaultProps = {
213
213
  };
214
214
 
215
215
  var COMPONENT_ID$4 = 'typography.codeblock_code';
216
- var highlightStyles = function highlightStyles(props) {
217
- var hue = props.isLight ? props.theme.palette.black : props.theme.palette.white;
218
- var backgroundColor = getColor(hue, 600, props.theme, 0.1);
216
+ var colorStyles$1 = function colorStyles(props) {
217
+ var backgroundColor;
218
+ if (props.diff) {
219
+ var hue;
220
+ switch (props.diff) {
221
+ case 'hunk':
222
+ hue = 'royal';
223
+ break;
224
+ case 'add':
225
+ hue = 'lime';
226
+ break;
227
+ case 'delete':
228
+ hue = 'crimson';
229
+ break;
230
+ case 'change':
231
+ hue = 'lemon';
232
+ break;
233
+ }
234
+ backgroundColor = getColor(hue, 400, props.theme, 0.2);
235
+ } else if (props.isHighlighted) {
236
+ var _hue = props.isLight ? props.theme.palette.black : props.theme.palette.white;
237
+ backgroundColor = getColor(_hue, 600, props.theme, 0.1);
238
+ }
219
239
  return css(["background-color:", ";"], backgroundColor);
220
240
  };
221
241
  var lineNumberStyles = function lineNumberStyles(props) {
222
- var padding = "".concat(props.theme.space.base * 6, "px");
223
242
  var color = getColor('neutralHue', props.isLight ? 600 : 500, props.theme);
224
- return css(["&::before{display:table-cell;padding-right:", ";width:1px;text-align:right;color:", ";content:counter(linenumber);counter-increment:linenumber;}"], padding, color);
243
+ var padding;
244
+ if (props.language && props.language === 'diff') {
245
+ padding = 0;
246
+ } else if (props.size === 'sm') {
247
+ padding = props.theme.space.base * 4;
248
+ } else if (props.size === 'lg') {
249
+ padding = props.theme.space.base * 7;
250
+ } else {
251
+ padding = props.theme.space.base * 6;
252
+ }
253
+ return "\n &::before {\n display: table-cell;\n padding-right: ".concat(padding, "px;\n width: 1px;\n text-align: right;\n color: ").concat(color, ";\n content: counter(linenumber);\n counter-increment: linenumber;\n }\n ");
225
254
  };
226
255
  var StyledCodeBlockLine = styled(StyledFont).attrs({
227
256
  'data-garden-id': COMPONENT_ID$4,
228
- 'data-garden-version': '8.40.1',
257
+ 'data-garden-version': '8.42.2',
229
258
  as: 'code',
230
259
  isMonospace: true
231
260
  }).withConfig({
@@ -234,7 +263,7 @@ var StyledCodeBlockLine = styled(StyledFont).attrs({
234
263
  })(["display:table-row;height:", ";direction:ltr;", ";", ";&::after{display:inline-block;width:", "px;content:'';}", ";"], function (props) {
235
264
  return props.theme.lineHeights[props.size];
236
265
  }, function (props) {
237
- return props.isHighlighted && highlightStyles(props);
266
+ return colorStyles$1(props);
238
267
  }, function (props) {
239
268
  return props.isNumbered && lineNumberStyles(props);
240
269
  }, function (props) {
@@ -255,7 +284,11 @@ var colorStyles = function colorStyles(props) {
255
284
  builtin: palette.teal[400],
256
285
  comment: props.isLight ? palette.lime[600] : palette.mint[400],
257
286
  constant: props.isLight ? palette.azure[400] : palette.blue[500],
287
+ coord: props.isLight ? palette.purple[600] : palette.blue[200],
288
+ deleted: props.isLight ? palette.red[700] : palette.red[200],
289
+ diff: props.isLight ? palette.yellow[800] : palette.yellow[200],
258
290
  function: props.isLight ? palette.orange['M600'] : palette.yellow[300],
291
+ inserted: props.isLight ? palette.green[700] : palette.green[200],
259
292
  keyword: palette.fuschia['M400'],
260
293
  name: props.isLight ? palette.crimson[400] : palette.blue[300],
261
294
  number: props.isLight ? palette.green[600] : palette.green[300],
@@ -263,15 +296,15 @@ var colorStyles = function colorStyles(props) {
263
296
  regex: palette.red[400],
264
297
  value: props.isLight ? palette.red[700] : palette.crimson['M400']
265
298
  };
266
- return css(["&.builtin,&.class-name,&.tag:not(.punctuation):not(.attr-name):not(.attr-value):not(.script){color:", ";}&.doctype,&.prolog,&.tag.punctuation:not(.attr-value):not(.script):not(.spread){color:", ";}&.attribute.value,&.attr-value,&.atrule,&.cdata,&.string,&.url.content{color:", ";}&.constant,&.interpolation-punctuation{color:", ";}&.attr-name,&.attr-value.spread,&.environment,&.interpolation,&.parameter,&.property,&.property-access,&.variable{color:", ";}&.parameter.punctuation,&.attr-name + .attr-value.punctuation{color:inherit;}&.regex{color:", ";}&.boolean,&.bold,&.entity,&.important,&.tag:not(.punctuation):not(.attr-name):not(.attr-value):not(.script):not(.class-name){color:", ";}&.number,&.unit{color:", ";}&.assign-left,&.function,&.selector:not(.attribute){color:", ";}&.atrule.rule,&.keyword{color:", ";}&.blockquote,&.comment,&.shebang{color:", ";}", ".language-css &.plain{color:", ";}"], colors.builtin, colors.punctuation, colors.value, colors.constant, colors.name, colors.regex, colors.boolean, colors.number, colors.function, colors.keyword, colors.comment, StyledCodeBlock, colors.value);
299
+ return css(["&.builtin,&.class-name,&.tag:not(.punctuation):not(.attr-name):not(.attr-value):not(.script){color:", ";}&.doctype,&.prolog,&.tag.punctuation:not(.attr-value):not(.script):not(.spread){color:", ";}&.attribute.value,&.attr-value,&.atrule,&.cdata,&.string,&.url.content{color:", ";}&.constant,&.interpolation-punctuation{color:", ";}&.attr-name,&.attr-value.spread,&.environment,&.interpolation,&.parameter,&.property,&.property-access,&.variable{color:", ";}&.parameter.punctuation,&.attr-name + .attr-value.punctuation{color:inherit;}&.regex{color:", ";}&.boolean,&.bold:not(.diff),&.entity,&.important,&.tag:not(.punctuation):not(.attr-name):not(.attr-value):not(.script):not(.class-name){color:", ";}&.number,&.unit{color:", ";}&.assign-left,&.function,&.selector:not(.attribute){color:", ";}&.atrule.rule,&.keyword{color:", ";}&.blockquote,&.comment,&.shebang{color:", ";}", ".language-css &&.plain{color:", ";}", ".language-diff &&.coord{color:", ";}", ".language-diff &&.deleted{color:", ";}", ".language-diff &&.diff{color:", ";}", ".language-diff &&.inserted{color:", ";}"], colors.builtin, colors.punctuation, colors.value, colors.constant, colors.name, colors.regex, colors.boolean, colors.number, colors.function, colors.keyword, colors.comment, StyledCodeBlock, colors.value, StyledCodeBlock, colors.coord, StyledCodeBlock, colors.deleted, StyledCodeBlock, colors.diff, StyledCodeBlock, colors.inserted);
267
300
  };
268
301
  var StyledCodeBlockToken = styled.span.attrs({
269
302
  'data-garden-id': COMPONENT_ID$3,
270
- 'data-garden-version': '8.40.1'
303
+ 'data-garden-version': '8.42.2'
271
304
  }).withConfig({
272
305
  displayName: "StyledCodeBlockToken",
273
306
  componentId: "sc-1hkshdq-0"
274
- })(["display:inline-block;&.bold{font-weight:", ";}&.italic{font-style:italic;}", ";", ";"], function (props) {
307
+ })(["display:inline-block;&.bold:not(.diff){font-weight:", ";}&.coord{padding-left:0.75em;}&.italic{font-style:italic;}&.prefix{width:2em;text-align:center;}", ";", ";"], function (props) {
275
308
  return props.theme.fontWeights.semibold;
276
309
  }, function (props) {
277
310
  return colorStyles(props);
@@ -285,7 +318,7 @@ StyledCodeBlockToken.defaultProps = {
285
318
  var COMPONENT_ID$2 = 'typography.ellipsis';
286
319
  var StyledEllipsis = styled.div.attrs({
287
320
  'data-garden-id': COMPONENT_ID$2,
288
- 'data-garden-version': '8.40.1'
321
+ 'data-garden-version': '8.42.2'
289
322
  }).withConfig({
290
323
  displayName: "StyledEllipsis",
291
324
  componentId: "sc-1u4uqmy-0"
@@ -312,7 +345,7 @@ var StyledIcon = styled(function (_ref) {
312
345
  return React.cloneElement(Children.only(children), props);
313
346
  }).attrs({
314
347
  'data-garden-id': COMPONENT_ID$1,
315
- 'data-garden-version': '8.40.1'
348
+ 'data-garden-version': '8.42.2'
316
349
  }).withConfig({
317
350
  displayName: "StyledIcon",
318
351
  componentId: "sc-10rfb5b-0"
@@ -332,7 +365,7 @@ var listStyles = function listStyles(props) {
332
365
  var ORDERED_ID$1 = 'typography.ordered_list';
333
366
  var StyledOrderedList = styled.ol.attrs({
334
367
  'data-garden-id': ORDERED_ID$1,
335
- 'data-garden-version': '8.40.1'
368
+ 'data-garden-version': '8.42.2'
336
369
  }).withConfig({
337
370
  displayName: "StyledList__StyledOrderedList",
338
371
  componentId: "sc-jdbsfi-0"
@@ -347,7 +380,7 @@ StyledOrderedList.defaultProps = {
347
380
  var UNORDERED_ID$1 = 'typography.unordered_list';
348
381
  var StyledUnorderedList = styled.ul.attrs({
349
382
  'data-garden-id': UNORDERED_ID$1,
350
- 'data-garden-version': '8.40.1'
383
+ 'data-garden-version': '8.42.2'
351
384
  }).withConfig({
352
385
  displayName: "StyledList__StyledUnorderedList",
353
386
  componentId: "sc-jdbsfi-1"
@@ -371,7 +404,7 @@ var listItemStyles = function listItemStyles(props) {
371
404
  var ORDERED_ID = 'typography.ordered_list_item';
372
405
  var StyledOrderedListItem = styled(StyledFont).attrs({
373
406
  'data-garden-id': ORDERED_ID,
374
- 'data-garden-version': '8.40.1',
407
+ 'data-garden-version': '8.42.2',
375
408
  as: 'li'
376
409
  }).withConfig({
377
410
  displayName: "StyledListItem__StyledOrderedListItem",
@@ -396,7 +429,7 @@ StyledOrderedListItem.defaultProps = {
396
429
  var UNORDERED_ID = 'typography.unordered_list_item';
397
430
  var StyledUnorderedListItem = styled(StyledFont).attrs({
398
431
  'data-garden-id': UNORDERED_ID,
399
- 'data-garden-version': '8.40.1',
432
+ 'data-garden-version': '8.42.2',
400
433
  as: 'li'
401
434
  }).withConfig({
402
435
  displayName: "StyledListItem__StyledUnorderedListItem",
@@ -414,7 +447,7 @@ StyledUnorderedListItem.defaultProps = {
414
447
  var COMPONENT_ID = 'typography.paragraph';
415
448
  var StyledParagraph = styled.p.attrs({
416
449
  'data-garden-id': COMPONENT_ID,
417
- 'data-garden-version': '8.40.1'
450
+ 'data-garden-version': '8.42.2'
418
451
  }).withConfig({
419
452
  displayName: "StyledParagraph",
420
453
  componentId: "sc-zkuftz-0"
@@ -604,6 +637,7 @@ Blockquote.defaultProps = {
604
637
  };
605
638
 
606
639
  var _excluded$5 = ["children", "containerProps", "highlightLines", "isLight", "isNumbered", "language", "size"];
640
+ var LANGUAGES = ['markup', 'bash', 'clike', 'c', 'cpp', 'css', 'javascript', 'jsx', 'coffeescript', 'actionscript', 'css-extr', 'diff', 'git', 'go', 'graphql', 'handlebars', 'json', 'less', 'makefile', 'markdown', 'objectivec', 'ocaml', 'python', 'reason', 'sass', 'scss', 'sql', 'stylus', 'tsx', 'typescript', 'wasm', 'yaml'];
607
641
  var CodeBlock = React.forwardRef(function (_ref, ref) {
608
642
  var children = _ref.children,
609
643
  containerProps = _ref.containerProps,
@@ -615,14 +649,11 @@ var CodeBlock = React.forwardRef(function (_ref, ref) {
615
649
  other = _objectWithoutProperties(_ref, _excluded$5);
616
650
  var containerRef = useRef(null);
617
651
  var code = Array.isArray(children) ? children[0] : children;
618
- var _size;
619
- if (size === 'small') {
620
- _size = 'sm';
621
- } else if (size === 'medium') {
622
- _size = 'md';
623
- } else {
624
- _size = 'lg';
625
- }
652
+ var SIZES = {
653
+ small: 'sm',
654
+ medium: 'md',
655
+ large: 'lg'
656
+ };
626
657
  var dependency = useMemo(function () {
627
658
  return [size, children];
628
659
  }, [size, children]);
@@ -630,13 +661,33 @@ var CodeBlock = React.forwardRef(function (_ref, ref) {
630
661
  containerRef: containerRef,
631
662
  dependency: dependency
632
663
  });
664
+ var getDiff = function getDiff(line) {
665
+ var retVal;
666
+ if (language === 'diff') {
667
+ var token = line.find(function (value) {
668
+ return !(value.empty || value.content === '');
669
+ });
670
+ if (token) {
671
+ if (token.types.includes('deleted')) {
672
+ retVal = 'delete';
673
+ } else if (token.types.includes('inserted')) {
674
+ retVal = 'add';
675
+ } else if (token.types.includes('coord')) {
676
+ retVal = 'hunk';
677
+ } else if (token.types.includes('diff')) {
678
+ retVal = 'change';
679
+ }
680
+ }
681
+ }
682
+ return retVal;
683
+ };
633
684
  return React.createElement(StyledCodeBlockContainer, _extends({}, containerProps, {
634
685
  ref: containerRef,
635
686
  tabIndex: containerTabIndex
636
687
  }), React.createElement(Highlight, {
637
688
  Prism: Prism,
638
689
  code: code ? code.trim() : '',
639
- language: language || 'tsx'
690
+ language: LANGUAGES.includes(language) ? language : 'tsx'
640
691
  }, function (_ref2) {
641
692
  var className = _ref2.className,
642
693
  tokens = _ref2.tokens,
@@ -651,10 +702,12 @@ var CodeBlock = React.forwardRef(function (_ref, ref) {
651
702
  line: line
652
703
  }), {
653
704
  key: index,
705
+ language: language,
654
706
  isHighlighted: highlightLines && highlightLines.includes(index + 1),
655
707
  isLight: isLight,
656
708
  isNumbered: isNumbered,
657
- size: _size
709
+ diff: getDiff(line),
710
+ size: size ? SIZES[size] : undefined
658
711
  }), line.map(function (token, tokenKey) {
659
712
  return React.createElement(StyledCodeBlockToken, _extends({}, getTokenProps({
660
713
  token: token
@@ -5,10 +5,10 @@
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
7
  import React, { HTMLAttributes } from 'react';
8
- import { Language } from 'prism-react-renderer';
8
+ declare const LANGUAGES: readonly ["markup", "bash", "clike", "c", "cpp", "css", "javascript", "jsx", "coffeescript", "actionscript", "css-extr", "diff", "git", "go", "graphql", "handlebars", "json", "less", "makefile", "markdown", "objectivec", "ocaml", "python", "reason", "sass", "scss", "sql", "stylus", "tsx", "typescript", "wasm", "yaml"];
9
9
  export interface ICodeBlockProps extends HTMLAttributes<HTMLPreElement> {
10
- /** Selects the language used by the Prism tokenizer */
11
- language?: Language;
10
+ /** Selects the language used by the [Prism](https://prismjs.com/) tokenizer */
11
+ language?: typeof LANGUAGES[number];
12
12
  /** Specifies the font size */
13
13
  size?: 'small' | 'medium' | 'large';
14
14
  /** Applies light mode styling */
@@ -24,3 +24,4 @@ export interface ICodeBlockProps extends HTMLAttributes<HTMLPreElement> {
24
24
  * @extends HTMLAttributes<HTMLPreElement>
25
25
  */
26
26
  export declare const CodeBlock: React.ForwardRefExoticComponent<ICodeBlockProps & React.RefAttributes<HTMLPreElement>>;
27
+ export {};
@@ -5,11 +5,16 @@
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
7
  import { DefaultTheme } from 'styled-components';
8
+ import { Language } from 'prism-react-renderer';
9
+ export declare type DIFF = 'hunk' | 'add' | 'delete' | 'change';
10
+ export declare type SIZE = 'sm' | 'md' | 'lg';
8
11
  export interface IStyledCodeBlockLineProps {
12
+ language?: Language;
9
13
  isHighlighted?: boolean;
10
14
  isLight?: boolean;
11
15
  isNumbered?: boolean;
12
- size?: 'sm' | 'md' | 'lg';
16
+ diff?: DIFF;
17
+ size?: SIZE;
13
18
  }
14
19
  /**
15
20
  * 1. Fix line display for mobile.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zendeskgarden/react-typography",
3
- "version": "8.40.1",
3
+ "version": "8.42.2",
4
4
  "description": "Components relating to typography in the Garden Design System",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Zendesk Garden <garden@zendesk.com>",
@@ -33,7 +33,7 @@
33
33
  "styled-components": "^4.2.0 || ^5.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@zendeskgarden/react-theming": "^8.40.1"
36
+ "@zendeskgarden/react-theming": "^8.42.2"
37
37
  },
38
38
  "keywords": [
39
39
  "components",
@@ -45,5 +45,5 @@
45
45
  "access": "public"
46
46
  },
47
47
  "zendeskgarden:src": "src/index.ts",
48
- "gitHead": "7feeb65e934f41f48757fcd3bd0d36287b893fae"
48
+ "gitHead": "4d3dfab413c6a167dcaf6f9cc674160455881407"
49
49
  }