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

Add: success and failure events #2

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Add: success and failure events #2

wants to merge 1 commit into from

Conversation

rg-wood
Copy link
Member

@rg-wood rg-wood commented May 22, 2024

Fire events on a success or failure. Success is determined by min or max attributes:

<vellum-dice min="7">3d6+3</vellum-dice>

Success or failure changes the colour of the component text. Defaults are green for success, red for failure. We will create --success-color and --failure-color CSS variables to customise these defaults.

On a successful roll, the component emits a success event. Conversely, failed rolls emit failure events. This can be scripted as follows:

const dice = document.querySelector('vellum-dice')

function success(event) {
  alerts(`success on ${event.detail.result}`
}

dice.addEventListener('success', success)

Notes:

  • What should be the behaviour if both min and max attributes are set?
  • Should we support handling other kinds of success (i.e. rolling doubles)?

@rg-wood rg-wood marked this pull request as draft May 22, 2024 09:38
@rg-wood rg-wood changed the title Add: success events Add: success and failure events May 22, 2024
@rg-wood rg-wood added enhancement New feature or request help wanted Extra attention is needed labels May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant