* Update README * create structure for discussions landing page * is everything broken * [Universe] Dark mode (#16545) * Fix title * Add Discussions product * Correct title * Correct title * Move quickstart article * Move quickstart back out into article * Add and incorporate reusables * Move information about search * Draft conceptual information * Draft best practices * Draft further reading * Draft product introduction * Draft introduction * Add author metadata * Pluralize * Fix typos * Add introduction * Bump Octicons * Add some reusables * Add images * Revise article * Draft article * Change word * 🔪 the gerund * Add reusable * Revise introduction * Revise list * Simplify * Revise reusable * Fix reusable; add context * Rename reusable * Deduplicate conceptual information * 🔪 gerund * Add link to further reading * Move link and dispose of tip * Delete space * Add images * Add conceptual section * Add word * Delete newline * Revert package.json to state on main * Tweak images * Draft article * Add product name * Remove beta note * Use product name for future-proofing * Begin adding search information * Fix copypasta * little edits * build out a bit more of the guides content * Don't mention integrations for now * Escape quote * Remove authorship information for new defaults * Finish drafting article * Replace encoded character to match description * Revise away inline link * Accommodate 'for more information' in reusable * Fix links * Fix one last bit of copypasta * Update indices * Temporarily remove heading * Update introduction * Add new article 💀 * Remove commits from universe-2020-megabranch * Add article 💀 * update with a very rough draft * Add content about collaboration options to "About repositories" * Add content about discussions to "About issues" * Reorder content * Add is:discussion query * update with a few mmore fleshed out sections * update with more structure * Add reusable * Add screenshots * Clear way for actual procedural * Discussions landing page "Communities" section (#16692) * Make button Overview-able * Make card filtering more extensible * Guard for missing attributes * Use arbitrary dataset attributes * Add section with discussions-community-card * Tweak show more button behavior * Conditionally show "Show more" * Add beta_product frontmatter/label * Remove beta callout note * Hide changelog with no items * Finish importing community info * Fix borked markup * Omit search abr * Two columns should actually be two columns * Use org image, change card layout * Add two more examples * Fix title * Escape quote * Escape another quote * Draft article * Lower case * Relocate conceptual information * Update qualifier name * Draft article * Add conceptual information and links * Remove duplicative section * Fix copypasta * Revise reusable * Update link * Add content on categories * Lint the discussions YAML file * Update introduction and permissions * ⚓ * Reusablize; fix link * more planning content stuff * Escape quotes * Align prerequisites * Soften * Clean up prerequisites * Fix titles; version; add screenshot * Fix links * Actually fix links * Use better variable * Mention pinning * Update screenshots * Add screenshot * forgot to committ * update with reusable * add that screenshot * beef up landing page a bit * remove extra space * messed that up * fix hardcoded linkks weirdo * fix tests * update with permissions content * update with placeholder * filter out standalone category files from test * update * update @becca's ⚡ feedback * update with more feedback * so many updates * fix links * fix some more tests * flesh some more things out * update with further reading blah blah * fix some things * remove the gate-features label for beta ship only * Add discussions video to product landing page (#16759) * Add discussions video placeholder * This might work maybe * fix tests * apply all of @becca's and @lecoursen's ⚡ feedback ❤️ * rename to fix test * Revert "Add discussions video to product landing page (#16759)" This reverts commit 2247e5d0881ca6b36cee421218e8341a7cc12ac7. * update with test fix Co-authored-by: Melanie Yarbrough <11952755+myarb@users.noreply.github.com> Co-authored-by: Laura Coursen <lecoursen@github.com> Co-authored-by: Matt Pollard <mattpollard@users.noreply.github.com> Co-authored-by: Jason Etcovitch <jasonetco@github.com> Co-authored-by: Sarah Schneider <sarahs@github.com>
91 lines
2.6 KiB
JavaScript
91 lines
2.6 KiB
JavaScript
function filterCards (cards, value) {
|
|
const noResults = document.querySelector('.js-filter-card-no-results')
|
|
const matchReg = new RegExp(value, 'i')
|
|
|
|
// Track whether or not we had at least one match
|
|
let hasMatches = false
|
|
|
|
for (let index = 0; index < cards.length; index++) {
|
|
const card = cards[index]
|
|
|
|
// Filter was emptied
|
|
if (!value) {
|
|
// Make sure we don't show the "No results" blurb
|
|
hasMatches = true
|
|
|
|
// Hide all but the first 6
|
|
if (index > 5) {
|
|
card.classList.add('d-none')
|
|
} else {
|
|
card.classList.remove('d-none')
|
|
}
|
|
|
|
continue
|
|
}
|
|
|
|
// Check if this card matches - any `data-*` attribute contains the string
|
|
const cardMatches = Object.keys(card.dataset)
|
|
.some(key => matchReg.test(card.dataset[key]))
|
|
|
|
if (cardMatches) {
|
|
card.classList.remove('d-none')
|
|
hasMatches = true
|
|
} else {
|
|
card.classList.add('d-none')
|
|
}
|
|
}
|
|
|
|
// If there wasn't at least one match, show the "no results" text
|
|
if (!hasMatches) {
|
|
document.querySelector('.js-filter-card-value').textContent = value
|
|
noResults.classList.remove('d-none')
|
|
} else {
|
|
noResults.classList.add('d-none')
|
|
}
|
|
}
|
|
|
|
export default function filterCodeExamples () {
|
|
const filter = document.querySelector('.js-filter-card-filter')
|
|
const cards = Array.from(document.querySelectorAll('.js-filter-card'))
|
|
const showMoreButton = document.querySelector('.js-filter-card-show-more')
|
|
|
|
if (filter) {
|
|
filter.addEventListener('keyup', evt => {
|
|
const value = evt.currentTarget.value
|
|
|
|
// Show or hide the "Show more" button if there is a value
|
|
if (value) showMoreButton.classList.add('d-none')
|
|
else showMoreButton.classList.remove('d-none')
|
|
|
|
filterCards(cards, value)
|
|
})
|
|
}
|
|
|
|
if (showMoreButton) {
|
|
showMoreButton.addEventListener('click', evt => {
|
|
// Number of cards that are currently visible
|
|
const numShown = cards.filter(card => !card.classList.contains('d-none')).length
|
|
// We want to show 6 more
|
|
const totalToShow = numShown + 6
|
|
|
|
for (let index = numShown; index < cards.length; index++) {
|
|
const card = cards[index]
|
|
|
|
// If the card we're at is less than the total number of cards
|
|
// we should show, show this one
|
|
if (index < totalToShow) {
|
|
card.classList.remove('d-none')
|
|
} else {
|
|
// Otherwise, we've shown the ones we intend to so exit the loop
|
|
break
|
|
}
|
|
}
|
|
|
|
// They're all shown now, we should hide the button
|
|
if (totalToShow >= cards.length) {
|
|
evt.currentTarget.style.display = 'none'
|
|
}
|
|
})
|
|
}
|
|
}
|