Skip to content

Commit

Permalink
feat(theme): support code block theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Mar 1, 2022
1 parent b411a29 commit 5a644dd
Show file tree
Hide file tree
Showing 26 changed files with 2,428 additions and 293 deletions.
74 changes: 37 additions & 37 deletions packages/theme/src/client/styles/code/base.scss
Expand Up @@ -3,6 +3,7 @@
code[class*="language-"],
pre[class*="language-"] {
background: none;
color: var(--code-color);
font-family: var(--font-family-code);
font-size: 1em;
text-align: left;
Expand All @@ -11,10 +12,6 @@ pre[class*="language-"] {
word-break: normal;
word-wrap: normal;

-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;

-webkit-hyphens: none;
-moz-hyphens: none;
hyphens: none;
Expand Down Expand Up @@ -81,8 +78,11 @@ div[class*="language-"] {
pre[class*="language-"] {
position: relative;
z-index: 1;
background: transparent;

// TODO: Add this in docs
// force override the background color to be compatible with shiki
background: transparent !important;
// background: transparent !important;
}

.highlight-lines {
Expand All @@ -95,20 +95,32 @@ div[class*="language-"] {

line-height: 1.4;
user-select: none;

.highlight-line {
background-color: var(--code-highlight-line-color);
}
}

&:not(.line-numbers-mode) {
.line-numbers {
display: none;
}
.highlight-line {
background-color: var(--code-highlight-line-color);
}

&.line-numbers-mode {
.highlight-lines .highlight-line {
&::after {
content: "";
position: absolute;
z-index: 2;
top: 0;
left: 0;
width: var(--line-numbers-width);
height: 100%;

border-radius: 6px 0 0 6px;
border-right: 1px solid var(--code-highlight-line-color);

// edited
@media (max-width: hope-config.$mobileS) {
border-radius: 0;
}
}

.highlight-line {
position: relative;

&:before {
Expand Down Expand Up @@ -146,32 +158,20 @@ div[class*="language-"] {
br {
user-select: none;
}

.line-number {
position: relative;
z-index: 4;
user-select: none;
font-size: 0.85em;
line-height: 0;
}
}

&::after {
content: "";
position: absolute;
z-index: 2;
top: 0;
left: 0;
width: var(--line-numbers-width);
height: 100%;

border-radius: 6px 0 0 6px;
border-right: 1px solid var(--code-highlight-line-color);
.line-number {
position: relative;
z-index: 4;
user-select: none;
font-size: 0.85em;
line-height: 0;
}
}

// edited
@media (max-width: hope-config.$mobileS) {
border-radius: 0;
}
&:not(.line-numbers-mode) {
.line-numbers {
display: none;
}
}
}
Expand Down
94 changes: 0 additions & 94 deletions packages/theme/src/client/styles/code/dark.scss

This file was deleted.

12 changes: 10 additions & 2 deletions packages/theme/src/client/styles/code/index.scss
@@ -1,3 +1,11 @@
@use "sass:meta";
@use "@sass-palette/hope-config";
@use "base";
@use "dark";
@use "light";

#{hope-config.$lightSelector} {
@include meta.load-css("theme/#{hope-config.$codeLightTheme}");
}

#{hope-config.$darkSelector} {
@include meta.load-css("theme/#{hope-config.$codeDarkTheme}");
}
109 changes: 0 additions & 109 deletions packages/theme/src/client/styles/code/light.scss

This file was deleted.

0 comments on commit 5a644dd

Please sign in to comment.