Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support displaying match games #96

Merged
merged 6 commits into from
Jul 9, 2023

Conversation

Drarig29
Copy link
Owner

@Drarig29 Drarig29 commented Jul 9, 2023

Closes #76

Leverages this API: https://developer.mozilla.org/en-US/docs/Web/API/Popover_API

However, currently this is only supported on Chrome and Edge.

To support Firefox, you will need to add this manual polyfill for now:

<style>
    [popover] {
        display: none;
        position: absolute;
        background: white;
        border: 1px solid black;
        z-index: 1000;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }

    /** Custom class to replace pseudo-class `:popover-open`. */
    [popover].popover-open {
        display: block;
    }
</style>

<script>
    function clearPreviousPopoverSelections() {
        document.querySelector('.popover-selected')?.classList.remove('popover-selected')
    }

    document.addEventListener('click', (event) => {
        clearPreviousPopoverSelections()
        document.querySelector('[popover]').classList.remove('popover-open')
    })
</script>

And your bracketsViewer.render() call should look like this:

await window.bracketsViewer.render({
  stages: data.stage,
  matches: data.match,
  matchGames: data.match_game,
  participants: data.participant,
}, {
  onMatchLabelClick: (match) => {
    if (match.child_count > 0) {
      clearPreviousPopoverSelections()
      document.querySelector('[popover]').classList.add('popover-open')
    }
  },
})

@Drarig29 Drarig29 force-pushed the corentin.girard/support-match-games-display branch from 49e13b4 to 334433b Compare July 9, 2023 21:07
@Drarig29 Drarig29 merged commit dae5803 into master Jul 9, 2023
1 check passed
@Drarig29 Drarig29 deleted the corentin.girard/support-match-games-display branch July 9, 2023 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support child games display
1 participant