|
| 1 | +import React from "react"; |
| 2 | +import { navigate } from "gatsby"; |
| 3 | +import { useLocation } from "@reach/router"; |
| 4 | + |
| 5 | +import { SistentThemeProvider, Stack, Box, Button } from "@sistent/sistent"; |
| 6 | +import { CodeBlock } from "../button/code-block"; |
| 7 | +import { SistentLayout } from "../../sistent-layout"; |
| 8 | + |
| 9 | +import TabButton from "../../../../../reusecore/Button"; |
| 10 | +import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; |
| 11 | + |
| 12 | +const codes = [ |
| 13 | + `<SistentThemeProvider> |
| 14 | + <Stack spacing={2}> |
| 15 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 16 | + Header |
| 17 | + </Box> |
| 18 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 19 | + Content |
| 20 | + </Box> |
| 21 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 22 | + Footer |
| 23 | + </Box> |
| 24 | + </Stack> |
| 25 | +</SistentThemeProvider>`, |
| 26 | + `<SistentThemeProvider> |
| 27 | + <Stack direction="row" spacing={2}> |
| 28 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 29 | + Home |
| 30 | + </Box> |
| 31 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 32 | + About |
| 33 | + </Box> |
| 34 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 35 | + Contact |
| 36 | + </Box> |
| 37 | + </Stack> |
| 38 | +</SistentThemeProvider>`, |
| 39 | + `<SistentThemeProvider> |
| 40 | + <Stack |
| 41 | + direction={{ xs: "column", sm: "row" }} |
| 42 | + spacing={2} |
| 43 | + sx={{ width: "100%" }} |
| 44 | + > |
| 45 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white", flex: 1 }}> |
| 46 | + Card One |
| 47 | + </Box> |
| 48 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white", flex: 1 }}> |
| 49 | + Card Two |
| 50 | + </Box> |
| 51 | + </Stack> |
| 52 | +</SistentThemeProvider>`, |
| 53 | + `<SistentThemeProvider> |
| 54 | + <Stack |
| 55 | + spacing={2} |
| 56 | + divider={ |
| 57 | + <Box |
| 58 | + sx={{ |
| 59 | + borderBottom: "1px solid", |
| 60 | + borderColor: "divider", |
| 61 | + }} |
| 62 | + /> |
| 63 | + } |
| 64 | + > |
| 65 | + <Box sx={{ p: 1 }}>Profile</Box> |
| 66 | + <Box sx={{ p: 1 }}>Settings</Box> |
| 67 | + <Box sx={{ p: 1 }}>Logout</Box> |
| 68 | + </Stack> |
| 69 | +</SistentThemeProvider>`, |
| 70 | + `<SistentThemeProvider> |
| 71 | + <Stack spacing={4}> |
| 72 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 73 | + Title |
| 74 | + </Box> |
| 75 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 76 | + Description |
| 77 | + </Box> |
| 78 | + </Stack> |
| 79 | +</SistentThemeProvider>`, |
| 80 | + `<SistentThemeProvider> |
| 81 | + <Stack direction="row" spacing={2}> |
| 82 | + <Button variant="contained">Save</Button> |
| 83 | + <Button variant="outlined">Cancel</Button> |
| 84 | + <Button variant="text">Reset</Button> |
| 85 | + </Stack> |
| 86 | +</SistentThemeProvider>`, |
| 87 | +]; |
| 88 | + |
| 89 | +const StackCode = () => { |
| 90 | + const location = useLocation(); |
| 91 | + const { isDark } = useStyledDarkMode(); |
| 92 | + |
| 93 | + return ( |
| 94 | + <SistentLayout title="Stack"> |
| 95 | + <div className="content"> |
| 96 | + <a id="Identity"> |
| 97 | + <h2>Stack</h2> |
| 98 | + </a> |
| 99 | + <p> |
| 100 | + The <code>Stack</code> component is a layout utility that manages |
| 101 | + one-dimensional layouts with flexible spacing and alignment. Built on |
| 102 | + Flexbox, it provides an efficient way to arrange elements vertically |
| 103 | + or horizontally with consistent spacing. |
| 104 | + </p> |
| 105 | + <div className="filterBtns"> |
| 106 | + <TabButton |
| 107 | + className={ |
| 108 | + location.pathname === "/projects/sistent/components/stack" |
| 109 | + ? "active" |
| 110 | + : "" |
| 111 | + } |
| 112 | + onClick={() => navigate("/projects/sistent/components/stack")} |
| 113 | + title="Overview" |
| 114 | + /> |
| 115 | + <TabButton |
| 116 | + className={ |
| 117 | + location.pathname === "/projects/sistent/components/stack/guidance" |
| 118 | + ? "active" |
| 119 | + : "" |
| 120 | + } |
| 121 | + onClick={() => |
| 122 | + navigate("/projects/sistent/components/stack/guidance") |
| 123 | + } |
| 124 | + title="Guidance" |
| 125 | + /> |
| 126 | + <TabButton |
| 127 | + className={ |
| 128 | + location.pathname === "/projects/sistent/components/stack/code" |
| 129 | + ? "active" |
| 130 | + : "" |
| 131 | + } |
| 132 | + onClick={() => navigate("/projects/sistent/components/stack/code")} |
| 133 | + title="Code" |
| 134 | + /> |
| 135 | + </div> |
| 136 | + <div className="main-content"> |
| 137 | + <p> |
| 138 | + The <code>Stack</code> component arranges children in one-dimensional flow, either vertically or |
| 139 | + horizontally, with consistent spacing and no manual margin adjustments. |
| 140 | + </p> |
| 141 | + <a id="Vertical Stack"> |
| 142 | + <h2>Vertical Stack</h2> |
| 143 | + </a> |
| 144 | + <p> |
| 145 | + The default Stack orientation is vertical. Use the <code>spacing</code> prop to control the gap between children. |
| 146 | + </p> |
| 147 | + <div className="showcase"> |
| 148 | + <div className="items"> |
| 149 | + <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> |
| 150 | + <Stack spacing={2}> |
| 151 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 152 | + Header |
| 153 | + </Box> |
| 154 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 155 | + Content |
| 156 | + </Box> |
| 157 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 158 | + Footer |
| 159 | + </Box> |
| 160 | + </Stack> |
| 161 | + </SistentThemeProvider> |
| 162 | + </div> |
| 163 | + <CodeBlock name="stack-vertical" code={codes[0]} /> |
| 164 | + </div> |
| 165 | + <a id="Horizontal Stack"> |
| 166 | + <h2>Horizontal Stack</h2> |
| 167 | + </a> |
| 168 | + <p> |
| 169 | + Set <code>direction="row"</code> to arrange children horizontally. Useful for button groups and navigation items. |
| 170 | + </p> |
| 171 | + <div className="showcase"> |
| 172 | + <div className="items"> |
| 173 | + <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> |
| 174 | + <Stack direction="row" spacing={2}> |
| 175 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 176 | + Home |
| 177 | + </Box> |
| 178 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 179 | + About |
| 180 | + </Box> |
| 181 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 182 | + Contact |
| 183 | + </Box> |
| 184 | + </Stack> |
| 185 | + </SistentThemeProvider> |
| 186 | + </div> |
| 187 | + <CodeBlock name="stack-horizontal" code={codes[1]} /> |
| 188 | + </div> |
| 189 | + <a id="Responsive Stack"> |
| 190 | + <h2>Responsive Stack</h2> |
| 191 | + </a> |
| 192 | + <p> |
| 193 | + Use responsive values for the <code>direction</code> prop to create adaptive layouts that stack vertically on mobile and horizontally on larger screens. |
| 194 | + </p> |
| 195 | + <div className="showcase"> |
| 196 | + <div className="items"> |
| 197 | + <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> |
| 198 | + <Stack |
| 199 | + direction={{ xs: "column", sm: "row" }} |
| 200 | + spacing={2} |
| 201 | + sx={{ width: "100%" }} |
| 202 | + > |
| 203 | + <Box |
| 204 | + sx={{ |
| 205 | + p: 2, |
| 206 | + bgcolor: "primary.main", |
| 207 | + color: "white", |
| 208 | + flex: 1, |
| 209 | + }} |
| 210 | + > |
| 211 | + Card One |
| 212 | + </Box> |
| 213 | + <Box |
| 214 | + sx={{ |
| 215 | + p: 2, |
| 216 | + bgcolor: "primary.main", |
| 217 | + color: "white", |
| 218 | + flex: 1, |
| 219 | + }} |
| 220 | + > |
| 221 | + Card Two |
| 222 | + </Box> |
| 223 | + </Stack> |
| 224 | + </SistentThemeProvider> |
| 225 | + </div> |
| 226 | + <CodeBlock name="stack-responsive" code={codes[2]} /> |
| 227 | + </div> |
| 228 | + <a id="Divider"> |
| 229 | + <h2>Divider</h2> |
| 230 | + </a> |
| 231 | + <p> |
| 232 | + Add visual separation between children using the <code>divider</code> prop. |
| 233 | + </p> |
| 234 | + <div className="showcase"> |
| 235 | + <div className="items"> |
| 236 | + <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> |
| 237 | + <Stack |
| 238 | + spacing={2} |
| 239 | + divider={ |
| 240 | + <Box |
| 241 | + sx={{ |
| 242 | + borderBottom: "1px solid", |
| 243 | + borderColor: "divider", |
| 244 | + }} |
| 245 | + /> |
| 246 | + } |
| 247 | + > |
| 248 | + <Box sx={{ p: 1 }}>Profile</Box> |
| 249 | + <Box sx={{ p: 1 }}>Settings</Box> |
| 250 | + <Box sx={{ p: 1 }}>Logout</Box> |
| 251 | + </Stack> |
| 252 | + </SistentThemeProvider> |
| 253 | + </div> |
| 254 | + <CodeBlock name="stack-divider" code={codes[3]} /> |
| 255 | + </div> |
| 256 | + <a id="Spacing"> |
| 257 | + <h2>Spacing</h2> |
| 258 | + </a> |
| 259 | + <p> |
| 260 | + Use larger spacing values to create wider gaps. Common values range from 1 (8px) to 4 (32px). |
| 261 | + </p> |
| 262 | + <div className="showcase"> |
| 263 | + <div className="items"> |
| 264 | + <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> |
| 265 | + <Stack spacing={4}> |
| 266 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 267 | + Title |
| 268 | + </Box> |
| 269 | + <Box sx={{ p: 2, bgcolor: "primary.main", color: "white" }}> |
| 270 | + Description |
| 271 | + </Box> |
| 272 | + </Stack> |
| 273 | + </SistentThemeProvider> |
| 274 | + </div> |
| 275 | + <CodeBlock name="stack-spacing" code={codes[4]} /> |
| 276 | + </div> |
| 277 | + <a id="Button Group"> |
| 278 | + <h2>Button Group</h2> |
| 279 | + </a> |
| 280 | + <p> |
| 281 | + Use <code>direction="row"</code> to stack horizontal button groups with consistent spacing. |
| 282 | + </p> |
| 283 | + <div className="showcase"> |
| 284 | + <div className="items"> |
| 285 | + <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> |
| 286 | + <Stack direction="row" spacing={2}> |
| 287 | + <Button variant="contained">Save</Button> |
| 288 | + <Button variant="outlined">Cancel</Button> |
| 289 | + <Button variant="text">Reset</Button> |
| 290 | + </Stack> |
| 291 | + </SistentThemeProvider> |
| 292 | + </div> |
| 293 | + <CodeBlock name="stack-buttons" code={codes[5]} /> |
| 294 | + </div> |
| 295 | + </div> |
| 296 | + </div> |
| 297 | + </SistentLayout> |
| 298 | + ); |
| 299 | +}; |
| 300 | + |
| 301 | +export default StackCode; |
0 commit comments