diff --git a/docs/javascripts/cookbooks-card.js b/docs/javascripts/cookbooks-card.js index d2447324..c1798337 100644 --- a/docs/javascripts/cookbooks-card.js +++ b/docs/javascripts/cookbooks-card.js @@ -1,26 +1,37 @@ - document.addEventListener("DOMContentLoaded", function () { - async function setCard(el, url, name, labels, version, theme, authors) { + const palette = __md_get("__palette") + const useDark = palette && typeof palette.color === "object" && palette.color.scheme === "slate" + const theme = useDark ? "dark-theme" : "light-default"; + const colorList = [ - "#22c55e", - "#14b8a6", - "#ef4444", - "#eab308", - "#8b5cf6", - "#f97316", - "#3b82f6", + "#22c55e", + "#14b8a6", + "#ef4444", + "#eab308", + "#8b5cf6", + "#f97316", + "#3b82f6", ] - let labelHTML = '' - if (labels) { - const labelArray = labels.split(',').map((label, index) => { - const color = colorList[index % colorList.length] - return `${label}` - }) + async function renderCard(element) { + const url = element.getAttribute('data-url'); + const name = element.getAttribute('data-name'); + const labels = element.getAttribute('data-labels'); + const version = element.getAttribute('data-version'); + const authors = element.getAttribute('data-author'); - labelHTML = labelArray.join(' ') - } + const labelHTML = labels ? labels.split(',').map((label, index) => { + const color = colorList[index % colorList.length]; + return ` + + ${label.trim()} + + `; + }).join(' ') : ''; const authorArray = authors.split(','); const authorDataArray = await Promise.all(authorArray.map(async (author) => { @@ -32,16 +43,33 @@ document.addEventListener("DOMContentLoaded", function () { const marginLeft = index === 0 ? '0' : '-10px'; const zIndex = 100 - index; return ` -
`; - el.innerText = ` + document.querySelectorAll('.author-name').forEach(element => { + element.addEventListener('mouseenter', function() { + const login = this.getAttribute('data-login'); + console.log(login, "enter") + document.querySelector(`.author-container[data-login="${login}"]`).classList.add('hover'); + }); + + element.addEventListener('mouseleave', function() { + const login = this.getAttribute('data-login'); + console.log(login, "leave") + document.querySelector(`.author-container[data-login="${login}"]`).classList.remove('hover'); + }); + }); + + element.innerText = `