aboutsummaryrefslogtreecommitdiff
path: root/src/css/_partial/_post/_code.scss
blob: ff4439f22edc78d67f99f829f06eae789ccc3570 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
code, pre {
  padding: 7px;
  font-size: $code-font-size;
  font-family: $code-font-family;
  background: $code-background;
}

code {
  padding: 3px 5px;
  border-radius: 4px;
  color: $code-color;
}

.highlight {
  margin: 1em 0;
  border-radius: 5px;
  overflow-x: auto;
  box-shadow: 1px 1px 2px rgba(0,0,0,0.125);
  position: relative;

  table {
    position: relative;

    &::after {
      position: absolute;
      top: 0;
      right: 0;
      left: 0;
      padding: 2px 7px;
      font-size: $code-font-size;
      font-weight: bold;
      color: darken($gray, 10%);
      background: darken($code-background, 3%);
      content: 'Code';
    }
  }

  @each $sign, $text in $code-type-list {
    &.#{$sign} > table::after {
      content: $text;
    }

    &.#{$sign} > figcaption > span::after {
      content: ' · ' + $text;
    }

    &.#{$sign} figcaption + table {
      &::after {
        display: none;
      }
    }
  }

  figcaption {
    position: absolute;
    top: 0;
    width: 100%;
    padding: 2px 7px;
    font-size: $code-font-size;
    font-weight: bold;
    color: darken($gray, 10%);
    background: darken($code-background, 3%);
    z-index: 20;
    overflow-x: hidden;
    box-sizing: border-box;

    & > a {
      position: absolute;
      right: 0;
      display: inline-box;
      margin-right: 7px;
      font-weight: 400;

      &:hover {
        text-decoration: none;
        border: 0;
      }
    }
  }

  .code {
    pre {
      margin: 0;
      padding: 30px 10px 10px;
    }
  }

  .gutter {
    width: 10px;
    color: $gray;

    pre {
      margin: 0;
      padding: 30px 7px 10px;
    }
  }

  .line {
    // Fix code block null line height and
    // Synchronous gutter and code line highly.
    height: round($code-font-size * 1.5);
  }

  table, tr, td {
    margin: 0;
    padding: 0;
    width: 100%;
    border-collapse: collapse;
  }

  .code {
    .hljs-comment,
    .hljs-quote {
      color: map-get($code-highlight-color, comment);
    }

    .hljs-keyword,
    .hljs-selector-tag,
    .hljs-addition {
      color: map-get($code-highlight-color, keyword);
    }

    .hljs-number,
    .hljs-string,
    .hljs-meta .hljs-meta-string,
    .hljs-literal,
    .hljs-doctag,
    .hljs-regexp {
      color: map-get($code-highlight-color, number);
    }

    .hljs-title,
    .hljs-section,
    .hljs-name,
    .hljs-selector-id,
    .hljs-selector-class {
      color: map-get($code-highlight-color, title);
    }

    .hljs-attribute,
    .hljs-attr,
    .hljs-variable,
    .hljs-template-variable,
    .hljs-class .hljs-title,
    .hljs-type {
      color: map-get($code-highlight-color, attribute);
    }

    .hljs-symbol,
    .hljs-bullet,
    .hljs-subst,
    .hljs-meta,
    .hljs-meta .hljs-keyword,
    .hljs-selector-attr,
    .hljs-selector-pseudo,
    .hljs-link {
      color: map-get($code-highlight-color, symbol);
    }

    .hljs-built_in,
    .hljs-deletion {
      color: map-get($code-highlight-color, built_in);
    }

    .hljs-formula {
      background: map-get($code-highlight-color, formula);
    }
    
    .hljs-emphasis {
      font-style: italic;
    }
    
    .hljs-strong {
      font-weight: bold;
    }
  }
}