Skip to content

Commit

Permalink
Merge pull request #50 from FRC2713/configurable-newline
Browse files Browse the repository at this point in the history
Configurable line delimiter
  • Loading branch information
Owen-Morgan825 authored Dec 3, 2024
2 parents b00991e + dddc5cd commit da266fc
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
6 changes: 4 additions & 2 deletions config/2024/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "../schema.json",
"title": "QRScout",
"page_title": "Crescendo",
"delimiter": "\t",
"sections": [
{
"name": "Prematch",
Expand Down Expand Up @@ -111,7 +112,8 @@
"6": "Midline 3 (Middle)",
"7": "Midline 2",
"8": "Midline 1 (Amp Edge)"
}
},
"required": false
},
{
"code": "auf",
Expand Down Expand Up @@ -245,4 +247,4 @@
]
}
]
}
}
23 changes: 19 additions & 4 deletions config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@
"page_title": {
"type": "string"
},
"delimiter": {
"type": "string"
},
"sections": {
"type": "array",
"items": {
"$ref": "#/definitions/Section"
}
}
},
"required": ["title", "page_title", "sections"],
"required": [
"title",
"page_title",
"sections"
],
"additionalProperties": false
},
"Section": {
Expand All @@ -41,7 +48,10 @@
}
}
},
"required": ["name", "fields"],
"required": [
"name",
"fields"
],
"additionalProperties": false
},
"InputProps": {
Expand Down Expand Up @@ -87,7 +97,12 @@
"type": "boolean"
}
},
"required": ["title", "type", "required", "code"],
"required": [
"title",
"type",
"required",
"code"
],
"additionalProperties": false
},
"InputTypes": {
Expand All @@ -104,4 +119,4 @@
]
}
}
}
}
4 changes: 3 additions & 1 deletion src/components/QR/PreviewText.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { useQRScoutState } from '../../store/store';
import { CopyButton } from './CopyButton';

export type PreviewTextProps = {
data: string;
};
export function PreviewText(props: PreviewTextProps) {
const chunks = props.data.split('\t');
const formData = useQRScoutState(state => state.formData);
const chunks = props.data.split(formData.delimiter);
return (
<div className="flex flex-col items-center gap-2 shadow-md bg-gray-600 m-2 p-2 rounded-md">
<div className="text-justify p-2 rounded bg-gray-600 ">
Expand Down
2 changes: 1 addition & 1 deletion src/components/QR/QRModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function getQRCodeData(formData: Config): string {
.map(s => s.fields)
.flat()
.map(v => `${v.value}`.replace(/\n/g, ' '))
.join('\t');
.join(formData.delimiter);
}

export function QRModal(props: QRModalProps) {
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 @@ -5,6 +5,7 @@ export default interface BaseInputProps extends InputProps {
export interface Config {
title: string;
page_title: string;
delimiter: string;
sections: SectionProps[];
}

Expand Down

0 comments on commit da266fc

Please sign in to comment.