-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overhaul for some mobile friendliness and just-keep-running
- Loading branch information
1 parent
76b77d0
commit 18b701f
Showing
9 changed files
with
527 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { | ||
ChevronLeftIcon, | ||
ChevronRightIcon, | ||
DoubleArrowLeftIcon, | ||
DoubleArrowRightIcon, | ||
} from '@radix-ui/react-icons'; | ||
import { WorkerQuery, WorkerStats } from './worker'; | ||
import { ICON_SIZE } from './constants'; | ||
|
||
interface Props { | ||
status: 'done' | 'running' | 'paused'; | ||
stats: WorkerStats; | ||
query: null | WorkerQuery; | ||
setSolution: (index: number | null) => void; | ||
} | ||
|
||
export default function View(props: Props) { | ||
const reportedSolutionNumber = (props.query?.solution ?? props.stats.solutions - 1) + 1; | ||
|
||
return ( | ||
<> | ||
<div id="explorer-view-header"> | ||
<div className="explorer-view-header"> | ||
<button | ||
disabled={props.stats.solutions < 2 || reportedSolutionNumber === 1} | ||
onClick={() => props.setSolution(0)} | ||
> | ||
<DoubleArrowLeftIcon width={ICON_SIZE} height={ICON_SIZE} /> | ||
</button> | ||
<button | ||
disabled={props.stats.solutions < 2 || reportedSolutionNumber === 1} | ||
onClick={() => props.setSolution(reportedSolutionNumber - 2)} | ||
> | ||
<ChevronLeftIcon width={ICON_SIZE} height={ICON_SIZE} /> | ||
</button> | ||
<div className="status"> | ||
{props.query === null && ( | ||
<> | ||
{props.status === 'done' && 'no solutions'} | ||
{props.status !== 'done' && 'no solutions yet'} | ||
</> | ||
)} | ||
{props.query !== null && ( | ||
<> | ||
{props.status === 'done' && ( | ||
<> | ||
{props.stats.solutions === 1 && 'unique solution found'} | ||
{props.stats.solutions > 1 && | ||
`solution ${reportedSolutionNumber} of ${props.stats.solutions}`} | ||
</> | ||
)} | ||
{props.status !== 'done' && ( | ||
<> | ||
{props.query.solution === null && `solution ${reportedSolutionNumber} of ?`} | ||
{props.query.solution !== null && | ||
`solution ${reportedSolutionNumber} of ${props.stats.solutions}+`} | ||
</> | ||
)} | ||
</> | ||
)} | ||
</div> | ||
<button | ||
disabled={ | ||
props.query?.solution == null || props.query.solution + 1 === props.stats.solutions | ||
} | ||
onClick={() => props.setSolution(reportedSolutionNumber)} | ||
> | ||
<ChevronRightIcon width={ICON_SIZE} height={ICON_SIZE} /> | ||
</button> | ||
<button | ||
disabled={ | ||
props.query?.solution == null || | ||
(props.status === 'done' && props.query.solution + 1 === props.stats.solutions) | ||
} | ||
onClick={() => props.setSolution(null)} | ||
> | ||
<DoubleArrowRightIcon width={ICON_SIZE} height={ICON_SIZE} /> | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<div id="explorer-view-data"> | ||
<div style={{ color: 'var(--oksolar-text-red)' }}>{props.stats.error}</div> | ||
{props.query !== null && ( | ||
<ul> | ||
{props.query.value.map((fact, i) => ( | ||
<li key={i}>{fact}</li> | ||
))} | ||
</ul> | ||
)} | ||
</div> | ||
</> | ||
); | ||
} |
Oops, something went wrong.