poor first attempt

This commit is contained in:
lindsaym-fa
2025-07-11 17:06:10 -04:00
parent f49c10b05b
commit 890b0a3c9b
2 changed files with 34 additions and 3 deletions

View File

@@ -223,9 +223,13 @@
{% if component.cssParts.length %}
<h2>CSS parts</h2>
<p>Learn more about <a href="/docs/customizing/#css-parts">CSS parts</a>.</p>
<{{ component.tagName }} id="parts-example"></{{ component.tagName }}>
{{ demo }}
<wa-scroller>
<table class="component-table wa-hover-rows">
<table id="css-parts-table" class="component-table wa-hover-rows">
<thead>
<tr>
<th class="table-name">Name</th>
@@ -234,7 +238,7 @@
</thead>
<tbody>
{% for cssPart in component.cssParts %}
<tr>
<tr data-part="{{ cssPart.name }}">
<td class="table-name"><code>{{ cssPart.name }}</code></td>
<td class="table-description">{{ cssPart.description | inlineMarkdown | safe }}</td>
</tr>
@@ -305,4 +309,6 @@
Ask for help
</wa-button>
</div>
{% endblock %}
<script type="module" src="/assets/scripts/parts-diagram.js"></script>
{% endblock %}

View File

@@ -0,0 +1,25 @@
// Get all table rows with data-part attributes
const tableRows = document.querySelectorAll('[data-part]');
// Add event listeners for mouseenter and mouseleave
tableRows.forEach(row => {
row.addEventListener('mouseenter', function () {
const partName = this.getAttribute('data-part');
const correspondingPart = document.getElementById('parts-example').shadowRoot.querySelector(`[part='${partName}']`);
console.log('hello!');
if (correspondingPart) {
correspondingPart.style.outline = '2px solid red';
}
});
row.addEventListener('mouseleave', function () {
const partName = this.getAttribute('data-part');
const correspondingPart = document.getElementById('parts-example').shadowRoot.querySelector(`[part='${partName}']`);
if (correspondingPart) {
correspondingPart.style.outline = '';
}
});
});