From 22e8a3b94adb458ea3fbf13d9542193843aceaba Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 18 May 2021 16:10:32 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Start=20working=20on=20Repositor?= =?UTF-8?q?yViewer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/providers/RepositoryViewer.js | 22 +++++++++++++++++++ .../providers/RepositoryViewer.module.css | 16 ++++++++++++++ .../contexts/ContextRepositoryViewer.js | 7 ++++++ nest_frontend/hooks/useRepositoryViewer.js | 14 ++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 nest_frontend/components/providers/RepositoryViewer.js create mode 100644 nest_frontend/components/providers/RepositoryViewer.module.css create mode 100644 nest_frontend/contexts/ContextRepositoryViewer.js create mode 100644 nest_frontend/hooks/useRepositoryViewer.js diff --git a/nest_frontend/components/providers/RepositoryViewer.js b/nest_frontend/components/providers/RepositoryViewer.js new file mode 100644 index 0000000..7d0fa6d --- /dev/null +++ b/nest_frontend/components/providers/RepositoryViewer.js @@ -0,0 +1,22 @@ +import React from "react" +import Style from "./RepositoryViewer.module.css" +import classNames from "classnames" +import ContextRepositoryViewer from "../../contexts/ContextRepositoryViewer" + + +export default function RepositoryViewer({ + id, + }) { + return ( + +
+ +
+
+ ) +} diff --git a/nest_frontend/components/providers/RepositoryViewer.module.css b/nest_frontend/components/providers/RepositoryViewer.module.css new file mode 100644 index 0000000..9bc7ea5 --- /dev/null +++ b/nest_frontend/components/providers/RepositoryViewer.module.css @@ -0,0 +1,16 @@ +.RepositoryViewer { + display: grid; + + grid-template-areas: + "b c d" + "b e e" + "b f f" + "b g g"; + grid-template-columns: 400px 1fr 1fr; + grid-template-rows: auto auto 1fr auto; + + grid-gap: 10px; + + width: 100%; + height: 100%; +} \ No newline at end of file diff --git a/nest_frontend/contexts/ContextRepositoryViewer.js b/nest_frontend/contexts/ContextRepositoryViewer.js new file mode 100644 index 0000000..abba378 --- /dev/null +++ b/nest_frontend/contexts/ContextRepositoryViewer.js @@ -0,0 +1,7 @@ +import { createContext } from "react" + + +/** + * @todo Document this. + */ +export default createContext(null) diff --git a/nest_frontend/hooks/useRepositoryViewer.js b/nest_frontend/hooks/useRepositoryViewer.js new file mode 100644 index 0000000..bec8ab6 --- /dev/null +++ b/nest_frontend/hooks/useRepositoryViewer.js @@ -0,0 +1,14 @@ +import { useContext } from "react" +import ContextRepositoryViewer from "../contexts/ContextRepositoryViewer" + + +/** + * @todo Document this. + */ +export default function useRepositoryViewer() { + const context = useContext(ContextRepositoryViewer) + if(!context) { + throw new Error("This component must be placed inside a RepositoryViewer.") + } + return context +}