From 32f1b770aa59787bfded135ec34614940086226b Mon Sep 17 00:00:00 2001 From: karan-palan Date: Mon, 10 Mar 2025 14:57:04 +0530 Subject: [PATCH] docs: add Stack documentation Signed-off-by: karan-palan --- .../Projects/Sistent/components/content.js | 8 ++ .../Projects/Sistent/components/stack/code.js | 108 ++++++++++++++++++ .../Sistent/components/stack/guidance.js | 105 +++++++++++++++++ .../Sistent/components/stack/index.js | 39 +++++++ 4 files changed, 260 insertions(+) create mode 100644 src/sections/Projects/Sistent/components/stack/code.js create mode 100644 src/sections/Projects/Sistent/components/stack/guidance.js create mode 100644 src/sections/Projects/Sistent/components/stack/index.js diff --git a/src/sections/Projects/Sistent/components/content.js b/src/sections/Projects/Sistent/components/content.js index d622ff10b49d..c1eeb33bcf53 100644 --- a/src/sections/Projects/Sistent/components/content.js +++ b/src/sections/Projects/Sistent/components/content.js @@ -119,6 +119,14 @@ const componentsData = [ url: "/projects/sistent/components/select", src: "/select", }, + { + id: 16, + name: "Stack", + description: + "Stack arranges elements in a row or column with consistent spacing and alignment, simplifying layout creation.", + url: "/projects/sistent/components/stack", + src: "/stack", + }, ]; module.exports = { componentsData }; diff --git a/src/sections/Projects/Sistent/components/stack/code.js b/src/sections/Projects/Sistent/components/stack/code.js new file mode 100644 index 000000000000..3f3a5bf0e660 --- /dev/null +++ b/src/sections/Projects/Sistent/components/stack/code.js @@ -0,0 +1,108 @@ +import React from "react"; +import { navigate } from "gatsby"; +import { useLocation } from "@reach/router"; + +import { Stack, SistentThemeProvider } from "@layer5/sistent"; +import { CodeBlock } from "../button/code-block"; +import { SistentLayout } from "../../sistent-layout"; + +import TabButton from "../../../../../reusecore/Button"; +import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; + +const codes = [ + ` + +
Item 1
+
Item 2
+
Item 3
+
+
`, + ` + +
Item A
+
Item B
+
+
`, + ` + +
Left
+
Right
+
+
`, +]; + +const StackCode = () => { + const location = useLocation(); + const { isDark } = useStyledDarkMode(); + + return ( + +
+ +

Stack

+
+

+ The Stack component is a flexible container that helps to arrange child elements + in a row or column layout with spacing and alignment options. +

+
+ navigate("/projects/sistent/components/stack")} + title="Overview" + /> + navigate("/projects/sistent/components/stack/guidance")} + title="Guidance" + /> + navigate("/projects/sistent/components/stack/code")} + title="Code" + /> +
+
+

Horizontal Stack

+

Stacks elements horizontally with spacing.

+
+ + +
Item 1
+
Item 2
+
Item 3
+
+
+ +
+ +

Vertical Stack

+

Stacks elements vertically with larger spacing.

+
+ + +
Item A
+
Item B
+
+
+ +
+ +

Alignment & Justification

+

Stack items can be aligned and justified.

+
+ + +
Left
+
Right
+
+
+ +
+
+
+
+ ); +}; + +export default StackCode; diff --git a/src/sections/Projects/Sistent/components/stack/guidance.js b/src/sections/Projects/Sistent/components/stack/guidance.js new file mode 100644 index 000000000000..63b5ad9b89bc --- /dev/null +++ b/src/sections/Projects/Sistent/components/stack/guidance.js @@ -0,0 +1,105 @@ +import React from "react"; +import { navigate } from "gatsby"; +import { useLocation } from "@reach/router"; +import { SistentLayout } from "../../sistent-layout"; +import TabButton from "../../../../../reusecore/Button"; + +const StackGuidance = () => { + const location = useLocation(); + + return ( + +
+ +

Stack

+
+

+ The Stack component arranges elements in a row or column with + consistent spacing and alignment. It’s best used for simple, + repetitive layouts, especially when you need uniform spacing between + items. +

+
+ navigate("/projects/sistent/components/stack")} + title="Overview" + /> + navigate("/projects/sistent/components/stack/guidance")} + title="Guidance" + /> + navigate("/projects/sistent/components/stack/code")} + title="Code" + /> +
+
+

Best Practices

+
    +
  • + Use Stack for simple layouts: For more complex + grids or responsive breakpoints, consider other layout components + (e.g., Grid). +
  • +
  • + Spacing control: Leverage spacing to + maintain consistent gaps between items. +
  • +
  • + Direction: Use direction="row" for + horizontal layouts or direction="column" for vertical + layouts. +
  • +
  • + Alignment: Combine alignItems and{" "} + justifyContent to position items. For instance,{" "} + alignItems="center" and{" "} + justifyContent="space-between". +
  • +
+ +

Styling & Customization

+

+ Stack itself is a layout tool. For visual flair, wrap child elements + (e.g., Box) with backgrounds, borders, or other custom + styling. This approach keeps layout concerns (Stack) separate from + presentation (child components). +

+ +

Real-World Usage

+
    +
  • + Form Layouts: Stacking labels and inputs + vertically with consistent spacing. +
  • +
  • + Card Groups: Displaying multiple cards or panels + horizontally with even spacing. +
  • +
  • + Toolbar or Header: Aligning icons and navigation + links in a row with justifyContent="space-between". +
  • +
+
+
+
+ ); +}; + +export default StackGuidance; diff --git a/src/sections/Projects/Sistent/components/stack/index.js b/src/sections/Projects/Sistent/components/stack/index.js new file mode 100644 index 000000000000..6e4c5bdae090 --- /dev/null +++ b/src/sections/Projects/Sistent/components/stack/index.js @@ -0,0 +1,39 @@ +import React from "react"; +import { navigate } from "gatsby"; + +import { Stack, SistentThemeProvider } from "@layer5/sistent"; +import TabButton from "../../../../../reusecore/Button"; +import { SistentLayout } from "../../sistent-layout"; + +const SistentStack = () => { + + return ( + +
+ +

Stack

+
+

+ The Stack component provides a simple way to arrange elements in a row or column with customizable spacing. +

+
+ navigate("/projects/sistent/components/stack")} title="Overview" /> + navigate("/projects/sistent/components/stack/guidance")} title="Guidance" /> + navigate("/projects/sistent/components/stack/code")} title="Code" /> +
+
+

Basic Usage

+ + +
Item 1
+
Item 2
+
Item 3
+
+
+
+
+
+ ); +}; + +export default SistentStack;