|
1 | 1 | @use "../mixins/function" as *;
|
2 | 2 | @use "../mixins/config" as *;
|
3 |
| -@use "../md-plugin/code-arrow"; |
4 | 3 |
|
5 |
| -// 因为 stroke 无法直接写 var(--vp-c-text-1),所以只能写死 var(--vp-c-text-1) 的具体颜色,如果改动了 var(--vp-c-text-1) 的值,则需要修改 stroke 为对于的值 |
6 |
| -:root { |
7 |
| - /* clipboard */ |
8 |
| - --vp-icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='rgba(60,60,67,1)' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 24 24'%3E%3Crect width='8' height='4' x='8' y='2' rx='1' ry='1'/%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3C/svg%3E"); |
9 |
| - /* clipboard-copy */ |
10 |
| - --vp-icon-copied: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='rgba(60,60,67,1)' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 24 24'%3E%3Crect width='8' height='4' x='8' y='2' rx='1' ry='1'/%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3Cpath d='m9 14 2 2 4-4'/%3E%3C/svg%3E"); |
11 |
| -} |
| 4 | +html[code-block="#{$namespace}"] { |
| 5 | + // 因为 stroke 无法直接写 var(--vp-c-text-1),所以只能写死 var(--vp-c-text-1) 的具体颜色,如果改动了 var(--vp-c-text-1) 的值,则需要修改 stroke 为对于的值 |
| 6 | + &:root { |
| 7 | + /* clipboard */ |
| 8 | + --vp-icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='rgba(60,60,67,1)' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 24 24'%3E%3Crect width='8' height='4' x='8' y='2' rx='1' ry='1'/%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3C/svg%3E"); |
| 9 | + /* clipboard-copy */ |
| 10 | + --vp-icon-copied: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='rgba(60,60,67,1)' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 24 24'%3E%3Crect width='8' height='4' x='8' y='2' rx='1' ry='1'/%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3Cpath d='m9 14 2 2 4-4'/%3E%3C/svg%3E"); |
| 11 | + } |
12 | 12 |
|
13 |
| -:root.dark { |
14 |
| - /* clipboard */ |
15 |
| - --vp-icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='rgba(223,223,214,1)' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 24 24'%3E%3Crect width='8' height='4' x='8' y='2' rx='1' ry='1'/%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3C/svg%3E"); |
16 |
| - /* clipboard-copy */ |
17 |
| - --vp-icon-copied: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='rgba(223,223,214,1)' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 24 24'%3E%3Crect width='8' height='4' x='8' y='2' rx='1' ry='1'/%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3Cpath d='m9 14 2 2 4-4'/%3E%3C/svg%3E"); |
18 |
| -} |
| 13 | + &:root.dark { |
| 14 | + /* clipboard */ |
| 15 | + --vp-icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='rgba(223,223,214,1)' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 24 24'%3E%3Crect width='8' height='4' x='8' y='2' rx='1' ry='1'/%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3C/svg%3E"); |
| 16 | + /* clipboard-copy */ |
| 17 | + --vp-icon-copied: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='rgba(223,223,214,1)' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 24 24'%3E%3Crect width='8' height='4' x='8' y='2' rx='1' ry='1'/%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3Cpath d='m9 14 2 2 4-4'/%3E%3C/svg%3E"); |
| 18 | + } |
19 | 19 |
|
20 |
| -.vp-doc div[class*="language-"], |
21 |
| -.#{$namespace}-postItem__info__left__excerpt div[class*="language-"] { |
22 |
| - transition: height 0.3s; |
23 |
| - overflow: hidden; |
| 20 | + .vp-doc div[class*="language-"], |
| 21 | + .#{$namespace}-postItem__info__left__excerpt div[class*="language-"] { |
| 22 | + transition: height 0.3s; |
| 23 | + overflow: hidden; |
24 | 24 |
|
25 |
| - .vp-code { |
26 |
| - padding-top: getCssVar("code-block-fold-height"); |
27 |
| - } |
| 25 | + .vp-code { |
| 26 | + padding-top: getCssVar("code-block-fold-height"); |
| 27 | + } |
28 | 28 |
|
29 |
| - .line-numbers-wrapper { |
30 |
| - margin-top: getCssVar("code-block-fold-height"); |
31 |
| - padding-top: 0; |
32 |
| - } |
| 29 | + .line-numbers-wrapper { |
| 30 | + margin-top: getCssVar("code-block-fold-height"); |
| 31 | + padding-top: 0; |
| 32 | + } |
33 | 33 |
|
34 |
| - /* 代码块三个圆圈 */ |
35 |
| - &::before { |
36 |
| - content: ""; |
37 |
| - display: block; |
38 |
| - position: absolute; |
39 |
| - top: calc(getCssVar("code-block-fold-height") / 2); |
40 |
| - left: 14px; |
41 |
| - transform: translateY(-50%); |
42 |
| - width: 12px; |
43 |
| - height: 12px; |
44 |
| - border-radius: 50%; |
45 |
| - background: #fc625d; |
46 |
| - box-shadow: |
47 |
| - 20px 0 #fdbc40, |
48 |
| - 40px 0 #35cd4b; |
| 34 | + /* 代码块三个圆圈 */ |
| 35 | + &::before { |
| 36 | + content: ""; |
| 37 | + display: block; |
| 38 | + position: absolute; |
| 39 | + top: calc(getCssVar("code-block-fold-height") / 2); |
| 40 | + left: 14px; |
| 41 | + transform: translateY(-50%); |
| 42 | + width: 12px; |
| 43 | + height: 12px; |
| 44 | + border-radius: 50%; |
| 45 | + background: #fc625d; |
| 46 | + box-shadow: |
| 47 | + 20px 0 #fdbc40, |
| 48 | + 40px 0 #35cd4b; |
| 49 | + } |
| 50 | + |
| 51 | + /* 代码块语言 */ |
| 52 | + span.lang { |
| 53 | + position: absolute; |
| 54 | + z-index: 3; |
| 55 | + top: calc(getCssVar("code-block-fold-height") / 2); |
| 56 | + left: 75px; |
| 57 | + transform: translateY(-50%); |
| 58 | + font-size: 18px; |
| 59 | + color: var(--vp-c-text-1); |
| 60 | + text-transform: getCssVar("code-block-lang-transform"); |
| 61 | + font-weight: bold; |
| 62 | + width: fit-content; |
| 63 | + } |
| 64 | + |
| 65 | + /* 一键复制图标 */ |
| 66 | + button.copy { |
| 67 | + width: 18px; |
| 68 | + height: 18px; |
| 69 | + position: absolute; |
| 70 | + top: calc(getCssVar("code-block-fold-height") / 2); |
| 71 | + right: 36px; |
| 72 | + transform: translateY(-50%); |
| 73 | + opacity: 1; |
| 74 | + background-size: 14px; |
| 75 | + background-color: transparent; |
| 76 | + border: none; |
| 77 | + color: var(--vp-c-text-1); |
| 78 | + fill: var(--vp-c-text-1); |
| 79 | + &:hover, |
| 80 | + .copied { |
| 81 | + background-color: transparent; |
| 82 | + border: none; |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + /* 语言和一键复制图标不会消失 */ |
| 87 | + &:hover button.copy + span.lang, |
| 88 | + button.copy:focus + span.lang, |
| 89 | + &:hover > button.copy, |
| 90 | + button.copy:focus { |
| 91 | + opacity: 1; |
| 92 | + } |
49 | 93 | }
|
50 | 94 |
|
51 |
| - /* 代码块语言 */ |
52 |
| - span.lang { |
| 95 | + /* 代码块箭头 */ |
| 96 | + .code-arrow { |
| 97 | + cursor: pointer; |
53 | 98 | position: absolute;
|
54 | 99 | z-index: 3;
|
55 | 100 | top: calc(getCssVar("code-block-fold-height") / 2);
|
56 |
| - left: 75px; |
| 101 | + right: 14px; |
57 | 102 | transform: translateY(-50%);
|
58 |
| - font-size: 18px; |
59 |
| - color: var(--vp-c-text-1); |
60 |
| - text-transform: getCssVar("code-block-lang-transform"); |
61 |
| - font-weight: bold; |
62 |
| - width: fit-content; |
63 |
| - } |
| 103 | + transition: all 0.3s; |
| 104 | + user-select: none; |
64 | 105 |
|
65 |
| - /* 一键复制图标 */ |
66 |
| - button.copy { |
67 |
| - width: 18px; |
68 |
| - height: 18px; |
69 |
| - position: absolute; |
70 |
| - top: calc(getCssVar("code-block-fold-height") / 2); |
71 |
| - right: 36px; |
72 |
| - transform: translateY(-50%); |
73 |
| - opacity: 1; |
74 |
| - background-size: 14px; |
75 |
| - background-color: transparent; |
76 |
| - border: none; |
77 |
| - color: var(--vp-c-text-1); |
78 |
| - fill: var(--vp-c-text-1); |
79 |
| - &:hover, |
80 |
| - .copied { |
81 |
| - background-color: transparent; |
82 |
| - border: none; |
| 106 | + svg { |
| 107 | + width: 16px; |
| 108 | + height: 16px; |
| 109 | + fill: var(--vp-c-text-1); |
83 | 110 | }
|
84 |
| - } |
85 | 111 |
|
86 |
| - /* 语言和一键复制图标不会消失 */ |
87 |
| - &:hover button.copy + span.lang, |
88 |
| - button.copy:focus + span.lang, |
89 |
| - &:hover > button.copy, |
90 |
| - button.copy:focus { |
91 |
| - opacity: 1; |
| 112 | + /* 代码块折叠后后旋转 -90 度 */ |
| 113 | + &.fold { |
| 114 | + transform: rotate(90deg) translateX(-50%); |
| 115 | + } |
92 | 116 | }
|
93 | 117 | }
|
0 commit comments