Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding export to ags file button #8

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ags-validator-app/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
--popover: #ffffff; /* White */
--popover-foreground: #302003; /* Darker text color */
--primary: #376409; /* Dark green */
--primary-hover: #4b7813;
--primary-foreground: #ffffff; /* White */
--secondary: #b08a57; /* Light brown */
--secondary-foreground: #302003; /* Darker text color */
Expand All @@ -36,6 +37,7 @@
--popover: #302003; /* Dark brown */
--popover-foreground: #f5f3e7; /* Lighter text color for dark mode */
--primary: #85a86f; /* Slightly lighter primary color for dark mode */
--primary-hover: #688a4d;
--primary-foreground: #302003; /* Dark brown */
--secondary: #5a7a37; /* Slightly lighter secondary color for dark mode */
--secondary-foreground: #f5f3e7; /* Lighter text color for dark mode */
Expand Down
3 changes: 2 additions & 1 deletion ags-validator-app/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const buttonVariants = cva(
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
default: "bg-primary text-primary-foreground hover:bg-[var(--primary-hover)]",
destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
outline:
Expand All @@ -33,6 +33,7 @@ const buttonVariants = cva(
}
);


export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const CodeMirrorTextArea: React.FC<CodeMirrorTextAreaProps> = ({
}),
[errorLines, hoverLineNumber]
);

// console.log(agsData)
return (
<div className="h-full w-full flex flex-col overflow-auto">
<CodeMirror
Expand Down
15 changes: 15 additions & 0 deletions ags-validator-app/components/validator/validator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ErrorMessages from "./ErrorMessages";
import React, { useEffect, useState } from "react";
import TextArea from "./TextArea";
import AGSUpload from "./AGSUpload";
import { Button } from "@/components/ui/button"
import { Card, CardContent } from "@/components/ui/card";
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
import { Label } from "../ui/label";
Expand Down Expand Up @@ -34,6 +35,18 @@ export default function Validator() {
}
}, [parsedAgs, selectedGroup, setSelectedGroup]);


// Function to handle exporting the agsData as a .ags file
const handleExport = () => {
if (!agsData) return;

const blob = new Blob([agsData], { type: "text/plain;charset=utf-8" });
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "exported.ags"; // Filename for the download
link.click();
};

return (
<div className="flex justify-center w-full">
<div className="flex flex-col p-4 max-w-500 w-full">
Expand All @@ -60,6 +73,8 @@ export default function Validator() {
</TabsTrigger>
</TabsList>
</div>
<Button variant={"default"} disabled={agsData === ""} onClick={handleExport}>Export</Button>

{tabsViewValue === "tables" && parsedAgs !== undefined && (
<SelectTable
parsedAgs={parsedAgs}
Expand Down
Loading