From a96d162f649704df5d9b567158366015cbe3172c Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sat, 5 Feb 2022 16:48:16 +0200 Subject: Get basic stuff working --- src/App.tsx | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'src/App.tsx') diff --git a/src/App.tsx b/src/App.tsx index 5645dcc..905149e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,24 +1,26 @@ -import { useSnippets } from "./api" +import { useExamples } from "./api" import styles from "./App.module.css" +import Editor from "./Editor" +import Tutorial from "./Tutorial" import icon from "./favicon.png" const App = () => { - const snippets = useSnippets() + const examples = useExamples() - const renderSnippets = () => { - if (snippets.type === "failed") { - return
- Unexpected error loading snippets. See console for details. -
- } - - if (snippets.type === "loading") { - return
Loading snippets...
+ const renderExamples = () => { + switch (examples.type) { + case "not_yet_requested": + case "loading": + return
Loading examples...
+ case "failed": + return
+ An unexpected error occurred while loading examples. See console for details. +
+ case "success": + return examples.data.map((example) => +
{example.title}
, + ) } - - return snippets.data.map((snippet) => -
{snippet.title}
, - ) } return ( @@ -32,9 +34,11 @@ const App = () => { A Mere Stack Language -
- {renderSnippets()} +
+ {renderExamples()}
+
+
) } -- cgit v1.3