-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "DARK: remove code component (#217)"
This reverts commit dcad054.
- Loading branch information
Showing
7 changed files
with
291 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<script setup lang="ts"> | ||
import { onMounted, ref } from 'vue'; | ||
import Prism from 'prismjs'; | ||
import './themes/dark.css'; | ||
import './themes/line-numbers.css'; | ||
import './languages'; | ||
import 'prismjs/plugins/line-numbers/prism-line-numbers.js'; | ||
import type { Language } from './types'; | ||
const props = withDefaults(defineProps<{ | ||
code?: string | ||
language?: Language | ||
showLineNumbers?: boolean | ||
}>(), { | ||
code: 'const data = 1;', | ||
language: 'js', | ||
showLineNumbers: true, | ||
}); | ||
const codeRef = ref(); | ||
onMounted(() => { | ||
if (codeRef.value) { | ||
codeRef.value.innerHTML = codeRef.value.innerHTML.trim(); | ||
Prism.highlightAll(); | ||
} | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<pre :class="[`language-${props.language}`, { 'line-numbers': props.showLineNumbers }]"> | ||
<code ref="codeRef">{{ code }}</code> | ||
</pre> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
pre code[ref="codeRef"] { | ||
white-space: pre-line; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import 'prismjs/components/prism-typescript'; | ||
import 'prismjs/components/prism-git'; | ||
import 'prismjs/components/prism-scss'; | ||
import 'prismjs/components/prism-markdown'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
/** | ||
* Shades of Purple Theme for Prism.js | ||
* | ||
* @author Ahmad Awais <https://twitter.com/MrAhmadAwais/> | ||
* @support Follow/tweet at https://twitter.com/MrAhmadAwais/ | ||
*/ | ||
|
||
code[class*='language-'], | ||
pre[class*='language-'] { | ||
color: #9efeff; | ||
direction: ltr; | ||
text-align: left; | ||
white-space: pre; | ||
word-spacing: normal; | ||
word-break: normal; | ||
|
||
-moz-tab-size: 4; | ||
-o-tab-size: 4; | ||
tab-size: 4; | ||
|
||
-webkit-hyphens: none; | ||
-moz-hyphens: none; | ||
-ms-hyphens: none; | ||
hyphens: none; | ||
|
||
font-family: 'Operator Mono', 'Fira Code', Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; | ||
font-weight: 400; | ||
font-size: 17px; | ||
line-height: 25px; | ||
letter-spacing: 0.5px; | ||
text-shadow: 0 1px #222245; | ||
border-radius: 8px | ||
} | ||
pre[class*='language-']{ | ||
white-space: normal; | ||
} | ||
pre[class*='language-']::-moz-selection, | ||
pre[class*='language-'] ::-moz-selection, | ||
code[class*='language-']::-moz-selection, | ||
code[class*='language-'] ::-moz-selection, | ||
pre[class*='language-']::selection, | ||
pre[class*='language-'] ::selection, | ||
code[class*='language-']::selection, | ||
code[class*='language-'] ::selection { | ||
color: inherit; | ||
background: #a599e9; | ||
} | ||
|
||
/* Code blocks. */ | ||
pre[class*='language-'] { | ||
padding: 1.5em; | ||
margin: 0; | ||
overflow: auto; | ||
box-sizing: border-box; | ||
max-width: 100%; | ||
} | ||
|
||
:not(pre) > code[class*='language-'], | ||
pre[class*='language-'] { | ||
background: #1e1e3f; | ||
} | ||
|
||
/* Inline code */ | ||
:not(pre) > code[class*='language-'] { | ||
padding: 0.1em; | ||
border-radius: 0.3em; | ||
} | ||
|
||
.token { | ||
font-weight: 400; | ||
} | ||
|
||
.token.comment, | ||
.token.prolog, | ||
.token.cdata { | ||
color: #b362ff; | ||
} | ||
|
||
.token.delimiter, | ||
.token.keyword, | ||
.token.selector, | ||
.token.important, | ||
.token.atrule { | ||
color: #ff9d00; | ||
} | ||
|
||
.token.operator, | ||
.token.attr-name { | ||
color: rgb(255, 180, 84); | ||
} | ||
|
||
.token.punctuation { | ||
color: #ffffff; | ||
} | ||
|
||
.token.boolean { | ||
color: rgb(255, 98, 140); | ||
} | ||
|
||
.token.tag, | ||
.token.tag .punctuation, | ||
.token.doctype, | ||
.token.builtin { | ||
color: rgb(255, 157, 0); | ||
} | ||
|
||
.token.entity, | ||
.token.symbol { | ||
color: #6897bb; | ||
} | ||
|
||
.token.number { | ||
color: #ff628c; | ||
} | ||
|
||
.token.property, | ||
.token.constant, | ||
.token.variable { | ||
color: #ff628c; | ||
} | ||
|
||
.token.string, | ||
.token.char { | ||
color: #a5ff90; | ||
} | ||
|
||
.token.attr-value, | ||
.token.attr-value .punctuation { | ||
color: #a5c261; | ||
} | ||
|
||
.token.attr-value .punctuation:first-child { | ||
color: #a9b7c6; | ||
} | ||
|
||
.token.url { | ||
color: #287bde; | ||
text-decoration: underline; | ||
} | ||
|
||
.token.function { | ||
color: rgb(250, 208, 0); | ||
} | ||
|
||
.token.regex { | ||
background: #364135; | ||
} | ||
|
||
.token.bold { | ||
font-weight: bold; | ||
} | ||
|
||
.token.italic { | ||
font-style: italic; | ||
} | ||
|
||
.token.inserted { | ||
background: #00ff00; | ||
} | ||
|
||
.token.deleted { | ||
background: #ff000d; | ||
} | ||
|
||
code.language-css .token.property, | ||
code.language-css .token.property + .token.punctuation { | ||
color: #a9b7c6; | ||
} | ||
|
||
code.language-css .token.id { | ||
color: #ffc66d; | ||
} | ||
|
||
code.language-css .token.selector > .token.class, | ||
code.language-css .token.selector > .token.attribute, | ||
code.language-css .token.selector > .token.pseudo-class, | ||
code.language-css .token.selector > .token.pseudo-element { | ||
color: #ffc66d; | ||
} | ||
|
||
.token.class-name { | ||
color: #fb94ff; | ||
} | ||
|
||
.token.operator, | ||
.token.entity, | ||
.token.url, | ||
.language-css .token.string, | ||
.style .token.string { | ||
background: none; | ||
} | ||
|
||
.line-highlight.line-highlight { | ||
margin-top: 36px; | ||
background: linear-gradient(to right, rgba(179, 98, 255, 0.17), transparent); | ||
} | ||
|
||
.line-highlight.line-highlight:before, | ||
.line-highlight.line-highlight[data-end]:after { | ||
content: ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
pre[class*="language-"].line-numbers { | ||
position: relative; | ||
padding-left: 3.8em; | ||
counter-reset: linenumber; | ||
} | ||
|
||
pre[class*="language-"].line-numbers > code { | ||
position: relative; | ||
display: block | ||
} | ||
|
||
.line-numbers .line-numbers-rows { | ||
position: absolute; | ||
top: 0; | ||
left: -3.8em; | ||
width: 3em; /* works for line-numbers below 1000 lines */ | ||
border-right: 1px solid #999; | ||
font-size: 100%; | ||
letter-spacing: -1px; | ||
pointer-events: none; | ||
user-select: none; | ||
user-select: none; | ||
user-select: none; | ||
user-select: none; | ||
} | ||
|
||
.line-numbers-rows > span { | ||
display: block; | ||
counter-increment: linenumber; | ||
} | ||
|
||
.line-numbers-rows > span::before { | ||
content: counter(linenumber); | ||
display: block; | ||
padding-right: 0.8em; | ||
color: #999; | ||
text-align: right; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type Language = 'scss' | 'css' | 'html' | 'markdown' | 'md' | 'typescript' | 'ts' | 'git' | 'javascript' | 'js' | 'markup'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters