mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-09-09 11:15:08 +08:00
new LoadingScreen to replace old loading divs
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
import { LoadingScreen } from "./LoadingScreen";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: "Example/LoadingScreen",
|
||||||
|
component: LoadingScreen,
|
||||||
|
parameters: {
|
||||||
|
layout: "fullscreen",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const Template = (args) => <LoadingScreen {...args} />; //<><div>text</div><div className="max-w-500 mt-40 z-1000 h-full relative"></div></>;
|
||||||
|
|
||||||
|
export const Default = Template.bind({});
|
||||||
|
|
||||||
|
export const WithText = Template.bind({});
|
||||||
|
WithText.args = { text: "Loading Text ..." };
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { Progress } from "@chakra-ui/react";
|
||||||
|
|
||||||
|
export const LoadingScreen = ({ text }) => (
|
||||||
|
<div className="bg-slate-100">
|
||||||
|
<Progress size="xs" isIndeterminate />
|
||||||
|
{text && (
|
||||||
|
<div className="flex h-full">
|
||||||
|
<div className="text-xl font-bold text-gray-800 mx-auto my-auto">{text}</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
@@ -8,6 +8,7 @@ import poster from "src/lib/poster";
|
|||||||
import { Messages } from "src/components/Messages";
|
import { Messages } from "src/components/Messages";
|
||||||
import { TwoColumns } from "src/components/TwoColumns";
|
import { TwoColumns } from "src/components/TwoColumns";
|
||||||
import { Button } from "src/components/Button";
|
import { Button } from "src/components/Button";
|
||||||
|
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
|
||||||
|
|
||||||
const AssistantReply = () => {
|
const AssistantReply = () => {
|
||||||
const [tasks, setTasks] = useState([]);
|
const [tasks, setTasks] = useState([]);
|
||||||
@@ -39,12 +40,13 @@ const AssistantReply = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
if (true) {
|
||||||
* TODO: Make this a nicer loading screen.
|
return (<LoadingScreen text="Loading..."/>);
|
||||||
*/
|
|
||||||
if (tasks.length == 0) {
|
|
||||||
return <div className="p-6 bg-slate-100 text-gray-800">Loading...</div>;
|
|
||||||
}
|
}
|
||||||
|
if (tasks.length == 0) {
|
||||||
|
return <div className="p-6 bg-slate-100 text-gray-800">No tasks found...</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const task = tasks[0].task;
|
const task = tasks[0].task;
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import poster from "src/lib/poster";
|
|||||||
|
|
||||||
import { TwoColumns } from "src/components/TwoColumns";
|
import { TwoColumns } from "src/components/TwoColumns";
|
||||||
import { Button } from "src/components/Button";
|
import { Button } from "src/components/Button";
|
||||||
|
import { LoadingScreen } from "@/components/Loading/LoadingScreen";
|
||||||
|
|
||||||
const SummarizeStory = () => {
|
const SummarizeStory = () => {
|
||||||
// Use an array of tasks that record the sequence of steps until a task is
|
// Use an array of tasks that record the sequence of steps until a task is
|
||||||
@@ -49,11 +50,11 @@ const SummarizeStory = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
if (isLoading) {
|
||||||
* TODO: Make this a nicer loading screen.
|
return (<LoadingScreen text="Loading..."/>);
|
||||||
*/
|
}
|
||||||
if (tasks.length == 0) {
|
if (tasks.length == 0) {
|
||||||
return <div className=" p-6 bg-slate-100 text-gray-800">Loading...</div>;
|
return <div className="p-6 bg-slate-100 text-gray-800">No tasks found...</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import poster from "src/lib/poster";
|
|||||||
import { Messages } from "src/components/Messages";
|
import { Messages } from "src/components/Messages";
|
||||||
import { TwoColumns } from "src/components/TwoColumns";
|
import { TwoColumns } from "src/components/TwoColumns";
|
||||||
import { Button } from "src/components/Button";
|
import { Button } from "src/components/Button";
|
||||||
|
import { LoadingScreen } from "@/components/Loading/LoadingScreen";
|
||||||
|
|
||||||
const UserReply = () => {
|
const UserReply = () => {
|
||||||
const [tasks, setTasks] = useState([]);
|
const [tasks, setTasks] = useState([]);
|
||||||
@@ -39,11 +40,16 @@ const UserReply = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return (<LoadingScreen text="Loading..."/>);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Make this a nicer loading screen.
|
* TODO: Make this a nicer loading screen.
|
||||||
*/
|
*/
|
||||||
if (tasks.length == 0) {
|
if (tasks.length == 0) {
|
||||||
return <div className="p-6 bg-slate-100 text-gray-800">Loading...</div>;
|
return <div className="p-6 bg-slate-100 text-gray-800">No tasks found...</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const task = tasks[0].task;
|
const task = tasks[0].task;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import fetcher from "src/lib/fetcher";
|
|||||||
import poster from "src/lib/poster";
|
import poster from "src/lib/poster";
|
||||||
|
|
||||||
import { Button } from "src/components/Button";
|
import { Button } from "src/components/Button";
|
||||||
|
import { LoadingScreen } from "@/components/Loading/LoadingScreen";
|
||||||
|
|
||||||
const RankInitialPrompts = () => {
|
const RankInitialPrompts = () => {
|
||||||
const [tasks, setTasks] = useState([]);
|
const [tasks, setTasks] = useState([]);
|
||||||
@@ -44,11 +45,11 @@ const RankInitialPrompts = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
if (isLoading) {
|
||||||
* TODO: Make this a nicer loading screen.
|
return (<LoadingScreen text="Loading..."/>);
|
||||||
*/
|
}
|
||||||
if (tasks.length == 0) {
|
if (tasks.length == 0) {
|
||||||
return <div className="p-6 bg-slate-100 text-gray-800">Loading...</div>;
|
return <div className="p-6 bg-slate-100 text-gray-800">No tasks found...</div>;
|
||||||
}
|
}
|
||||||
const prompts = tasks[0].task.prompts as string[];
|
const prompts = tasks[0].task.prompts as string[];
|
||||||
const items = ranking.map((i) => ({
|
const items = ranking.map((i) => ({
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import poster from "src/lib/poster";
|
|||||||
|
|
||||||
import { TwoColumns } from "src/components/TwoColumns";
|
import { TwoColumns } from "src/components/TwoColumns";
|
||||||
import { Button } from "src/components/Button";
|
import { Button } from "src/components/Button";
|
||||||
|
import { LoadingScreen } from "@/components/Loading/LoadingScreen";
|
||||||
|
|
||||||
const RateSummary = () => {
|
const RateSummary = () => {
|
||||||
// Use an array of tasks that record the sequence of steps until a task is
|
// Use an array of tasks that record the sequence of steps until a task is
|
||||||
@@ -49,11 +50,11 @@ const RateSummary = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
if (isLoading) {
|
||||||
* TODO: Make this a nicer loading screen.
|
return (<LoadingScreen text="Loading..."/>);
|
||||||
*/
|
}
|
||||||
if (tasks.length == 0) {
|
if (tasks.length == 0) {
|
||||||
return <div className="p-6 bg-slate-100 text-gray-800">Loading...</div>;
|
return <div className="p-6 bg-slate-100 text-gray-800">No tasks found...</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user