@hyvor/design 0.0.7 → 0.0.8

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,11 +1,12 @@
1
- <script>import "./prism.scss";
1
+ <script>import "./hljs.scss";
2
2
  export let code;
3
3
  export let language = "html";
4
4
  const languagesMap = {
5
- svelte: "tsx"
5
+ svelte: "html",
6
+ jsx: "js"
6
7
  };
7
8
  const languageCode = languagesMap[language] || language;
8
- import getCode, {} from "./prism.js";
9
+ import getCode, {} from "./getCode.js";
9
10
  </script>
10
11
 
11
- <pre class="language-{languageCode}"><code>{@html getCode(code, languageCode)}</code></pre>
12
+ <pre class="language-{languageCode} hljs"><code>{@html getCode(code, languageCode)}</code></pre>
@@ -1,9 +1,9 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import './prism.scss';
2
+ import './hljs.scss';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  code: string;
6
- language?: ("html" | "css" | "ts" | "jsx" | "svelte") | undefined;
6
+ language?: ("css" | "ts" | "html" | "js" | "svelte" | "jsx") | undefined;
7
7
  };
8
8
  events: {
9
9
  [evt: string]: CustomEvent<any>;
@@ -0,0 +1,2 @@
1
+ export type Language = 'html' | 'css' | 'js' | 'ts';
2
+ export default function getCode(code: string, language: Language): string;
@@ -1,15 +1,12 @@
1
- import Prism from 'prismjs';
2
- /**
3
- * This is to prevent Prism not defined error in development
4
- * in SvelteKit
5
- */
6
- if (typeof window !== 'undefined') {
7
- // @ts-ignore
8
- window.Prism = Prism;
9
- }
10
- import 'prismjs/components/prism-typescript.js';
11
- import 'prismjs/components/prism-jsx.js';
12
- import 'prismjs/components/prism-tsx.js';
1
+ import hljs from 'highlight.js/lib/core';
2
+ import javascript from 'highlight.js/lib/languages/javascript';
3
+ import xml from 'highlight.js/lib/languages/xml';
4
+ import css from 'highlight.js/lib/languages/css';
5
+ import ts from 'highlight.js/lib/languages/typescript';
6
+ hljs.registerLanguage('javascript', javascript);
7
+ hljs.registerLanguage('xml', xml);
8
+ hljs.registerLanguage('css', css);
9
+ hljs.registerLanguage('ts', ts);
13
10
  export default function getCode(code, language) {
14
11
  let ret = code;
15
12
  // remove the first empty line
@@ -32,5 +29,5 @@ export default function getCode(code, language) {
32
29
  return line;
33
30
  });
34
31
  ret = lines.join("\n");
35
- return Prism.highlight(ret, Prism.languages[language], language);
32
+ return hljs.highlight(ret, { language }).value;
36
33
  }
@@ -0,0 +1,230 @@
1
+
2
+
3
+ .hljs code {
4
+ color: inherit!important;
5
+ background: inherit!important;
6
+ }
7
+
8
+ /*!
9
+ Theme: StackOverflow Light
10
+ Description: Light theme as used on stackoverflow.com
11
+ Author: stackoverflow.com
12
+ Maintainer: @Hirse
13
+ Website: https://github.com/StackExchange/Stacks
14
+ License: MIT
15
+ Updated: 2021-05-15
16
+
17
+ Updated for @stackoverflow/stacks v0.64.0
18
+ Code Blocks: /blob/v0.64.0/lib/css/components/_stacks-code-blocks.less
19
+ Colors: /blob/v0.64.0/lib/css/exports/_stacks-constants-colors.less
20
+ */
21
+
22
+ .hljs {
23
+ /* var(--highlight-color) */
24
+ color: #2f3337;
25
+ /* var(--highlight-bg) */
26
+ background: #f4f2f0;
27
+ }
28
+
29
+ .hljs-subst {
30
+ /* var(--highlight-color) */
31
+ color: #2f3337;
32
+ }
33
+
34
+ .hljs-comment {
35
+ /* var(--highlight-comment) */
36
+ color: #656e77;
37
+ }
38
+
39
+ .hljs-keyword,
40
+ .hljs-selector-tag,
41
+ .hljs-meta .hljs-keyword,
42
+ .hljs-doctag,
43
+ .hljs-section {
44
+ /* var(--highlight-keyword) */
45
+ color: #015692;
46
+ }
47
+
48
+ .hljs-attr {
49
+ /* var(--highlight-attribute); */
50
+ color: #015692;
51
+ }
52
+
53
+ .hljs-attribute {
54
+ /* var(--highlight-symbol) */
55
+ color: #803378;
56
+ }
57
+
58
+ .hljs-name,
59
+ .hljs-type,
60
+ .hljs-number,
61
+ .hljs-selector-id,
62
+ .hljs-quote,
63
+ .hljs-template-tag {
64
+ /* var(--highlight-namespace) */
65
+ color: #905;
66
+ }
67
+
68
+ .hljs-selector-class {
69
+ /* var(--highlight-keyword) */
70
+ color: #015692;
71
+ }
72
+
73
+ .hljs-string,
74
+ .hljs-regexp,
75
+ .hljs-symbol,
76
+ .hljs-variable,
77
+ .hljs-template-variable,
78
+ .hljs-link,
79
+ .hljs-selector-attr {
80
+ /* var(--highlight-variable) */
81
+ color: #54790d;
82
+ }
83
+
84
+ .hljs-meta,
85
+ .hljs-selector-pseudo {
86
+ /* var(--highlight-keyword) */
87
+ color: #015692;
88
+ }
89
+
90
+ .hljs-built_in,
91
+ .hljs-title,
92
+ .hljs-literal {
93
+ /* var(--highlight-literal) */
94
+ color: #905;
95
+ }
96
+
97
+ .hljs-bullet,
98
+ .hljs-code {
99
+ /* var(--highlight-punctuation) */
100
+ color: #535a60;
101
+ }
102
+
103
+ .hljs-meta .hljs-string {
104
+ /* var(--highlight-variable) */
105
+ color: #54790d;
106
+ }
107
+
108
+ .hljs-deletion {
109
+ /* var(--highlight-deletion) */
110
+ color: #c02d2e;
111
+ }
112
+
113
+ .hljs-addition {
114
+ /* var(--highlight-addition) */
115
+ color: #2f6f44;
116
+ }
117
+
118
+ .hljs-emphasis {
119
+ font-style: italic;
120
+ }
121
+
122
+ .hljs-strong {
123
+ font-weight: bold;
124
+ }
125
+
126
+ .hljs-formula,
127
+ .hljs-operator,
128
+ .hljs-params,
129
+ .hljs-property,
130
+ .hljs-punctuation,
131
+ .hljs-tag {
132
+ /* purposely ignored */
133
+ }
134
+
135
+ :root.dark {
136
+ /*
137
+
138
+ Atom One Dark by Daniel Gamage
139
+ Original One Dark Syntax theme from https://github.com/atom/one-dark-syntax
140
+
141
+ base: #282c34
142
+ mono-1: #abb2bf
143
+ mono-2: #818896
144
+ mono-3: #5c6370
145
+ hue-1: #56b6c2
146
+ hue-2: #61aeee
147
+ hue-3: #c678dd
148
+ hue-4: #98c379
149
+ hue-5: #e06c75
150
+ hue-5-2: #be5046
151
+ hue-6: #d19a66
152
+ hue-6-2: #e6c07b
153
+
154
+ */
155
+
156
+ .hljs {
157
+ color: #abb2bf;
158
+ background: #282c34;
159
+ }
160
+
161
+ .hljs-comment,
162
+ .hljs-quote {
163
+ color: #5c6370;
164
+ font-style: italic;
165
+ }
166
+
167
+ .hljs-doctag,
168
+ .hljs-keyword,
169
+ .hljs-formula {
170
+ color: #c678dd;
171
+ }
172
+
173
+ .hljs-section,
174
+ .hljs-name,
175
+ .hljs-selector-tag,
176
+ .hljs-deletion,
177
+ .hljs-subst {
178
+ color: #e06c75;
179
+ }
180
+
181
+ .hljs-literal {
182
+ color: #56b6c2;
183
+ }
184
+
185
+ .hljs-string,
186
+ .hljs-regexp,
187
+ .hljs-addition,
188
+ .hljs-attribute,
189
+ .hljs-meta .hljs-string {
190
+ color: #98c379;
191
+ }
192
+
193
+ .hljs-attr,
194
+ .hljs-variable,
195
+ .hljs-template-variable,
196
+ .hljs-type,
197
+ .hljs-selector-class,
198
+ .hljs-selector-attr,
199
+ .hljs-selector-pseudo,
200
+ .hljs-number {
201
+ color: #d19a66;
202
+ }
203
+
204
+ .hljs-symbol,
205
+ .hljs-bullet,
206
+ .hljs-link,
207
+ .hljs-meta,
208
+ .hljs-selector-id,
209
+ .hljs-title {
210
+ color: #61aeee;
211
+ }
212
+
213
+ .hljs-built_in,
214
+ .hljs-title.class_,
215
+ .hljs-class .hljs-title {
216
+ color: #e6c07b;
217
+ }
218
+
219
+ .hljs-emphasis {
220
+ font-style: italic;
221
+ }
222
+
223
+ .hljs-strong {
224
+ font-weight: bold;
225
+ }
226
+
227
+ .hljs-link {
228
+ text-decoration: underline;
229
+ }
230
+ }
@@ -99,14 +99,11 @@ content :global(code) {
99
99
  }
100
100
 
101
101
  :global(:root.dark) content :global(code) {
102
- background-color: #262626;
103
- color: #ce9178;
102
+ background-color: #282c34;
103
+ color: #e06c75;
104
104
  }
105
105
 
106
106
  content :global(pre) {
107
- color: #000;
108
- background: #f5f2f0;
109
- text-shadow: 0 1px #fff;
110
107
  text-align: left;
111
108
  white-space: pre;
112
109
  word-spacing: normal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyvor/design",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "scripts": {
@@ -35,8 +35,6 @@
35
35
  "@sveltejs/adapter-static": "^2.0.3",
36
36
  "@sveltejs/kit": "^1.25.1",
37
37
  "@sveltejs/package": "^2.0.0",
38
- "@types/prismjs": "^1.26.1",
39
- "prismjs": "^1.29.0",
40
38
  "publint": "^0.1.9",
41
39
  "sass": "^1.68.0",
42
40
  "svelte": "^4.0.5",
@@ -50,7 +48,8 @@
50
48
  "type": "module",
51
49
  "dependencies": {
52
50
  "@fontsource/readex-pro": "^5.0.8",
53
- "@hyvor/icons": "^0.0.2"
51
+ "@hyvor/icons": "^0.0.2",
52
+ "highlight.js": "^11.9.0"
54
53
  },
55
54
  "publishConfig": {
56
55
  "access": "public"
@@ -1,5 +0,0 @@
1
- import 'prismjs/components/prism-typescript.js';
2
- import 'prismjs/components/prism-jsx.js';
3
- import 'prismjs/components/prism-tsx.js';
4
- export type Language = 'html' | 'css' | 'js' | 'ts' | 'jsx' | 'tsx';
5
- export default function getCode(code: string, language: Language): string;