Spaces:
Running
Running
File size: 6,194 Bytes
5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e 5ea40ce 5da533e | 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 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | /* code-snippet.css, reusable "Run this from code" disclosure that sits
under a demo widget. Native <details>/<summary> + two tabs (Endpoint /
Local) + a copy button. Wire-up lives in shared/code-snippet.js. */
.code-snippet {
margin: 18px 0 0;
font-family: "JetBrains Mono", ui-monospace, monospace;
font-size: 11px;
}
/* Disclosure header. Styled as a pill-button so the affordance reads as
a card-level action rather than a faint inline label: warm-off-white
fill + outline, a brand-green </> chip on the left to signal "code",
and a chevron on the right that rotates 90° when the panel is open.
Border + background shift to brand-green tints on hover / open to
reinforce state without needing a separate +/− glyph. */
.code-snippet > summary {
cursor: pointer;
color: #1f1f1d;
font-weight: 600;
letter-spacing: 1.2px;
text-transform: uppercase;
font-size: 10.5px;
padding: 7px 14px 7px 8px;
list-style: none;
display: inline-flex;
align-items: center;
gap: 10px;
user-select: none;
background: #f7f5ee;
border: 1px solid #c8c2b3;
border-radius: 3px;
transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.code-snippet > summary::-webkit-details-marker { display: none; }
.code-snippet > summary:hover {
border-color: var(--green);
background: #f4f8f4;
}
.code-snippet[open] > summary {
border-color: var(--green);
background: #f4f8f4;
}
/* "</>" code chip on the left: solid green pill, white glyph. Same
visual weight as the brand chips used elsewhere in the page. */
.code-snippet > summary::before {
content: "</>";
display: inline-flex;
align-items: center;
justify-content: center;
height: 18px;
padding: 0 5px;
background: var(--green);
color: #ffffff;
font-family: "JetBrains Mono", monospace;
font-weight: 700;
font-size: 10px;
letter-spacing: -0.5px;
border-radius: 2px;
}
/* Chevron on the right, pivots on open via CSS transform. */
.code-snippet > summary::after {
content: "›";
margin-left: 2px;
color: #6b7a6e;
font-size: 14px;
font-weight: 700;
line-height: 0;
transition: transform 0.15s, color 0.15s;
}
.code-snippet > summary:hover::after,
.code-snippet[open] > summary::after {
color: var(--green);
}
.code-snippet[open] > summary::after {
transform: rotate(90deg);
}
.code-snippet__body {
margin-top: 10px;
border: 1px solid #d4dcc9;
border-radius: 3px;
overflow: hidden;
background: #ffffff;
position: relative;
}
.code-snippet__tabs {
display: flex;
align-items: center;
background: #f7f5ee;
border-bottom: 1px solid #d4dcc9;
}
.code-snippet__tab {
padding: 8px 14px;
background: transparent;
border: none;
font-family: inherit;
font-size: 10px;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 1px;
color: #6b7a6e;
cursor: pointer;
border-bottom: 2px solid transparent;
transition: color 0.12s, border-bottom-color 0.12s, background 0.12s;
}
.code-snippet__tab:hover { color: #1f1f1d; background: rgba(0,0,0,0.02); }
.code-snippet__tab.active {
color: #1f1f1d;
border-bottom-color: var(--green);
}
.code-snippet__panel { display: none; background: #ffffff; }
.code-snippet__panel.active { display: block; }
.code-snippet__panel pre {
margin: 0;
padding: 14px 16px;
font-family: "JetBrains Mono", monospace;
font-size: 12px;
line-height: 1.55;
color: #1f1f1d;
background: #ffffff;
overflow-x: auto;
white-space: pre;
tab-size: 4;
}
/* highlight.js sets `background` on the `.hljs` class once it's done
processing a block. Force-override to transparent so our pure-white
panel background shows through regardless of which hljs theme (if any)
gets loaded. */
.code-snippet__panel pre code,
.code-snippet__panel pre code.hljs {
background: transparent;
padding: 0;
color: inherit;
}
/* --- highlight.js token palette --------------------------------------
We intentionally don't load a hljs theme stylesheet. Instead, define
token colours here so the Python snippets stay on-brand: brand green
for keywords / builtins, warm amber for strings, blue for numbers,
italic muted gray for comments. Everything else falls through to the
default ink colour set on <pre>. */
.code-snippet__panel .hljs-comment,
.code-snippet__panel .hljs-quote {
color: #9a958a;
font-style: italic;
}
.code-snippet__panel .hljs-keyword,
.code-snippet__panel .hljs-built_in,
.code-snippet__panel .hljs-literal,
.code-snippet__panel .hljs-type {
color: #317f3f;
}
.code-snippet__panel .hljs-string,
.code-snippet__panel .hljs-regexp,
.code-snippet__panel .hljs-doctag {
color: #a9762f;
}
.code-snippet__panel .hljs-number {
color: #2c5aa0;
}
.code-snippet__panel .hljs-meta,
.code-snippet__panel .hljs-meta .hljs-string {
color: #7a6242;
}
.code-snippet__panel .hljs-title,
.code-snippet__panel .hljs-title.function_,
.code-snippet__panel .hljs-title.class_,
.code-snippet__panel .hljs-class .hljs-title,
.code-snippet__panel .hljs-section {
color: #1f1f1d;
font-weight: 500;
}
.code-snippet__panel .hljs-attr,
.code-snippet__panel .hljs-params,
.code-snippet__panel .hljs-variable,
.code-snippet__panel .hljs-symbol,
.code-snippet__panel .hljs-operator,
.code-snippet__panel .hljs-punctuation {
color: #1f1f1d;
}
/* Copy button. Lives inside .code-snippet__tabs (the JS lifts it there
on init) so the flex `align-items: center` on the strip handles
vertical centring against the tab pills. `margin-left: auto` shoves
it to the right edge. On a pure-white panel background we lean on a
faint warm fill + border so the chip stays visible without competing
with the code. */
.code-snippet__copy {
margin-left: auto;
margin-right: 12px;
padding: 4px 10px;
background: #f7f5ee;
border: 1px solid #d4dcc9;
border-radius: 3px;
font-family: inherit;
font-size: 9px;
font-weight: 500;
letter-spacing: 1px;
text-transform: uppercase;
color: #6b7a6e;
cursor: pointer;
transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.code-snippet__copy:hover { color: #1f1f1d; background: #f1ece0; }
.code-snippet__copy.copied { color: var(--green); border-color: var(--green); background: #ffffff; }
|