Skip to content

Commit

Permalink
Show a message on no errors or warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rwblair committed Nov 7, 2024
1 parent dbf83e5 commit 925dc21
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
22 changes: 21 additions & 1 deletion web/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React, { useState } from "react"
import "./App.css"
import { directoryOpen } from "https://esm.sh/[email protected]"
import confetti, { create } from 'https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.module.mjs';
import { fileListToTree, validate } from "../dist/validator/main.js"
import type { ValidationResult } from "../../src/types/validation-result.ts"
import { Collapse } from "./Collapse.tsx"
import { Summary } from "./Summary.tsx"
console.log(confetti)

function Files({ issues }) {
const unique = new Map(issues.map(({ location, issueMessage }) => {
Expand Down Expand Up @@ -61,6 +63,7 @@ function App() {
if (validation) {
const errorList = []
const warningList = []
let success = ""
for (const [code, issues] of validation.issues.filter({ severity: 'error' }).groupBy('code')) {
if (code === 'None') {
continue
Expand All @@ -73,13 +76,28 @@ function App() {
}
warningList.push(...Issue({ data: issues }))
}
if (errorList.length === 0 && warningList.length === 0) {
success = (
<div className="success">
<Collapse label="No Issues Detected!">
<div>Thanks for Everything. I Have No Complaints Whatsoever.</div>
</Collapse>
</div>
)
confetti({
particleCount: 500,
spread: 180,
ticks: 400
});
}
validatorOutput = (
<>
<button onClick={validateDir}>Reselect Files</button>
<div>
<ul className="issues-list">
{errorList}
{warningList}
{success}
</ul>
<Summary data={validation.summary} />
<a
Expand All @@ -92,7 +110,10 @@ function App() {
</div>
</>
)
if (errorList.length === 0) {
}
} else {

validatorOutput = (
<>
<h2>
Expand All @@ -106,7 +127,6 @@ function App() {
</>
)
}

return (
<>
<h1>BIDS Validator</h1>
Expand Down
9 changes: 8 additions & 1 deletion web/src/Collapse.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ input[type='checkbox'] {
background: #D55E00;
}

.success .lbl-toggle {
background: #E6E7E7
}

@media (prefers-color-scheme: light) {
.lbl-toggle {
color: #000;
Expand All @@ -57,6 +61,9 @@ input[type='checkbox'] {
.error .lbl-toggle {
background: #D55E00;
}
.success .lbl-toggle {
background: #E5F8E7
}
}

.lbl-toggle::before {
Expand Down Expand Up @@ -98,4 +105,4 @@ input[type='checkbox'] {
border-bottom-right-radius: 7px;
padding: .5rem 1rem;
text-align: left;
}
}

0 comments on commit 925dc21

Please sign in to comment.