diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 0000000..599c324 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,42 @@ +name: "\U0001F41B Bug Report" +description: Report an issue or possible bug +labels: [] +assignees: [] +body: + - type: markdown + attributes: + value: | + ## Quick Checklist + Thank you for taking the time to file a bug report! Please fill out this form as completely as possible. + + ✅ I am using the **latest version of the Bag of Tricks** + ✅ I have searched all issues here to see if this has already been reported + - type: textarea + id: bug-description + attributes: + label: Describe the Bug + description: A clear and concise description of what the bug is. + validations: + required: true + - type: textarea + id: bug-expectation + attributes: + label: What's the expected result? + description: Describe what you expect to happen. + validations: + required: true + - type: input + id: bug-reproduction + attributes: + label: Link to Minimal Reproducible Example + description: '**A minimal reproduction is required** so that others can help debug your issue.' + placeholder: 'https://github.com/you/your-minimal-repo' + validations: + required: true + - type: checkboxes + id: will-pr + attributes: + label: Participation + options: + - label: I am willing to submit a pull request for this issue. + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..0bd61ef --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: Issue or feature request + url: https://github.com/martrapp/astro-vtbot/issues/new/choose + about: Report bugs or request a new trick for the bag using this link. + - name: GitHub Discussions + url: https://github.com/martrapp/astro-vtbot/discussions + about: Does the issue involve a lot of explanation, or are you not sure how it can be split into actionable tasks? Consider starting a discussion first. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..d761890 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,14 @@ + +### Description + + - Summarize your changes in one or two sentences. + - Don't forget `npm changeset` + +### Tests + +- How was this change tested? + + +### Docs & Examples + +- Does your change here require changes to the astro-vtbot-website? diff --git a/components/derive-css-selector.ts b/components/derive-css-selector.ts new file mode 100644 index 0000000..f0be669 --- /dev/null +++ b/components/derive-css-selector.ts @@ -0,0 +1,23 @@ +export function deriveCSSSelector(element: Element, useIds = true) { + let path: string[] = []; + while (element && element.nodeType === Node.ELEMENT_NODE) { + let selector = element.nodeName.toLowerCase(); + if (useIds && element.id) { + selector = '#' + element.id; + path.unshift(selector); + break; + } else { + let sibling = element; + let nth = 1; + while ((sibling = sibling.previousElementSibling as Element)) { + if (sibling.nodeName.toLowerCase() === selector) nth++; + } + if (nth !== 1) { + selector += ':nth-of-type(' + nth + ')'; + } + } + path.unshift(selector); + element = element.parentNode as Element; + } + return path.join(' > '); +}