-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Sistent] Add FormGroup component documentation to Sistent components page #7444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
shteypandey28-hue
wants to merge
2
commits into
layer5io:master
from
shteypandey28-hue:shrey-first-contribution
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/sections/Projects/Sistent/components/formgroup/code.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import React from "react"; | ||
| import { navigate } from "gatsby"; | ||
| import { useLocation } from "@reach/router"; | ||
|
|
||
| import { CodeBlock } from "../button/code-block"; | ||
| import { SistentLayout } from "../../sistent-layout"; | ||
| import TabButton from "../../../../../reusecore/Button"; | ||
|
|
||
| const exampleCode = ` | ||
| <SistentThemeProvider> | ||
| <FormGroup> | ||
| <FormControlLabel | ||
| control={<Checkbox />} | ||
| label="Option 1" | ||
| /> | ||
| <FormControlLabel | ||
| control={<Checkbox />} | ||
| label="Option 2" | ||
| /> | ||
| </FormGroup> | ||
| </SistentThemeProvider> | ||
| `; | ||
|
|
||
| const FormGroupCode = () => { | ||
| const location = useLocation(); | ||
|
|
||
| return ( | ||
| <SistentLayout title="FormGroup"> | ||
| <div className="content"> | ||
| <h2>FormGroup</h2> | ||
|
|
||
| <div className="filterBtns"> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === "/projects/sistent/components/formgroup" | ||
| ? "active" | ||
| : "" | ||
| } | ||
| onClick={() => navigate("/projects/sistent/components/formgroup")} | ||
| title="Overview" | ||
| /> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === | ||
| "/projects/sistent/components/formgroup/guidance" | ||
| ? "active" | ||
| : "" | ||
| } | ||
| onClick={() => | ||
| navigate("/projects/sistent/components/formgroup/guidance") | ||
| } | ||
| title="Guidance" | ||
| /> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === | ||
| "/projects/sistent/components/formgroup/code" | ||
| ? "active" | ||
| : "" | ||
| } | ||
| onClick={() => | ||
| navigate("/projects/sistent/components/formgroup/code") | ||
| } | ||
| title="Code" | ||
| /> | ||
| </div> | ||
|
|
||
| <CodeBlock name="formgroup-example" code={exampleCode} /> | ||
| </div> | ||
| </SistentLayout> | ||
| ); | ||
| }; | ||
|
|
||
| export default FormGroupCode; |
90 changes: 90 additions & 0 deletions
90
src/sections/Projects/Sistent/components/formgroup/guidance.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import React from "react"; | ||
| import { navigate } from "gatsby"; | ||
| import { useLocation } from "@reach/router"; | ||
| import { | ||
| SistentThemeProvider, | ||
| FormGroup, | ||
| Checkbox, | ||
| FormControlLabel, | ||
| } from "@sistent/sistent"; | ||
| import { SistentLayout } from "../../sistent-layout"; | ||
| import TabButton from "../../../../../reusecore/Button"; | ||
| import { Row } from "../../../../../reusecore/Layout"; | ||
| import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; | ||
|
|
||
| const FormGroupGuidance = () => { | ||
| const location = useLocation(); | ||
| const { isDark } = useStyledDarkMode(); | ||
|
|
||
| return ( | ||
| <SistentLayout title="FormGroup"> | ||
| <div className="content"> | ||
| <h2>FormGroup</h2> | ||
|
|
||
| <div className="filterBtns"> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === "/projects/sistent/components/formgroup" | ||
| ? "active" | ||
| : "" | ||
| } | ||
| onClick={() => navigate("/projects/sistent/components/formgroup")} | ||
| title="Overview" | ||
| /> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === | ||
| "/projects/sistent/components/formgroup/guidance" | ||
| ? "active" | ||
| : "" | ||
| } | ||
| onClick={() => | ||
| navigate("/projects/sistent/components/formgroup/guidance") | ||
| } | ||
| title="Guidance" | ||
| /> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === | ||
| "/projects/sistent/components/formgroup/code" | ||
| ? "active" | ||
| : "" | ||
| } | ||
| onClick={() => | ||
| navigate("/projects/sistent/components/formgroup/code") | ||
| } | ||
| title="Code" | ||
| /> | ||
| </div> | ||
|
|
||
| <div className="main-content"> | ||
| <h3>Best Practices</h3> | ||
| <ul> | ||
| <li>Use FormGroup to group related checkboxes or switches.</li> | ||
|
|
||
| <li>Wrap controls inside FormControlLabel.</li> | ||
|
|
||
| <li>Use vertical layout for forms.</li> | ||
|
|
||
| <li> | ||
| Use <code>row</code> prop for horizontal layout. | ||
| </li> | ||
| </ul> | ||
|
|
||
| <h3>Horizontal Example</h3> | ||
|
|
||
| <Row $Hcenter> | ||
| <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> | ||
| <FormGroup row> | ||
| <FormControlLabel control={<Checkbox />} label="Email" /> | ||
| <FormControlLabel control={<Checkbox />} label="SMS" /> | ||
| </FormGroup> | ||
| </SistentThemeProvider> | ||
| </Row> | ||
| </div> | ||
| </div> | ||
| </SistentLayout> | ||
| ); | ||
| }; | ||
|
|
||
| export default FormGroupGuidance; |
84 changes: 84 additions & 0 deletions
84
src/sections/Projects/Sistent/components/formgroup/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import React from "react"; | ||
| import { navigate } from "gatsby"; | ||
| import { useLocation } from "@reach/router"; | ||
| import { | ||
| SistentThemeProvider, | ||
| FormGroup, | ||
| Checkbox, | ||
| FormControlLabel, | ||
| } from "@sistent/sistent"; | ||
| import TabButton from "../../../../../reusecore/Button"; | ||
| import { SistentLayout } from "../../sistent-layout"; | ||
| import { Row } from "../../../../../reusecore/Layout"; | ||
| import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; | ||
|
|
||
| const SistentFormGroup = () => { | ||
| const location = useLocation(); | ||
| const { isDark } = useStyledDarkMode(); | ||
|
|
||
| return ( | ||
| <SistentLayout title="FormGroup"> | ||
| <div className="content"> | ||
| <h2>FormGroup</h2> | ||
|
|
||
| <p> | ||
| The <code>FormGroup</code> component groups related form controls such | ||
| as checkboxes and switches. It ensures consistent alignment and | ||
| spacing between inputs. | ||
| </p> | ||
|
|
||
| {/* Tabs */} | ||
| <div className="filterBtns"> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === "/projects/sistent/components/formgroup" | ||
| ? "active" | ||
| : "" | ||
| } | ||
| onClick={() => navigate("/projects/sistent/components/formgroup")} | ||
| title="Overview" | ||
| /> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === | ||
| "/projects/sistent/components/formgroup/guidance" | ||
| ? "active" | ||
| : "" | ||
| } | ||
| onClick={() => | ||
| navigate("/projects/sistent/components/formgroup/guidance") | ||
| } | ||
| title="Guidance" | ||
| /> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === | ||
| "/projects/sistent/components/formgroup/code" | ||
| ? "active" | ||
| : "" | ||
| } | ||
| onClick={() => | ||
| navigate("/projects/sistent/components/formgroup/code") | ||
| } | ||
| title="Code" | ||
| /> | ||
| </div> | ||
|
|
||
| <div className="main-content"> | ||
| <h3>Basic Example</h3> | ||
|
|
||
| <Row $Hcenter> | ||
| <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> | ||
| <FormGroup> | ||
| <FormControlLabel control={<Checkbox />} label="Option 1" /> | ||
| <FormControlLabel control={<Checkbox />} label="Option 2" /> | ||
| </FormGroup> | ||
| </SistentThemeProvider> | ||
| </Row> | ||
| </div> | ||
| </div> | ||
| </SistentLayout> | ||
| ); | ||
| }; | ||
|
|
||
| export default SistentFormGroup; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Navigation
IDis crucial for navigating through sistent components. It should be placed in its correct order, not at the end. If it’s at the end, we won’t be able to navigate fromcodeto the next component or from its previous component to this component’soverview.