Skip to content

Commit

Permalink
fix(typeit): typeit code highlight (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq authored Apr 29, 2020
1 parent f6f7d91 commit 56026f9
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 97 deletions.
189 changes: 96 additions & 93 deletions assets/css/_partial/_single/_code.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,135 +54,138 @@ code, pre, .highlight table, .highlight tr, .highlight td {
}
}

.highlight > .chroma {
position: relative;
.highlight {
line-height: 1.4em;
margin: .5rem 0;

.code-header {
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
width: 100%;
font-family: $global-font-family;
font-weight: bold;
color: $code-info-color;
background: darken($code-background-color, 8%);
> .chroma {
position: relative;

[theme=dark] & {
color: $code-info-color-dark;
background: darken($code-background-color-dark, 6%);
}

&:hover {
cursor: pointer;
}

.code-title {
.code-header {
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
width: 100%;
padding: .4rem;
}
font-family: $global-font-family;
font-weight: bold;
color: $code-info-color;
background: darken($code-background-color, 8%);

.code-title::after {
padding-left: .2rem;
content: 'Code';
}
[theme=dark] & {
color: $code-info-color-dark;
background: darken($code-background-color-dark, 6%);
}

@each $type, $text in $code-type-map {
&.#{$type} .code-title::after {
content: $text;
&:hover {
cursor: pointer;
}
}
}

.lntd:first-child {
min-width: 1.6rem;
text-align: right;
}
.code-title {
width: 100%;
padding: .4rem;
}

.lntd:last-child {
width: 100%;
.code-title::after {
padding-left: .2rem;
content: 'Code';
}

pre {
@include max-content(min-width);
@each $type, $text in $code-type-map {
&.#{$type} .code-title::after {
content: $text;
}
}
}
}

.ln {
padding-right: .75rem;
}

.hl {
display: block;
background-color: darken($code-background-color, 10%);

[theme=dark] & {
background-color: darken($code-background-color-dark, 5%);
.lntd:first-child {
min-width: 1.6rem;
text-align: right;
}
}

.ln, .lnt {
color: $global-font-secondary-color;
.lntd:last-child {
width: 100%;

[theme=dark] & {
color: $global-font-secondary-color-dark;
pre {
@include max-content(min-width);
}
}
}

.arrow {
padding: 0 .2rem;
@include transition(transform 0.2s ease);
}

.ellipses {
padding: .4rem;
}

.copy {
display: none;
padding: .4rem;
.ln {
padding-right: .75rem;
}

&:hover {
cursor: pointer;
color: $global-link-hover-color;
.hl {
display: block;
background-color: darken($code-background-color, 10%);

[theme=dark] & {
color: $global-link-hover-color-dark;
background-color: darken($code-background-color-dark, 5%);
}
}
}

.table-wrapper {
max-height: 0;
overflow-y: hidden;
@include details-transition-open;
}

&.open {
.code-header {
background: darken($code-background-color, 3%);
.ln, .lnt {
color: $global-font-secondary-color;

[theme=dark] & {
background: darken($code-background-color-dark, 3%);
color: $global-font-secondary-color-dark;
}
}

.table-wrapper {
max-height: $MAX_LENGTH;
@include details-transition-close;
}

.arrow {
@include transform(rotate(90deg));
padding: 0 .2rem;
@include transition(transform 0.2s ease);
}

.ellipses {
display: none;
padding: .4rem;
}

.copy {
display: inline;
display: none;
padding: .4rem;

&:hover {
cursor: pointer;
color: $global-link-hover-color;

[theme=dark] & {
color: $global-link-hover-color-dark;
}
}
}

.table-wrapper {
max-height: 0;
overflow-y: hidden;
@include details-transition-open;
}

&.open {
.code-header {
background: darken($code-background-color, 3%);

[theme=dark] & {
background: darken($code-background-color-dark, 3%);
}
}

.table-wrapper {
max-height: $MAX_LENGTH;
@include details-transition-close;
}

.arrow {
@include transform(rotate(90deg));
}

.ellipses {
display: none;
}

.copy {
display: inline;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{- end -}}

{{- $params := .Params | merge .Site.Params.page -}}
{{- .Scratch.Set "version" "0.2.0" -}}
{{- .Scratch.Set "version" "0.2.2" -}}

{{- if eq hugo.Environment "production" -}}
{{- .Scratch.Set "cdn" .Site.Params.cdn -}}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 56026f9

Please # to comment.