[UI docs] Added filter bar for integrations and events.

This commit is contained in:
Fabio Manganiello 2024-05-17 02:21:32 +02:00
parent f06233801b
commit 3d5c60e4f4
Signed by: blacklight
GPG key ID: D90FBA7F76362774
2 changed files with 96 additions and 4 deletions

View file

@ -188,9 +188,47 @@ const renderActionsList = () => {
})
}
const addFilterBar = () => {
const container = document.querySelector('.bd-main')
if (!container)
return
const referenceSection = document.getElementById('reference')
if (!referenceSection)
return
const header = referenceSection.querySelector('h2')
if (!header)
return
const input = document.createElement('input')
input.type = 'text'
input.placeholder = 'Filter'
input.classList.add('filter-bar')
input.addEventListener('input', (event) => {
const filter = event.target.value.toLowerCase()
referenceSection.querySelectorAll('ul.grid li').forEach((li) => {
if (li.innerText.toLowerCase().includes(filter)) {
li.style.display = 'flex'
} else {
li.style.display = 'none'
}
})
})
// Apply the fixed class if the header is above the viewport
const headerOffsetTop = header.offsetTop
document.addEventListener('scroll', () => {
header.classList.toggle('fixed', headerOffsetTop < window.scrollY)
})
header.appendChild(input)
}
document.addEventListener("DOMContentLoaded", function() {
generateComponentsGrid()
convertDepsToTabs()
addClipboardToCodeBlocks()
renderActionsList()
addFilterBar()
})

View file

@ -29,15 +29,18 @@ a.grid-title {
ul.grid li {
display: flex;
background: linear-gradient(0deg, #fff, #f9f9f9);
align-items: center;
justify-content: space-between;
margin: 0 10px 10px 0;
padding: 10px;
padding: 20px;
border: 1px solid #ccc;
border-radius: 15px;
flex-direction: column;
}
ul.grid img {
width: 32px;
width: 48px;
margin-right: 5px;
}
@ -52,13 +55,19 @@ ul.grid li code .pre {
}
ul.grid li:hover {
background: linear-gradient(0deg, #e0ffe8, #e3ffff);
background: linear-gradient(0deg, #157765, #cbffd8) !important;
}
ul.grid li a {
width: calc(100% - 35px);
width: 100%;
display: flex;
justify-content: center;
text-align: center;
margin-top: 0.5em;
}
ul.grid li:hover a {
color: white !important;
}
ul.grid li a code {
@ -128,3 +137,48 @@ ul.grid .icon {
border-radius: 0 0 0.75em 0.75em;
}
.bd-article-container {
position: relative;
}
.filter-bar {
width: 100%;
display: block;
font-size: 0.6em;
border: 1px solid #ccc;
border-radius: 0.75em;
margin: 0.5em 0;
padding: 0.25em;
}
#reference h2.fixed {
position: fixed;
top: 0;
background: white;
z-index: 1;
border-bottom: 1px solid #ccc;
}
@media screen and (max-width: 768px) {
#reference h2.fixed {
width: 100%;
margin-left: -0.5em;
padding: 0.5em 0.5em 0 0.5em;
}
}
@media screen and (max-width: 959px) {
#reference h2.fixed {
width: 100%;
margin-left: -1em;
padding: 0.5em 0.5em 0 0.5em;
}
}
@media screen and (min-width: 960px) {
#reference h2.fixed {
width: 75%;
max-width: 800px;
padding-top: 0.5em;
}
}