|
324 | 324 | --code-copy-border: rgba(255,255,255,0.2); |
325 | 325 | --code-copy-accent: #769aa5; |
326 | 326 | --code-color-preview-border: rgba(255,255,255,0.3); |
327 | | - --code-editable-underline: #769aa5; |
| 327 | + --code-interactive-highlight: #769aa5; |
| 328 | + --code-interactive-color: inherit; |
| 329 | + --code-interactive-bg-color: transparent; |
| 330 | + --code-interactive-border-color: var(--code-interactive-highlight); |
328 | 331 | --code-comment-color: #808080; |
329 | 332 | border: 1px solid var(--border-color); |
330 | 333 | border-top: none; |
@@ -511,38 +514,74 @@ <h2>Theme & Color Scheme</h2> |
511 | 514 | </interactive-code> |
512 | 515 | </section> |
513 | 516 |
|
514 | | - <!-- Editable Zone Style --> |
| 517 | + <!-- Interactive Zone Style --> |
515 | 518 | <section> |
516 | | - <h2>Editable Zone Style</h2> |
517 | | - <p>Customize how interactive zones look. Select a style to see the CSS and apply it to "Seen by user" blocks below.</p> |
| 519 | + <h2>Interactive Zone Style</h2> |
| 520 | + <p>Customize how interactive zones look. Select a style to see the CSS and apply it globally.</p> |
518 | 521 |
|
519 | 522 | <interactive-code class="inline-code" language="scss" show-copy> |
520 | | - <textarea>/* Interactive zone style: ${editableStyle} */ |
521 | | -interactive-code {</textarea> |
522 | | - <textarea condition="editableStyle=wavy"> /* default — no custom property needed */</textarea> |
523 | | - <textarea condition="editableStyle=dotted"> --code-editable-text-decoration: underline dotted 1.5px; |
524 | | - --code-editable-text-underline-offset: 3px;</textarea> |
525 | | - <textarea condition="editableStyle=dashed"> --code-editable-text-decoration: underline dashed 1.5px; |
526 | | - --code-editable-text-underline-offset: 3px;</textarea> |
527 | | - <textarea condition="editableStyle=highlight"> --code-editable-text-decoration: none; |
528 | | - --code-editable-background: rgba(128,128,128,0.15); |
529 | | - --code-editable-border-radius: 3px; |
530 | | - --code-editable-padding: 1px 4px;</textarea> |
531 | | - <textarea condition="editableStyle=outline"> --code-editable-text-decoration: none; |
532 | | - --code-editable-outline: 1px dashed; |
533 | | - --code-editable-outline-offset: 2px;</textarea> |
534 | | - <textarea condition="editableStyle=pill"> --code-editable-text-decoration: none; |
535 | | - --code-editable-background: rgba(128,128,128,0.12); |
536 | | - --code-editable-border-radius: 12px; |
537 | | - --code-editable-padding: 1px 8px;</textarea> |
538 | | - <textarea condition="editableStyle=hand-drawn"> --code-editable-text-decoration: none; |
539 | | - --code-editable-border: 1.5px solid; |
540 | | - --code-editable-border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px; |
541 | | - --code-editable-padding: 2px 6px;</textarea> |
542 | | - <textarea condition="editableStyle=none"> --code-editable-text-decoration: none;</textarea> |
543 | | - <textarea>}</textarea> |
544 | | - <code-binding key="editableStyle" type="select" carousel options="wavy,dotted,dashed,highlight,outline,pill,hand-drawn,none" value="wavy" |
545 | | - onchange="applyEditableStyle(e.detail)"></code-binding> |
| 523 | + <textarea>/* Interactive zone style: ${interactiveStyle} */</textarea> |
| 524 | + <textarea condition="interactiveStyle=wavy">/* built-in default — no custom CSS needed */</textarea> |
| 525 | + <textarea condition="interactiveStyle=dotted">interactive-code::part(interactive) { |
| 526 | + text-decoration: underline dotted 1.5px var(--code-interactive-highlight); |
| 527 | + text-underline-offset: 3px; |
| 528 | +} |
| 529 | + |
| 530 | +interactive-code::part(interactive):hover { |
| 531 | + text-decoration-thickness: 2.5px; |
| 532 | +}</textarea> |
| 533 | + <textarea condition="interactiveStyle=dashed">interactive-code::part(interactive) { |
| 534 | + text-decoration: underline dashed 1.5px var(--code-interactive-highlight); |
| 535 | + text-underline-offset: 3px; |
| 536 | +} |
| 537 | + |
| 538 | +interactive-code::part(interactive):hover { |
| 539 | + text-decoration-thickness: 2.5px; |
| 540 | +}</textarea> |
| 541 | + <textarea condition="interactiveStyle=highlight">interactive-code::part(interactive) { |
| 542 | + text-decoration: none; |
| 543 | + background: rgba(128,128,128,0.15); |
| 544 | + border-radius: 3px; |
| 545 | + padding: 1px 4px; |
| 546 | +} |
| 547 | + |
| 548 | +interactive-code::part(interactive):hover { |
| 549 | + background: rgba(128,128,128,0.25); |
| 550 | +}</textarea> |
| 551 | + <textarea condition="interactiveStyle=outline">interactive-code::part(interactive) { |
| 552 | + text-decoration: none; |
| 553 | + outline: 1px dashed var(--code-interactive-border-color); |
| 554 | + outline-offset: 2px; |
| 555 | +} |
| 556 | + |
| 557 | +interactive-code::part(interactive):hover { |
| 558 | + outline-style: solid; |
| 559 | +}</textarea> |
| 560 | + <textarea condition="interactiveStyle=pill">interactive-code::part(interactive) { |
| 561 | + text-decoration: none; |
| 562 | + background: rgba(128,128,128,0.12); |
| 563 | + border-radius: 12px; |
| 564 | + padding: 1px 8px; |
| 565 | +} |
| 566 | + |
| 567 | +interactive-code::part(interactive):hover { |
| 568 | + background: rgba(128,128,128,0.25); |
| 569 | +}</textarea> |
| 570 | + <textarea condition="interactiveStyle=hand-drawn">interactive-code::part(interactive) { |
| 571 | + text-decoration: none; |
| 572 | + border: 1.5px solid var(--code-interactive-border-color); |
| 573 | + border-radius: 55% 45% 50% 40% / 40% 50% 45% 55%; |
| 574 | + padding: 2px 8px; |
| 575 | +} |
| 576 | + |
| 577 | +interactive-code::part(interactive):hover { |
| 578 | + box-shadow: 0 0 0 1px var(--code-interactive-border-color); |
| 579 | +}</textarea> |
| 580 | + <textarea condition="interactiveStyle=none">interactive-code::part(interactive) { |
| 581 | + text-decoration: none; |
| 582 | +}</textarea> |
| 583 | + <code-binding key="interactiveStyle" type="select" carousel options="hand-drawn,wavy,dotted,dashed,highlight,outline,pill,none" value="hand-drawn" |
| 584 | + onchange="applyInteractiveStyle(e.detail)"></code-binding> |
546 | 585 | </interactive-code> |
547 | 586 | </section> |
548 | 587 |
|
@@ -1346,59 +1385,53 @@ <h3>Features</h3> |
1346 | 1385 | // Load initial theme (catppuccin) |
1347 | 1386 | loadThemeCSS('catppuccin'); |
1348 | 1387 |
|
1349 | | - function applyEditableStyle(style) { |
1350 | | - var els = document.querySelectorAll('.user-view interactive-code'); |
1351 | | - var props = [ |
1352 | | - '--code-editable-text-decoration', |
1353 | | - '--code-editable-text-underline-offset', |
1354 | | - '--code-editable-border-radius', |
1355 | | - '--code-editable-border', |
1356 | | - '--code-editable-outline', |
1357 | | - '--code-editable-outline-offset', |
1358 | | - '--code-editable-background', |
1359 | | - '--code-editable-padding' |
1360 | | - ]; |
1361 | | - els.forEach(function(el) { |
1362 | | - props.forEach(function(p) { el.style.removeProperty(p); }); |
1363 | | - switch (style) { |
1364 | | - case 'wavy': |
1365 | | - break; |
1366 | | - case 'dotted': |
1367 | | - el.style.setProperty('--code-editable-text-decoration', 'underline dotted 1.5px'); |
1368 | | - el.style.setProperty('--code-editable-text-underline-offset', '3px'); |
1369 | | - break; |
1370 | | - case 'dashed': |
1371 | | - el.style.setProperty('--code-editable-text-decoration', 'underline dashed 1.5px'); |
1372 | | - el.style.setProperty('--code-editable-text-underline-offset', '3px'); |
1373 | | - break; |
1374 | | - case 'highlight': |
1375 | | - el.style.setProperty('--code-editable-text-decoration', 'none'); |
1376 | | - el.style.setProperty('--code-editable-background', 'rgba(128,128,128,0.15)'); |
1377 | | - el.style.setProperty('--code-editable-border-radius', '3px'); |
1378 | | - el.style.setProperty('--code-editable-padding', '1px 4px'); |
1379 | | - break; |
1380 | | - case 'outline': |
1381 | | - el.style.setProperty('--code-editable-text-decoration', 'none'); |
1382 | | - el.style.setProperty('--code-editable-outline', '1px dashed'); |
1383 | | - el.style.setProperty('--code-editable-outline-offset', '2px'); |
1384 | | - break; |
1385 | | - case 'pill': |
1386 | | - el.style.setProperty('--code-editable-text-decoration', 'none'); |
1387 | | - el.style.setProperty('--code-editable-background', 'rgba(128,128,128,0.12)'); |
1388 | | - el.style.setProperty('--code-editable-border-radius', '12px'); |
1389 | | - el.style.setProperty('--code-editable-padding', '1px 8px'); |
1390 | | - break; |
1391 | | - case 'hand-drawn': |
1392 | | - el.style.setProperty('--code-editable-text-decoration', 'none'); |
1393 | | - el.style.setProperty('--code-editable-border', '1.5px solid'); |
1394 | | - el.style.setProperty('--code-editable-border-radius', '255px 15px 225px 15px / 15px 225px 15px 255px'); |
1395 | | - el.style.setProperty('--code-editable-padding', '2px 6px'); |
1396 | | - break; |
1397 | | - case 'none': |
1398 | | - el.style.setProperty('--code-editable-text-decoration', 'none'); |
1399 | | - break; |
1400 | | - } |
1401 | | - }); |
| 1388 | + // Apply initial interactive style (hand-drawn) |
| 1389 | + applyInteractiveStyle('hand-drawn'); |
| 1390 | + |
| 1391 | + function applyInteractiveStyle(style) { |
| 1392 | + var styleEl = document.getElementById('interactive-style-sheet'); |
| 1393 | + if (!styleEl) { |
| 1394 | + styleEl = document.createElement('style'); |
| 1395 | + styleEl.id = 'interactive-style-sheet'; |
| 1396 | + document.head.appendChild(styleEl); |
| 1397 | + } |
| 1398 | + var s = 'interactive-code::part(interactive)'; |
| 1399 | + var h = s + ':hover'; |
| 1400 | + var hl = 'var(--code-interactive-highlight)'; |
| 1401 | + var bc = 'var(--code-interactive-border-color)'; |
| 1402 | + var css = ''; |
| 1403 | + switch (style) { |
| 1404 | + case 'wavy': |
| 1405 | + break; |
| 1406 | + case 'dotted': |
| 1407 | + css = s + ' { text-decoration: underline dotted 1.5px ' + hl + '; text-underline-offset: 3px; } ' |
| 1408 | + + h + ' { text-decoration-thickness: 2.5px; }'; |
| 1409 | + break; |
| 1410 | + case 'dashed': |
| 1411 | + css = s + ' { text-decoration: underline dashed 1.5px ' + hl + '; text-underline-offset: 3px; } ' |
| 1412 | + + h + ' { text-decoration-thickness: 2.5px; }'; |
| 1413 | + break; |
| 1414 | + case 'highlight': |
| 1415 | + css = s + ' { text-decoration: none; background: rgba(128,128,128,0.15); border-radius: 3px; padding: 1px 4px; } ' |
| 1416 | + + h + ' { background: rgba(128,128,128,0.25); }'; |
| 1417 | + break; |
| 1418 | + case 'outline': |
| 1419 | + css = s + ' { text-decoration: none; outline: 1px dashed ' + bc + '; outline-offset: 2px; } ' |
| 1420 | + + h + ' { outline-style: solid; }'; |
| 1421 | + break; |
| 1422 | + case 'pill': |
| 1423 | + css = s + ' { text-decoration: none; background: rgba(128,128,128,0.12); border-radius: 12px; padding: 1px 8px; } ' |
| 1424 | + + h + ' { background: rgba(128,128,128,0.25); }'; |
| 1425 | + break; |
| 1426 | + case 'hand-drawn': |
| 1427 | + css = s + ' { text-decoration: none; border: 1.5px solid ' + bc + '; border-radius: 55% 45% 50% 40% / 40% 50% 45% 55%; padding: 2px 8px; } ' |
| 1428 | + + h + ' { box-shadow: 0 0 0 1px ' + bc + '; }'; |
| 1429 | + break; |
| 1430 | + case 'none': |
| 1431 | + css = s + ' { text-decoration: none; }'; |
| 1432 | + break; |
| 1433 | + } |
| 1434 | + styleEl.textContent = css; |
1402 | 1435 | } |
1403 | 1436 | </script> |
1404 | 1437 | </body> |
|
0 commit comments