@mantine/code-highlight 7.3.0-alpha.1 → 7.3.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantine/code-highlight",
3
- "version": "7.3.0-alpha.1",
3
+ "version": "7.3.0-alpha.2",
4
4
  "description": "Code highlight with Mantine theme",
5
5
  "homepage": "https://mantine.dev/others/prism/",
6
6
  "license": "MIT",
@@ -36,17 +36,17 @@
36
36
  "default": "./cjs/index.cjs"
37
37
  }
38
38
  },
39
- "./styles.css": "./esm/index.css",
40
- "./styles.layer.css": "./esm/index.layer.css"
39
+ "./styles.css": "./styles.css",
40
+ "./styles.layer.css": "./styles.layer.css"
41
41
  },
42
42
  "repository": {
43
43
  "url": "https://github.com/mantinedev/mantine.git",
44
44
  "type": "git",
45
- "directory": "src/mantine-prism"
45
+ "directory": "packages/@mantine/code-highlight"
46
46
  },
47
47
  "peerDependencies": {
48
- "@mantine/core": "7.3.0-alpha.1",
49
- "@mantine/hooks": "7.3.0-alpha.1",
48
+ "@mantine/core": "7.3.0-alpha.2",
49
+ "@mantine/hooks": "7.3.0-alpha.2",
50
50
  "react": "^18.2.0",
51
51
  "react-dom": "^18.2.0"
52
52
  },
@@ -55,8 +55,8 @@
55
55
  "highlight.js": "^11.9.0"
56
56
  },
57
57
  "devDependencies": {
58
- "@mantine/core": "7.3.0-alpha.1",
59
- "@mantine/hooks": "7.3.0-alpha.1",
60
- "@tests/core": "1.0.0"
58
+ "@mantine-tests/core": "1.0.1",
59
+ "@mantine/core": "7.3.0-alpha.2",
60
+ "@mantine/hooks": "7.3.0-alpha.2"
61
61
  }
62
62
  }
package/esm/index.css DELETED
@@ -1 +0,0 @@
1
- .m-5caae6d3{border-radius:var(--mantine-radius-xs);display:inline-block;font-family:var(--mantine-font-family-monospace);font-size:calc(.8125rem*var(--mantine-scale));line-height:var(--_code-line-height,var(--mantine-line-height));padding:calc(.0625rem*var(--mantine-scale)) calc(.1875rem*var(--mantine-scale))}.m-2c47c4fd{--_code-line-height:1.7;display:block;margin:0;padding:var(--mantine-spacing-xs) var(--mantine-spacing-md)}.m-e58679f3{align-items:flex-start;display:flex;justify-content:space-between}.m-be7e9c9c{display:flex;margin-right:calc(.4375rem*var(--mantine-scale));margin-top:calc(.4375rem*var(--mantine-scale))}.m-5caae85b,.m-d498bab7{background-color:transparent;color:var(--mantine-color-dimmed);margin:0;opacity:.8}@media (hover:hover){.m-5caae85b:hover,.m-d498bab7:hover{opacity:1}}@media (hover:none){.m-5caae85b:active,.m-d498bab7:active{opacity:1}}@media (max-width:40em){.m-5caae85b,.m-d498bab7{display:none}}.m-5caae85b{position:absolute;right:calc(.3125rem*var(--mantine-scale));top:calc(.3125rem*var(--mantine-scale));z-index:1}.m-5cac2e62{align-items:center;background-color:var(--_file-bg);border:calc(.0625rem*var(--mantine-scale)) solid var(--_file-bd);border-left:0;border-top:0;color:var(--_file-color);cursor:var(--_file-cursor);display:flex;font-family:var(--mantine-font-family-monospace);font-size:var(--mantine-font-size-xs);font-weight:700;gap:calc(.4375rem*var(--mantine-scale));justify-content:center;line-height:1;margin:0;opacity:var(--_file-opacity);padding:calc(.4375rem*var(--mantine-scale)) calc(.75rem*var(--mantine-scale));user-select:none;white-space:nowrap}@media (hover:hover){.m-5cac2e62:hover{--_file-opacity:1}}@media (hover:none){.m-5cac2e62:active{--_file-opacity:1}}.m-5cac2e62:last-of-type{border-bottom-right-radius:var(--mantine-radius-sm)}.m-5cac2e62:only-child{--_file-cursor:default}.m-5cac2e62[data-active]{--_file-opacity:1;--_file-color:var(--_file-active-color)!important;--_file-bg:var(--_file-active-bg)}.m-5cac2e62{--_file-opacity:0.8;--_file-cursor:pointer}[data-mantine-color-scheme=light] .m-5cac2e62{--_file-color:var(--mantine-color-gray-8);--_file-bd:var(--mantine-color-gray-2);--_file-active-bg:var(--mantine-color-white);--_file-active-color:var(--mantine-color-black)}[data-mantine-color-scheme=dark] .m-5cac2e62{--_file-color:var(--mantine-color-dark-0);--_file-bd:var(--mantine-color-dark-4);--_file-active-bg:var(--mantine-color-dark-6);--_file-active-color:var(--mantine-color-white)}.m-38d99e51{display:flex}.m-9f507240{max-height:var(--ch-max-collapsed-height);overflow:hidden;position:relative}.m-9f507240:before{background-image:linear-gradient(0deg,var(--_background) 16%,transparent 100%);border-radius:calc(var(--mantine-radius-md) - .0625rem*var(--mantine-scale));content:"";inset:0;pointer-events:none;position:absolute;z-index:100}.m-9f507240[data-expanded]{max-height:none}.m-9f507240[data-expanded]:before{display:none}.m-c9378bc2{bottom:0;color:var(--mantine-color-anchor);font-size:var(--mantine-font-size-sm);left:50%;padding-bottom:var(--mantine-spacing-xs);padding-top:var(--mantine-spacing-xs);position:absolute;text-align:center;transform:translateX(-50%);width:100%;z-index:101}.m-c9378bc2[data-hidden]{display:none}.m-5cb1b9c8{margin-top:0;position:relative}.m-5cb1b9c8[data-collapsed] .mantine-ScrollArea-viewport>div{display:block!important}.m-b46cddfb{align-items:center;display:flex;flex:0;justify-content:center}.m-b46cddfb>svg{display:block}.m-1f5e827e{background:var(--_background);color:var(--_color)}[data-mantine-color-scheme=light] .m-1f5e827e{--_color:var(--mantine-color-gray-7);--_background:var(--mantine-color-gray-0);--code-comment-color:var(--mantine-color-gray-6);--code-keyword-color:var(--mantine-color-violet-8);--code-tag-color:var(--mantine-color-red-9);--code-literal-color:var(--mantine-color-blue-6);--code-string-color:var(--mantine-color-blue-9);--code-variable-color:var(--mantine-color-lime-9);--code-class-color:var(--mantine-color-orange-9)}[data-mantine-color-scheme=dark] .m-1f5e827e{--_color:var(--mantine-color-dark-1);--_background:var(--mantine-color-dark-8);--code-comment-color:var(--mantine-color-dark-3);--code-keyword-color:var(--mantine-color-violet-3);--code-tag-color:var(--mantine-color-yellow-4);--code-literal-color:var(--mantine-color-blue-4);--code-string-color:var(--mantine-color-green-6);--code-variable-color:var(--mantine-color-blue-2);--code-class-color:var(--mantine-color-orange-5)}.m-1f5e827e .hljs-comment,.m-1f5e827e .hljs-quote{color:var(--code-comment-color);font-style:italic}.m-1f5e827e .hljs-doctag,.m-1f5e827e .hljs-formula,.m-1f5e827e .hljs-keyword{color:var(--code-keyword-color)}.m-1f5e827e .hljs-deletion,.m-1f5e827e .hljs-name,.m-1f5e827e .hljs-section,.m-1f5e827e .hljs-selector-tag,.m-1f5e827e .hljs-subst{color:var(--code-tag-color)}.m-1f5e827e .hljs-literal{color:var(--code-literal-color)}.m-1f5e827e .hljs-addition,.m-1f5e827e .hljs-attribute,.m-1f5e827e .hljs-meta .hljs-string,.m-1f5e827e .hljs-regexp,.m-1f5e827e .hljs-string{color:var(--code-string-color)}.m-1f5e827e .hljs-attr,.m-1f5e827e .hljs-number,.m-1f5e827e .hljs-selector-attr,.m-1f5e827e .hljs-selector-class,.m-1f5e827e .hljs-selector-pseudo,.m-1f5e827e .hljs-template-variable,.m-1f5e827e .hljs-type,.m-1f5e827e .hljs-variable{color:var(--code-variable-color)}.m-1f5e827e .hljs-built_in,.m-1f5e827e .hljs-bullet,.m-1f5e827e .hljs-class .hljs-title,.m-1f5e827e .hljs-link,.m-1f5e827e .hljs-meta,.m-1f5e827e .hljs-selector-id,.m-1f5e827e .hljs-symbol,.m-1f5e827e .hljs-title,.m-1f5e827e .hljs-title.class_{color:var(--code-class-color)}.m-1f5e827e .hljs-emphasis{font-style:italic}.m-1f5e827e .hljs-strong{font-weight:700}.m-1f5e827e .hljs-link{text-decoration:underline}
@@ -1,173 +0,0 @@
1
- .code {
2
- display: inline-block;
3
- padding: rem(1px) rem(3px);
4
- font-size: rem(13px);
5
- border-radius: var(--mantine-radius-xs);
6
- line-height: var(--_code-line-height, var(--mantine-line-height));
7
- font-family: var(--mantine-font-family-monospace);
8
- }
9
-
10
- .pre {
11
- display: block;
12
- padding: var(--mantine-spacing-xs) var(--mantine-spacing-md);
13
- margin: 0;
14
- --_code-line-height: 1.7;
15
- }
16
-
17
- .header {
18
- display: flex;
19
- align-items: flex-start;
20
- justify-content: space-between;
21
- }
22
-
23
- .controls {
24
- display: flex;
25
- margin-top: rem(7px);
26
- margin-right: rem(7px);
27
- }
28
-
29
- .copy,
30
- .control {
31
- background-color: transparent;
32
- opacity: 0.8;
33
- margin: 0;
34
- color: var(--mantine-color-dimmed);
35
-
36
- @mixin hover {
37
- opacity: 1;
38
- }
39
-
40
- @media (max-width: 40em) {
41
- display: none;
42
- }
43
- }
44
-
45
- .copy {
46
- position: absolute;
47
- top: rem(5px);
48
- right: rem(5px);
49
- z-index: 1;
50
- }
51
-
52
- .file {
53
- display: flex;
54
- align-items: center;
55
- justify-content: center;
56
- font-size: var(--mantine-font-size-xs);
57
- gap: rem(7px);
58
- padding: rem(7px) rem(12px);
59
- font-family: var(--mantine-font-family-monospace);
60
- font-weight: 700;
61
- line-height: 1;
62
- user-select: none;
63
- cursor: var(--_file-cursor);
64
- border: rem(1px) solid var(--_file-bd);
65
- border-top: 0;
66
- border-left: 0;
67
- color: var(--_file-color);
68
- opacity: var(--_file-opacity);
69
- background-color: var(--_file-bg);
70
- white-space: nowrap;
71
- margin: 0;
72
-
73
- @mixin hover {
74
- --_file-opacity: 1;
75
- }
76
-
77
- &:last-of-type {
78
- border-bottom-right-radius: var(--mantine-radius-sm);
79
- }
80
-
81
- &:only-child {
82
- --_file-cursor: default;
83
- }
84
-
85
- &[data-active] {
86
- --_file-opacity: 1;
87
- --_file-color: var(--_file-active-color) !important;
88
- --_file-bg: var(--_file-active-bg);
89
- }
90
-
91
- --_file-opacity: 0.8;
92
- --_file-cursor: pointer;
93
-
94
- @mixin light {
95
- --_file-color: var(--mantine-color-gray-8);
96
- --_file-bd: var(--mantine-color-gray-2);
97
- --_file-active-bg: var(--mantine-color-white);
98
- --_file-active-color: var(--mantine-color-black);
99
- }
100
-
101
- @mixin dark {
102
- --_file-color: var(--mantine-color-dark-0);
103
- --_file-bd: var(--mantine-color-dark-4);
104
- --_file-active-bg: var(--mantine-color-dark-6);
105
- --_file-active-color: var(--mantine-color-white);
106
- }
107
- }
108
-
109
- .files {
110
- display: flex;
111
- }
112
-
113
- .codeWrapper {
114
- max-height: var(--ch-max-collapsed-height);
115
- overflow: hidden;
116
- position: relative;
117
-
118
- &::before {
119
- content: '';
120
- z-index: 100;
121
- position: absolute;
122
- inset: 0;
123
- pointer-events: none;
124
- background-image: linear-gradient(0deg, var(--_background) 16%, rgba(0, 0, 0, 0) 100%);
125
- border-radius: calc(var(--mantine-radius-md) - rem(1px));
126
- }
127
-
128
- &[data-expanded] {
129
- max-height: none;
130
-
131
- &::before {
132
- display: none;
133
- }
134
- }
135
- }
136
-
137
- .showCodeButton {
138
- position: absolute;
139
- bottom: 0;
140
- left: 50%;
141
- transform: translateX(-50%);
142
- font-size: var(--mantine-font-size-sm);
143
- color: var(--mantine-color-anchor);
144
- width: 100%;
145
- text-align: center;
146
- z-index: 101;
147
- padding-top: var(--mantine-spacing-xs);
148
- padding-bottom: var(--mantine-spacing-xs);
149
-
150
- &[data-hidden] {
151
- display: none;
152
- }
153
- }
154
-
155
- .root {
156
- margin-top: 0;
157
- position: relative;
158
-
159
- &[data-collapsed] :global(.mantine-ScrollArea-viewport > div) {
160
- display: block !important;
161
- }
162
- }
163
-
164
- .fileIcon {
165
- display: flex;
166
- align-items: center;
167
- justify-content: center;
168
- flex: 0;
169
-
170
- & > svg {
171
- display: block;
172
- }
173
- }
@@ -1,273 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { CodeHighlightTabs } from './CodeHighlightTabs';
3
- import { CodeHighlight } from './CodeHighlight';
4
- import { InlineCodeHighlight } from './InlineCodeHighlight';
5
-
6
- export default { title: 'CodeHighlight' };
7
-
8
- const tsxCode = `
9
- import { forwardRef } from 'react';
10
- import { Group, Avatar, Text, Select } from '@mantine/core';
11
-
12
- // Data for select
13
- // You can use any data structure you want
14
-
15
- const data = [
16
- {
17
- image: 'https://img.icons8.com/clouds/256/000000/futurama-bender.png',
18
- label: 'Bender Bending Rodríguez',
19
- value: 'Bender Bending Rodríguez',
20
- description: 'Fascinated with cooking',
21
- },
22
-
23
- {
24
- image: 'https://img.icons8.com/clouds/256/000000/futurama-mom.png',
25
- label: 'Carol Miller',
26
- value: 'Carol Miller',
27
- description: 'One of the richest people on Earth',
28
- },
29
- {
30
- image: 'https://img.icons8.com/clouds/256/000000/homer-simpson.png',
31
- label: 'Homer Simpson',
32
- value: 'Homer Simpson',
33
- description: 'Overweight, lazy, and often ignorant',
34
- },
35
- {
36
- image: 'https://img.icons8.com/clouds/256/000000/spongebob-squarepants.png',
37
- label: 'Spongebob Squarepants',
38
- value: 'Spongebob Squarepants',
39
- description: 'Not just a sponge',
40
- },
41
- ];
42
-
43
- interface ItemProps extends React.ComponentPropsWithoutRef<'div'> {
44
- image: string;
45
- label: string;
46
- description: string;
47
- }
48
-
49
- const SelectItem = forwardRef<HTMLDivElement, ItemProps>(
50
- ({ image, label, description, ...others }: ItemProps, ref) => (
51
- <div ref={ref} {...others}>
52
- <Group noWrap>
53
- <Avatar src={image} />
54
-
55
- <div>
56
- <Text size="sm">{label}</Text>
57
- <Text size="xs" opacity={0.65}>
58
- {description}
59
- </Text>
60
- </div>
61
- </Group>
62
- </div>
63
- )
64
- );
65
-
66
- function Demo() {
67
- return (
68
- <Select
69
- label="Choose employee of the month"
70
- placeholder="Pick one"
71
- itemComponent={SelectItem}
72
- data={data}
73
- searchable
74
- maxDropdownHeight={400}
75
- nothingFound="Nobody here"
76
- filter={(value, item) =>
77
- item.label.toLowerCase().includes(value.toLowerCase().trim()) ||
78
- item.description.toLowerCase().includes(value.toLowerCase().trim())
79
- }
80
- />
81
- );
82
- }
83
- `;
84
-
85
- const cssCode = `.root {
86
- --ai-size-xs: rem(18px);
87
- --ai-size-sm: rem(22px);
88
- --ai-size-md: rem(28px);
89
- --ai-size-lg: rem(34px);
90
- --ai-size-xl: rem(44px);
91
-
92
- --_bg: var(--ai-bg);
93
- --_color: var(--ai-color);
94
- --_cursor: pointer;
95
-
96
- line-height: 1;
97
- display: inline-flex;
98
- align-items: center;
99
- justify-content: center;
100
- position: relative;
101
- user-select: none;
102
-
103
- width: var(--ai-size);
104
- height: var(--ai-size);
105
- min-width: var(--ai-size);
106
- min-height: var(--ai-size);
107
- border-radius: var(--ai-radius);
108
- background: var(--_bg);
109
- color: var(--_color);
110
- border: var(--ai-bd);
111
- cursor: var(--_cursor);
112
-
113
- @mixin hover {
114
- &:not([data-loading]):not(:disabled):not([data-disabled]) {
115
- --_bg: var(--ai-hover);
116
- }
117
- }
118
-
119
- @mixin light {
120
- --_loading-overlay-bg: rgba(255, 255, 255, 0.35);
121
- --_disabled-bg: var(--mantine-color-gray-1);
122
- --_disabled-color: var(--mantine-color-gray-5);
123
- }
124
-
125
- @mixin dark {
126
- --_loading-overlay-bg: rgba(0, 0, 0, 0.35);
127
- --_disabled-bg: var(--mantine-color-dark-6);
128
- --_disabled-color: var(--mantine-color-dark-3);
129
- }
130
-
131
- &[data-loading] {
132
- --_cursor: not-allowed;
133
-
134
- &::before {
135
- content: '';
136
- position: absolute;
137
- inset: rem(-1px);
138
- border-radius: var(--ai-radius);
139
- background-color: var(--_loading-overlay_bg);
140
- }
141
- }
142
-
143
- &:disabled:not([data-loading]),
144
- &[data-disabled]:not([data-loading]) {
145
- --_cursor: not-allowed;
146
- --_bg: var(--_disabled-bg);
147
- --_color: var(--_disabled-color);
148
- }
149
- }
150
-
151
- .loader {
152
- z-index: 1;
153
- }
154
- `;
155
-
156
- function TsIcon(props: React.ComponentProps<'svg'>) {
157
- return (
158
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width={18} height={18} {...props}>
159
- <path fill="#1976d2" d="M6 6h36v36H6z" />
160
- <path
161
- fill="#fff"
162
- d="M27.49 22H14.227v3.264h4.757V40h3.769V25.264h4.737zM39.194 26.084s-1.787-1.192-3.807-1.192-2.747.96-2.747 1.986c0 2.648 7.381 2.383 7.381 7.712 0 8.209-11.254 4.568-11.254 4.568V35.22s2.152 1.622 4.733 1.622 2.483-1.688 2.483-1.92c0-2.449-7.315-2.449-7.315-7.878 0-7.381 10.658-4.469 10.658-4.469l-.132 3.509z"
163
- />
164
- </svg>
165
- );
166
- }
167
-
168
- function CSSIcon(props: React.ComponentProps<'svg'>) {
169
- return (
170
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width={18} height={18} {...props}>
171
- <path fill="#0277BD" d="M41 5H7l3 34 14 4 14-4 3-34z" />
172
- <path fill="#039BE5" d="M24 8v31.9l11.2-3.2L37.7 8z" />
173
- <path fill="#FFF" d="M33.1 13H24v4h4.9l-.3 4H24v4h4.4l-.3 4.5-4.1 1.4v4.2l7.9-2.6.7-11.5z" />
174
- <path
175
- fill="#EEE"
176
- d="M24 13v4h-8.9l-.3-4H24zm-4.6 8l.2 4H24v-4h-4.6zm.4 6h-4l.3 5.5 7.9 2.6v-4.2l-4.1-1.4-.1-2.5z"
177
- />
178
- </svg>
179
- );
180
- }
181
-
182
- export function Usage() {
183
- return (
184
- <div style={{ padding: 40 }}>
185
- <CodeHighlight code={tsxCode} highlightOnClient />
186
- </div>
187
- );
188
- }
189
-
190
- export function Unstyled() {
191
- return (
192
- <div style={{ padding: 40 }}>
193
- <CodeHighlight code={tsxCode} highlightOnClient unstyled />
194
- </div>
195
- );
196
- }
197
-
198
- export function Tabs() {
199
- return (
200
- <div style={{ padding: 40 }}>
201
- <CodeHighlightTabs
202
- code={[
203
- { code: tsxCode, language: 'tsx', icon: <TsIcon />, fileName: 'Component.tsx' },
204
- { code: cssCode, language: 'css', icon: <CSSIcon />, fileName: 'Component.module.css' },
205
- {
206
- code: cssCode,
207
- language: 'css',
208
- icon: <CSSIcon />,
209
- fileName: 'Long-file-name-that-will-break-to-another-line.css',
210
- },
211
- ]}
212
- defaultExpanded={false}
213
- >
214
- {tsxCode}
215
- </CodeHighlightTabs>
216
- </div>
217
- );
218
- }
219
-
220
- export function TabsUnstyled() {
221
- return (
222
- <div style={{ padding: 40 }}>
223
- <CodeHighlightTabs
224
- unstyled
225
- code={[
226
- { code: tsxCode, language: 'tsx', icon: <TsIcon />, fileName: 'Component.tsx' },
227
- { code: cssCode, language: 'css', icon: <CSSIcon />, fileName: 'Component.module.css' },
228
- {
229
- code: cssCode,
230
- language: 'css',
231
- icon: <CSSIcon />,
232
- fileName: 'Long-file-name-that-will-break-to-another-line.css',
233
- },
234
- ]}
235
- defaultExpanded={false}
236
- >
237
- {tsxCode}
238
- </CodeHighlightTabs>
239
- </div>
240
- );
241
- }
242
-
243
- export function Inline() {
244
- return (
245
- <div style={{ padding: 40 }}>
246
- <p>
247
- Hello there! this is{' '}
248
- <InlineCodeHighlight code="import React from 'react';" language="tsx" /> some code Lorem
249
- ipsum dolor sit amet consectetur adipisicing elit. Aliquid reiciendis, facilis repudiandae
250
- vero mollitia non dolorum cupiditate assumenda odio unde quaerat beatae explicabo veritatis
251
- nam temporibus! Quibusdam quod enim voluptatibus?
252
- </p>
253
- </div>
254
- );
255
- }
256
-
257
- export function DataChangesOverTime() {
258
- const [code, setCode] = useState('a');
259
- return (
260
- <>
261
- <button
262
- type="button"
263
- onClick={() => {
264
- setCode((c) => (c === 'a' ? 'b' : 'a'));
265
- }}
266
- >
267
- Toggle
268
- </button>
269
- <CodeHighlight code={code} />
270
- {code}
271
- </>
272
- );
273
- }
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import { render, tests } from '@tests/core';
3
- import { CodeHighlight, CodeHighlightProps, CodeHighlightStylesNames } from './CodeHighlight';
4
-
5
- const defaultProps: CodeHighlightProps = {
6
- code: 'test-code',
7
- };
8
-
9
- describe('@mantine/code-highlight/CodeHighlight', () => {
10
- tests.itSupportsSystemProps<CodeHighlightProps, CodeHighlightStylesNames>({
11
- component: CodeHighlight,
12
- props: defaultProps,
13
- polymorphic: true,
14
- styleProps: true,
15
- extend: true,
16
- variant: true,
17
- size: true,
18
- classes: true,
19
- id: true,
20
- refType: HTMLDivElement,
21
- displayName: '@mantine/core/CodeHighlight',
22
- stylesApiSelectors: ['root', 'code', 'copy', 'pre'],
23
- });
24
-
25
- it('renders copy button based on withCopyButton prop', () => {
26
- const { container, rerender } = render(<CodeHighlight {...defaultProps} withCopyButton />);
27
- expect(container.querySelector('.mantine-CodeHighlight-copy')).toBeInTheDocument();
28
-
29
- rerender(<CodeHighlight {...defaultProps} withCopyButton={false} />);
30
- expect(container.querySelector('.mantine-CodeHighlight-copy')).not.toBeInTheDocument();
31
- });
32
- });
@@ -1,95 +0,0 @@
1
- .theme {
2
- color: var(--_color);
3
- background: var(--_background);
4
-
5
- @mixin light {
6
- --_color: var(--mantine-color-gray-7);
7
- --_background: var(--mantine-color-gray-0);
8
- --code-comment-color: var(--mantine-color-gray-6);
9
- --code-keyword-color: var(--mantine-color-violet-8);
10
- --code-tag-color: var(--mantine-color-red-9);
11
- --code-literal-color: var(--mantine-color-blue-6);
12
- --code-string-color: var(--mantine-color-blue-9);
13
- --code-variable-color: var(--mantine-color-lime-9);
14
- --code-class-color: var(--mantine-color-orange-9);
15
- }
16
-
17
- @mixin dark {
18
- --_color: var(--mantine-color-dark-1);
19
- --_background: var(--mantine-color-dark-8);
20
- --code-comment-color: var(--mantine-color-dark-3);
21
- --code-keyword-color: var(--mantine-color-violet-3);
22
- --code-tag-color: var(--mantine-color-yellow-4);
23
- --code-literal-color: var(--mantine-color-blue-4);
24
- --code-string-color: var(--mantine-color-green-6);
25
- --code-variable-color: var(--mantine-color-blue-2);
26
- --code-class-color: var(--mantine-color-orange-5);
27
- }
28
-
29
- :global(.hljs-comment),
30
- :global(.hljs-quote) {
31
- font-style: italic;
32
- color: var(--code-comment-color);
33
- }
34
-
35
- :global(.hljs-doctag),
36
- :global(.hljs-formula),
37
- :global(.hljs-keyword) {
38
- color: var(--code-keyword-color);
39
- }
40
-
41
- :global(.hljs-deletion),
42
- :global(.hljs-name),
43
- :global(.hljs-section),
44
- :global(.hljs-selector-tag),
45
- :global(.hljs-subst) {
46
- color: var(--code-tag-color);
47
- }
48
-
49
- :global(.hljs-literal) {
50
- color: var(--code-literal-color);
51
- }
52
-
53
- :global(.hljs-addition),
54
- :global(.hljs-attribute),
55
- :global(.hljs-meta .hljs-string),
56
- :global(.hljs-regexp),
57
- :global(.hljs-string) {
58
- color: var(--code-string-color);
59
- }
60
-
61
- :global(.hljs-attr),
62
- :global(.hljs-number),
63
- :global(.hljs-selector-attr),
64
- :global(.hljs-selector-class),
65
- :global(.hljs-selector-pseudo),
66
- :global(.hljs-template-variable),
67
- :global(.hljs-type),
68
- :global(.hljs-variable) {
69
- color: var(--code-variable-color);
70
- }
71
-
72
- :global(.hljs-bullet),
73
- :global(.hljs-link),
74
- :global(.hljs-meta),
75
- :global(.hljs-selector-id),
76
- :global(.hljs-symbol),
77
- :global(.hljs-title),
78
- :global(.hljs-built_in),
79
- :global(.hljs-class .hljs-title),
80
- :global(.hljs-title.class_) {
81
- color: var(--code-class-color);
82
- }
83
-
84
- :global(.hljs-emphasis) {
85
- font-style: italic;
86
- }
87
-
88
- :global(.hljs-strong) {
89
- font-weight: 700;
90
- }
91
-
92
- :global(.hljs-link) {
93
- text-decoration: underline;
94
- }
95
- }