File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,61 +4,6 @@ import { definePlugin } from "@expressive-code/core";
44export default ( ) => {
55 return definePlugin ( {
66 name : "Adds 'Explain Code' button to code blocks with 10+ lines" ,
7- baseStyles : `
8- .explain-button {
9- position: absolute;
10- top: 0.5rem;
11- right: 0.5rem;
12- z-index: 10;
13- display: flex;
14- align-items: center;
15- justify-content: center;
16- width: 2rem;
17- height: 2rem;
18- padding: 0;
19- border: 1px solid var(--ec-brdCol);
20- border-radius: 0.25rem;
21- background: var(--sl-color-bg);
22- color: var(--sl-color-text);
23- cursor: pointer;
24- transition: all 0.2s;
25- opacity: 1;
26- }
27-
28- .explain-button:hover {
29- background: var(--sl-color-gray-6);
30- border-color: var(--sl-color-text-accent);
31- }
32-
33- .explain-button:focus {
34- outline: 2px solid var(--sl-color-text-accent);
35- outline-offset: 2px;
36- }
37-
38- .explain-button svg {
39- width: 1rem;
40- height: 1rem;
41- }
42-
43- .explain-tooltip {
44- position: absolute;
45- top: -2rem;
46- right: 0;
47- padding: 0.25rem 0.5rem;
48- background: var(--sl-color-black);
49- color: var(--sl-color-white);
50- font-size: 0.75rem;
51- border-radius: 0.25rem;
52- white-space: nowrap;
53- opacity: 0;
54- pointer-events: none;
55- transition: opacity 0.2s;
56- }
57-
58- .explain-button:hover .explain-tooltip {
59- opacity: 1;
60- }
61- ` ,
627 hooks : {
638 postprocessRenderedBlock : async ( context ) => {
649 const lineCount = context . codeBlock . code . split ( "\n" ) . length ;
Original file line number Diff line number Diff line change 1010.has-explain-button + .copy {
1111 right : 3rem ;
1212}
13+
14+ /* Explain Code button styles */
15+ .explain-button {
16+ position : absolute;
17+ top : 0.5rem ;
18+ right : 0.5rem ;
19+ z-index : 10 ;
20+ display : flex;
21+ align-items : center;
22+ justify-content : center;
23+ width : 2rem ;
24+ height : 2rem ;
25+ padding : 0 ;
26+ border : 1px solid # 666a6b ;
27+ border-radius : 0.25rem ;
28+ background : transparent;
29+ color : var (--sl-color-text );
30+ cursor : pointer;
31+ transition : all 0.2s ;
32+ opacity : 1 ;
33+ }
34+
35+ .explain-button : hover {
36+ background : # 525555 ;
37+ border-color : # 909899 ;
38+ }
39+
40+ .explain-button : focus {
41+ outline : 2px solid var (--sl-color-text-accent );
42+ outline-offset : 2px ;
43+ }
44+
45+ .explain-button svg {
46+ width : 1rem ;
47+ height : 1rem ;
48+ }
49+
50+ /* Light mode styles */
51+ @media (prefers-color-scheme : light) {
52+ .explain-button {
53+ border-color : # cdcecf ;
54+ color : # 828587 ;
55+ }
56+
57+ .explain-button : hover {
58+ background : # dededf ;
59+ border-color : # a8aaac ;
60+ color : # 585c5f ;
61+ }
62+ }
63+
64+ .explain-tooltip {
65+ position : absolute;
66+ bottom : calc (100% + 0.25rem );
67+ left : 45% ;
68+ transform : translateX (-50% );
69+ padding : 0.5rem 0.75rem ;
70+ background : var (--sl-color-black );
71+ color : var (--sl-color-white );
72+ font-size : 0.75rem ;
73+ line-height : 1 ;
74+ display : flex;
75+ align-items : center;
76+ justify-content : center;
77+ border : 1px solid var (--sl-color-gray-5 );
78+ white-space : nowrap;
79+ min-width : max-content;
80+ opacity : 0 ;
81+ pointer-events : none;
82+ transition : opacity 0.2s ;
83+ box-shadow : 0 2px 8px rgba (0 , 0 , 0 , 0.15 );
84+ z-index : 100 ;
85+ }
86+
87+ .explain-button : hover .explain-tooltip {
88+ opacity : 1 ;
89+ }
You can’t perform that action at this time.
0 commit comments