From a7d283ce06107173750c39a8f662beee15c5b5e7 Mon Sep 17 00:00:00 2001 From: Arctic Ice Studio Date: Thu, 6 Dec 2018 11:10:55 +0100 Subject: [PATCH 1/2] Implement core layout component `BaseLayout` This is the default layout of Nord Docs that consists of the `Root` core container (1) as root element and the core components representing the header (2), the main page container (3) and the footer. References: (1) https://github.com/arcticicestudio/nord-docs/issues/36 (2) https://github.com/arcticicestudio/nord-docs/issues/64 (3) https://github.com/arcticicestudio/nord-docs/issues/65 Associated epic: GH-63 Depends on GH-65 Relates to: GH-36, GH-64 GH-66 --- .../layouts/core/BaseLayout/BaseLayout.jsx | 33 +++++++++++++++++++ .../layouts/core/BaseLayout/index.js | 1 + .../core/BaseLayout/BaseLayout.test.jsx | 22 +++++++++++++ .../__snapshots__/BaseLayout.test.jsx.snap | 9 +++++ 4 files changed, 65 insertions(+) create mode 100644 src/components/layouts/core/BaseLayout/BaseLayout.jsx create mode 100644 src/components/layouts/core/BaseLayout/index.js create mode 100644 test/components/layouts/core/BaseLayout/BaseLayout.test.jsx create mode 100644 test/components/layouts/core/BaseLayout/__snapshots__/BaseLayout.test.jsx.snap diff --git a/src/components/layouts/core/BaseLayout/BaseLayout.jsx b/src/components/layouts/core/BaseLayout/BaseLayout.jsx new file mode 100644 index 00000000..46e753d4 --- /dev/null +++ b/src/components/layouts/core/BaseLayout/BaseLayout.jsx @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2018-present Arctic Ice Studio + * Copyright (C) 2018-present Sven Greb + * + * Project: Nord Docs + * Repository: https://github.com/arcticicestudio/nord-docs + * License: MIT + */ + +import React, { Fragment } from "react"; +import PropTypes from "prop-types"; + +import Page from "containers/core/Page"; +import Root from "containers/core/Root"; + +/** + * The base page layout providing the main container that wraps the content. + * + * @since 0.3.0 + */ +const BaseLayout = ({ children }) => ( + + + {children} + + +); + +BaseLayout.propTypes = { + children: PropTypes.node.isRequired +}; + +export default BaseLayout; diff --git a/src/components/layouts/core/BaseLayout/index.js b/src/components/layouts/core/BaseLayout/index.js new file mode 100644 index 00000000..cd391add --- /dev/null +++ b/src/components/layouts/core/BaseLayout/index.js @@ -0,0 +1 @@ +export { default } from "./BaseLayout"; diff --git a/test/components/layouts/core/BaseLayout/BaseLayout.test.jsx b/test/components/layouts/core/BaseLayout/BaseLayout.test.jsx new file mode 100644 index 00000000..0632f6be --- /dev/null +++ b/test/components/layouts/core/BaseLayout/BaseLayout.test.jsx @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2018-present Arctic Ice Studio + * Copyright (C) 2018-present Sven Greb + * + * Project: Nord Docs + * Repository: https://github.com/arcticicestudio/nord-docs + * License: MIT + */ + +import React, { Fragment } from "react"; +import { render } from "react-testing-library"; + +import BaseLayout from "layouts/core/BaseLayout"; + +test("snapshot", () => { + const { container } = render( + + + + ); + expect(container).toMatchSnapshot(); +}); diff --git a/test/components/layouts/core/BaseLayout/__snapshots__/BaseLayout.test.jsx.snap b/test/components/layouts/core/BaseLayout/__snapshots__/BaseLayout.test.jsx.snap new file mode 100644 index 00000000..3a2e181c --- /dev/null +++ b/test/components/layouts/core/BaseLayout/__snapshots__/BaseLayout.test.jsx.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`snapshot 1`] = ` +
+
+
+`; From ab29461d89c0d18751cb0a34df24604384d20545 Mon Sep 17 00:00:00 2001 From: Arctic Ice Studio Date: Thu, 6 Dec 2018 11:11:16 +0100 Subject: [PATCH 2/2] Replace `Root` container with `BaseLayout` layout component GH-66 --- src/pages/index.jsx | 6 +++--- test/pages/__snapshots__/index.test.jsx.snap | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pages/index.jsx b/src/pages/index.jsx index f8770770..116ada29 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -8,7 +8,7 @@ */ import React, { Fragment } from "react"; -import Root from "containers/core/Root"; +import BaseLayout from "layouts/core/BaseLayout"; /** * The landing page component representing the root/index of the site. @@ -18,9 +18,9 @@ import Root from "containers/core/Root"; * @since 0.1.0 */ const Landing = () => ( - + - + ); export default Landing; diff --git a/test/pages/__snapshots__/index.test.jsx.snap b/test/pages/__snapshots__/index.test.jsx.snap index 90b331da..3a2e181c 100644 --- a/test/pages/__snapshots__/index.test.jsx.snap +++ b/test/pages/__snapshots__/index.test.jsx.snap @@ -1,3 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`snapshot 1`] = `
`; +exports[`snapshot 1`] = ` +
+
+
+`;