Skip to content

Commit

Permalink
add support for field descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
tytremblay committed Dec 17, 2024
1 parent c4cdb79 commit d409f47
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 8 deletions.
10 changes: 10 additions & 0 deletions config/2024/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
"fields": [
{
"title": "Scouter Initials",
"description": "Enter the initials of the scouter.",
"type": "text",
"required": true,
"code": "scouter"
},
{
"title": "Match Number",
"description": "Enter the match number.",
"type": "number",
"required": true,
"code": "matchNumber",
Expand All @@ -24,6 +26,7 @@
},
{
"title": "Robot",
"description": "The robot you are scouting this match, based on driver station position.",
"type": "select",
"required": true,
"code": "robot",
Expand All @@ -39,12 +42,14 @@
},
{
"title": "Team Number",
"description": "The team number of the robot you're scouting.",
"type": "number",
"required": true,
"code": "teamNumber"
},
{
"title": "Starting Position",
"description": "The starting position of the robot.",
"type": "select",
"required": true,
"code": "Prsp",
Expand All @@ -57,6 +62,7 @@
},
{
"title": "No Show",
"description": "Check if the robot did not show up for the match.",
"type": "boolean",
"defaultValue": false,
"required": false,
Expand All @@ -69,6 +75,7 @@
"fields": [
{
"title": "Moved?",
"description": "Check if the robot moved during autonomous.",
"type": "boolean",
"defaultValue": false,
"required": false,
Expand All @@ -77,13 +84,15 @@
{
"code": "timer",
"title": "Timer",
"description": "The time it took for the robot to finish autonomous.",
"type": "timer",
"defaultValue": 0,
"required": false
},
{
"code": "ausc",
"title": "Speaker Scored",
"description": "The number of speaker shots scored during autonomous.",
"type": "counter",
"defaultValue": 0,
"min": 0,
Expand All @@ -92,6 +101,7 @@
{
"code": "auskpm",
"title": "Speaker Missed",
"description": "The number of speaker shots missed during autonomous.",
"type": "counter",
"defaultValue": 0,
"min": 0,
Expand Down
22 changes: 22 additions & 0 deletions public/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"type": "string",
"description": "The title of the input"
},
"description": {
"type": "string",
"description": "The description of the input"
},
"type": {
"type": "string",
"const": "counter"
Expand Down Expand Up @@ -93,6 +97,9 @@
"title": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/title"
},
"description": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/description"
},
"type": {
"type": "string",
"const": "text"
Expand Down Expand Up @@ -141,6 +148,9 @@
"title": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/title"
},
"description": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/description"
},
"type": {
"type": "string",
"const": "number"
Expand Down Expand Up @@ -193,6 +203,9 @@
"title": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/title"
},
"description": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/description"
},
"type": {
"type": "string",
"const": "select"
Expand Down Expand Up @@ -244,6 +257,9 @@
"title": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/title"
},
"description": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/description"
},
"type": {
"type": "string",
"const": "range"
Expand Down Expand Up @@ -300,6 +316,9 @@
"title": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/title"
},
"description": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/description"
},
"type": {
"type": "string",
"const": "boolean"
Expand Down Expand Up @@ -339,6 +358,9 @@
"title": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/title"
},
"description": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/description"
},
"type": {
"type": "string",
"const": "timer"
Expand Down
22 changes: 22 additions & 0 deletions src/assets/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"type": "string",
"description": "The title of the input"
},
"description": {
"type": "string",
"description": "The description of the input"
},
"type": {
"type": "string",
"const": "counter"
Expand Down Expand Up @@ -93,6 +97,9 @@
"title": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/title"
},
"description": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/description"
},
"type": {
"type": "string",
"const": "text"
Expand Down Expand Up @@ -141,6 +148,9 @@
"title": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/title"
},
"description": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/description"
},
"type": {
"type": "string",
"const": "number"
Expand Down Expand Up @@ -193,6 +203,9 @@
"title": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/title"
},
"description": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/description"
},
"type": {
"type": "string",
"const": "select"
Expand Down Expand Up @@ -244,6 +257,9 @@
"title": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/title"
},
"description": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/description"
},
"type": {
"type": "string",
"const": "range"
Expand Down Expand Up @@ -300,6 +316,9 @@
"title": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/title"
},
"description": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/description"
},
"type": {
"type": "string",
"const": "boolean"
Expand Down Expand Up @@ -339,6 +358,9 @@
"title": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/title"
},
"description": {
"$ref": "#/properties/sections/items/properties/fields/items/anyOf/0/properties/description"
},
"type": {
"type": "string",
"const": "timer"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function Header() {
return (
<Helmet>
<title>QRScout | {page_title}</title>
<link rel="icon" href="/favicon.ico" />
<link rel="icon" href="/QRScout/favicon.ico" />
</Helmet>
);
}
1 change: 1 addition & 0 deletions src/components/Sections/FormSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default function FormSection(props: SectionProps) {
title={e.title}
required={e.required}
hasValue={e.value !== null && e.value !== undefined && e.value !== ''}
description={e.description}
key={`${props.name}_${e.title}`}
>
<ConfigurableInput section={props.name} code={e.code} />
Expand Down
1 change: 1 addition & 0 deletions src/components/inputs/BaseInputProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const inputTypeSchema = z

export const inputBaseSchema = z.object({
title: z.string().describe('The title of the input'),
description: z.string().optional().describe('The description of the input'),
type: inputTypeSchema,
required: z.boolean().describe('Whether this input is required'),
code: z.string().describe('A unique code for this input'),
Expand Down
35 changes: 28 additions & 7 deletions src/components/inputs/InputCard.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
import { TriangleAlert } from 'lucide-react';
import { Info, TriangleAlert } from 'lucide-react';
import React from 'react';
import { Card, CardContent } from '../ui/card';
import {
Dialog,
DialogContent,
DialogDescription,
DialogTitle,
DialogTrigger,
} from '../ui/dialog';

export interface InputCardProps {
title: string;
required: boolean;
hasValue: boolean;
description?: string;
}

export default function InputCard(
props: React.PropsWithChildren<InputCardProps>,
) {
return (
<Card>
<div className="flex gap-2 bg-secondary px-1 items-center rounded-t-lg">
{props.required && !props.hasValue && (
<TriangleAlert className="text-primary animate-pulse size-4" />
<div className="flex justify-between bg-secondary px-1 items-center rounded-t-lg">
<div className="flex gap-2 ">
{props.required && !props.hasValue && (
<TriangleAlert className="text-primary animate-pulse size-4" />
)}
<h1 className="capitalize text-secondary-foreground text-sm">
{props.title.toUpperCase()}
</h1>
</div>
{props.description && (
<Dialog>
<DialogTrigger asChild>
<Info className="text-secondary-foreground size-4" />
</DialogTrigger>
<DialogContent>
<DialogTitle>{props.title}</DialogTitle>
<DialogDescription>{props.description}</DialogDescription>
</DialogContent>
</Dialog>
)}
<h1 className="capitalize text-secondary-foreground text-sm">
{props.title.toUpperCase()}
</h1>
</div>
<CardContent className="p-0">{props.children}</CardContent>
</Card>
Expand Down

0 comments on commit d409f47

Please sign in to comment.