@mantine/code-highlight 7.0.0-alpha.2 → 7.0.0-alpha.21

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.
Files changed (55) hide show
  1. package/cjs/CodeHighlight.js +1 -20
  2. package/cjs/CodeHighlight.js.map +1 -1
  3. package/cjs/CodeHighlight.module.css.js +1 -1
  4. package/cjs/CodeHighlight.theme.module.css.js +1 -1
  5. package/cjs/CodeHighlightTabs.js +41 -50
  6. package/cjs/CodeHighlightTabs.js.map +1 -1
  7. package/cjs/CopyIcon.js +14 -24
  8. package/cjs/CopyIcon.js.map +1 -1
  9. package/cjs/ExpandIcon.js +14 -38
  10. package/cjs/ExpandIcon.js.map +1 -1
  11. package/cjs/FileIcon.js +3 -3
  12. package/cjs/FileIcon.js.map +1 -1
  13. package/cjs/InlineCodeHighlight.js +9 -6
  14. package/cjs/InlineCodeHighlight.js.map +1 -1
  15. package/cjs/index.css +91 -127
  16. package/cjs/index.js +1 -0
  17. package/cjs/index.js.map +1 -1
  18. package/cjs/use-highlight.js +3 -1
  19. package/cjs/use-highlight.js.map +1 -1
  20. package/esm/CodeHighlight.js +1 -20
  21. package/esm/CodeHighlight.js.map +1 -1
  22. package/esm/CodeHighlight.module.css.js +1 -1
  23. package/esm/CodeHighlight.theme.module.css.js +1 -1
  24. package/esm/CodeHighlightTabs.js +42 -51
  25. package/esm/CodeHighlightTabs.js.map +1 -1
  26. package/esm/CopyIcon.js +14 -24
  27. package/esm/CopyIcon.js.map +1 -1
  28. package/esm/ExpandIcon.js +14 -38
  29. package/esm/ExpandIcon.js.map +1 -1
  30. package/esm/FileIcon.js +3 -3
  31. package/esm/FileIcon.js.map +1 -1
  32. package/esm/InlineCodeHighlight.js +9 -6
  33. package/esm/InlineCodeHighlight.js.map +1 -1
  34. package/esm/index.css +91 -127
  35. package/esm/index.js +1 -0
  36. package/esm/index.js.map +1 -1
  37. package/esm/use-highlight.js +3 -1
  38. package/esm/use-highlight.js.map +1 -1
  39. package/lib/CodeHighlight.d.ts +0 -3
  40. package/lib/CodeHighlightTabs.d.ts +2 -3
  41. package/lib/CopyIcon.d.ts +1 -1
  42. package/lib/ExpandIcon.d.ts +1 -1
  43. package/lib/FileIcon.d.ts +3 -1
  44. package/lib/InlineCodeHighlight.d.ts +0 -1
  45. package/lib/index.d.ts +3 -3
  46. package/package.json +18 -10
  47. package/src/CodeHighlight.module.css +14 -0
  48. package/src/CodeHighlight.story.tsx +6 -0
  49. package/src/CodeHighlight.tsx +1 -3
  50. package/src/CodeHighlightTabs.tsx +10 -5
  51. package/src/FileIcon.tsx +13 -3
  52. package/src/InlineCodeHighlight.tsx +0 -1
  53. package/src/index.ts +0 -3
  54. package/tsconfig.build.tsbuildinfo +1 -1
  55. package/styles.css +0 -326
@@ -37,9 +37,9 @@ export type CodeHighlightTabsStylesNames =
37
37
  | 'control'
38
38
  | 'header'
39
39
  | 'file'
40
- | 'files';
40
+ | 'files'
41
+ | 'fileIcon';
41
42
 
42
- export type CodeHighlightTabsVariant = string;
43
43
  export type CodeHighlightTabsCssVariables = {
44
44
  root: '--ch-max-collapsed-height';
45
45
  };
@@ -79,7 +79,7 @@ export interface CodeHighlightTabsProps
79
79
  /** Function that returns icon based on file name */
80
80
  getFileIcon?(fileName: string): React.ReactNode;
81
81
 
82
- /** `max-height` of code in collapsed state, `'6rem'` by default */
82
+ /** `max-height` of code in collapsed state */
83
83
  maxCollapsedHeight?: React.CSSProperties['maxHeight'];
84
84
 
85
85
  /** Controlled expanded state */
@@ -111,7 +111,7 @@ const defaultProps: Partial<CodeHighlightTabsProps> = {
111
111
  withHeader: true,
112
112
  copyLabel: 'Copy code',
113
113
  copiedLabel: 'Copied',
114
- maxCollapsedHeight: '8rem',
114
+ maxCollapsedHeight: rem('8rem'),
115
115
  expandCodeLabel: 'Expand code',
116
116
  collapseCodeLabel: 'Collapse code',
117
117
  };
@@ -189,7 +189,12 @@ export const CodeHighlightTabs = factory<CodeHighlightTabsFactory>((_props, ref)
189
189
  mod={{ active: index === value }}
190
190
  onClick={() => setValue(index)}
191
191
  >
192
- <FileIcon fileIcon={node.icon} getFileIcon={getFileIcon} fileName={node.fileName} />
192
+ <FileIcon
193
+ fileIcon={node.icon}
194
+ getFileIcon={getFileIcon}
195
+ fileName={node.fileName}
196
+ {...getStyles('fileIcon')}
197
+ />
193
198
  <span>{node.fileName}</span>
194
199
  </UnstyledButton>
195
200
  ));
package/src/FileIcon.tsx CHANGED
@@ -4,15 +4,25 @@ interface FileIconProps {
4
4
  fileName: string | undefined;
5
5
  getFileIcon?: ((fileName: string) => React.ReactNode) | undefined;
6
6
  fileIcon: React.ReactNode | undefined;
7
+ className?: string;
8
+ style?: React.CSSProperties;
7
9
  }
8
10
 
9
- export function FileIcon({ fileIcon, fileName, getFileIcon }: FileIconProps) {
11
+ export function FileIcon({ fileIcon, fileName, getFileIcon, className, style }: FileIconProps) {
10
12
  if (fileIcon) {
11
- return <>{fileIcon}</>;
13
+ return (
14
+ <span className={className} style={style}>
15
+ {fileIcon}
16
+ </span>
17
+ );
12
18
  }
13
19
 
14
20
  if (getFileIcon && fileName) {
15
- return <>{getFileIcon(fileName)}</>;
21
+ return (
22
+ <span className={className} style={style}>
23
+ {getFileIcon(fileName)}
24
+ </span>
25
+ );
16
26
  }
17
27
 
18
28
  return null;
@@ -17,7 +17,6 @@ import themeClasses from './CodeHighlight.theme.module.css';
17
17
  const classes = { ..._classes, code: cx(_classes.code, themeClasses.theme) };
18
18
 
19
19
  export type InlineCodeHighlightStylesNames = 'code';
20
- export type InlineCodeHighlightVariant = string;
21
20
 
22
21
  export interface InlineCodeHighlightProps
23
22
  extends BoxProps,
package/src/index.ts CHANGED
@@ -6,18 +6,15 @@ export type {
6
6
  CodeHighlightTabsStylesNames,
7
7
  CodeHighlightTabsProps,
8
8
  CodeHighlightTabsCode,
9
- CodeHighlightTabsVariant,
10
9
  CodeHighlightTabsCssVariables,
11
10
  } from './CodeHighlightTabs';
12
11
  export type {
13
12
  CodeHighlightFactory,
14
13
  CodeHighlightProps,
15
14
  CodeHighlightStylesNames,
16
- CodeHighlightVariant,
17
15
  } from './CodeHighlight';
18
16
  export type {
19
17
  InlineCodeHighlightFactory,
20
18
  InlineCodeHighlightProps,
21
19
  InlineCodeHighlightStylesNames,
22
- InlineCodeHighlightVariant,
23
20
  } from './InlineCodeHighlight';