Skip to content

Commit 4977635

Browse files
Merge pull request #7081 from helper-uttam/feat/form-control-label-single-commit
feat(form-control-label): add form control label and update navigation
2 parents 746f32b + 02cba98 commit 4977635

5 files changed

Lines changed: 496 additions & 68 deletions

File tree

src/components/SistentNavigation/content.js

Lines changed: 64 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -37,92 +37,90 @@ export const content = [
3737
{ id: 26, link: "/projects/sistent/components/button-group/guidance", text: "Button Group" },
3838
{ id: 27, link: "/projects/sistent/components/button-group/code", text: "Button Group" },
3939

40-
{ id: 25, link: "/projects/sistent/components/chip", text: "Chip" },
41-
{ id: 26, link: "/projects/sistent/components/chip/guidance", text: "Chip" },
42-
{ id: 27, link: "/projects/sistent/components/chip/code", text: "Chip" },
40+
{ id: 28, link: "/projects/sistent/components/chip", text: "Chip" },
41+
{ id: 29, link: "/projects/sistent/components/chip/guidance", text: "Chip" },
42+
{ id: 30, link: "/projects/sistent/components/chip/code", text: "Chip" },
4343

44-
{ id: 28, link: "/projects/sistent/components/circularprogress", text: "Circular Progress" },
45-
{ id: 29, link: "/projects/sistent/components/circularprogress/guidance", text: "Circular Progress" },
46-
{ id: 30, link: "/projects/sistent/components/circularprogress/code", text: "Circular Progress" },
44+
{ id: 31, link: "/projects/sistent/components/circularprogress", text: "Circular Progress" },
45+
{ id: 32, link: "/projects/sistent/components/circularprogress/guidance", text: "Circular Progress" },
46+
{ id: 33, link: "/projects/sistent/components/circularprogress/code", text: "Circular Progress" },
4747

48-
{ id: 31, link: "/projects/sistent/components/container", text: "Container" },
49-
{ id: 32, link: "/projects/sistent/components/container/guidance", text: "Container" },
50-
{ id: 33, link: "/projects/sistent/components/container/code", text: "Container" },
48+
{ id: 34, link: "/projects/sistent/components/container", text: "Container" },
49+
{ id: 35, link: "/projects/sistent/components/container/guidance", text: "Container" },
50+
{ id: 36, link: "/projects/sistent/components/container/code", text: "Container" },
5151

52-
{ id: 34, link: "/projects/sistent/components/dialog", text: "Dialog" },
53-
{ id: 35, link: "/projects/sistent/components/dialog/guidance", text: "Dialog" },
54-
{ id: 36, link: "/projects/sistent/components/dialog/code", text: "Dialog" },
52+
{ id: 37, link: "/projects/sistent/components/dialog", text: "Dialog" },
53+
{ id: 38, link: "/projects/sistent/components/dialog/guidance", text: "Dialog" },
54+
{ id: 39, link: "/projects/sistent/components/dialog/code", text: "Dialog" },
5555

56-
{ id: 37, link: "/projects/sistent/components/grid", text: "Grid" },
57-
{ id: 38, link: "/projects/sistent/components/grid/guidance", text: "Grid" },
58-
{ id: 39, link: "/projects/sistent/components/grid/code", text: "Grid" },
56+
{ id: 40, link: "/projects/sistent/components/formcontrollabel", text: "FormControlLabel" },
57+
{ id: 41, link: "/projects/sistent/components/formcontrollabel/guidance", text: "FormControlLabel" },
58+
{ id: 42, link: "/projects/sistent/components/formcontrollabel/code", text: "FormControlLabel" },
5959

60-
{ id: 40, link: "/projects/sistent/components/iconbutton", text: "IconButton" },
61-
{ id: 41, link: "/projects/sistent/components/iconbutton/guidance", text: "IconButton" },
62-
{ id: 42, link: "/projects/sistent/components/iconbutton/code", text: "IconButton" },
60+
{ id: 43, link: "/projects/sistent/components/grid", text: "Grid" },
61+
{ id: 44, link: "/projects/sistent/components/grid/guidance", text: "Grid" },
62+
{ id: 45, link: "/projects/sistent/components/grid/code", text: "Grid" },
6363

64-
{ id: 43, link: "/projects/sistent/components/icons", text: "Icons" },
64+
{ id: 46, link: "/projects/sistent/components/iconbutton", text: "IconButton" },
65+
{ id: 47, link: "/projects/sistent/components/iconbutton/guidance", text: "IconButton" },
66+
{ id: 48, link: "/projects/sistent/components/iconbutton/code", text: "IconButton" },
6567

66-
{ id: 44, link: "/projects/sistent/components/link", text: "Link" },
67-
{ id: 45, link: "/projects/sistent/components/link/guidance", text: "Link" },
68-
{ id: 46, link: "/projects/sistent/components/link/code", text: "Link" },
68+
{ id: 49, link: "/projects/sistent/components/icons", text: "Icons" },
6969

70-
{ id: 47, link: "/projects/sistent/components/list", text: "List" },
71-
{ id: 48, link: "/projects/sistent/components/list/guidance", text: "List" },
72-
{ id: 49, link: "/projects/sistent/components/list/code", text: "List" },
70+
{ id: 50, link: "/projects/sistent/components/link", text: "Link" },
71+
{ id: 51, link: "/projects/sistent/components/link/guidance", text: "Link" },
72+
{ id: 52, link: "/projects/sistent/components/link/code", text: "Link" },
7373

74-
{ id: 50, link: "/projects/sistent/components/modal", text: "Modal" },
75-
{ id: 51, link: "/projects/sistent/components/modal/guidance", text: "Modal" },
76-
{ id: 52, link: "/projects/sistent/components/modal/code", text: "Modal" },
74+
{ id: 53, link: "/projects/sistent/components/list", text: "List" },
75+
{ id: 54, link: "/projects/sistent/components/list/guidance", text: "List" },
76+
{ id: 55, link: "/projects/sistent/components/list/code", text: "List" },
7777

78-
{ id: 53, link: "/projects/sistent/components/pagination", text: "Pagination" },
79-
{ id: 54, link: "/projects/sistent/components/pagination/guidance", text: "Pagination" },
80-
{ id: 55, link: "/projects/sistent/components/pagination/code", text: "Pagination" },
78+
{ id: 56, link: "/projects/sistent/components/modal", text: "Modal" },
79+
{ id: 57, link: "/projects/sistent/components/modal/guidance", text: "Modal" },
80+
{ id: 58, link: "/projects/sistent/components/modal/code", text: "Modal" },
8181

82-
{ id: 56, link: "/projects/sistent/components/paper", text: "Paper" },
83-
{ id: 57, link: "/projects/sistent/components/paper/guidance", text: "Paper" },
84-
{ id: 58, link: "/projects/sistent/components/paper/code", text: "Paper" },
82+
{ id: 59, link: "/projects/sistent/components/pagination", text: "Pagination" },
83+
{ id: 60, link: "/projects/sistent/components/pagination/guidance", text: "Pagination" },
84+
{ id: 61, link: "/projects/sistent/components/pagination/code", text: "Pagination" },
8585

86-
{ id: 59, link: "/projects/sistent/components/popper", text: "Popper" },
87-
{ id: 60, link: "/projects/sistent/components/popper/guidance", text: "Popper" },
88-
{ id: 61, link: "/projects/sistent/components/popper/code", text: "Popper" },
86+
{ id: 62, link: "/projects/sistent/components/paper", text: "Paper" },
87+
{ id: 63, link: "/projects/sistent/components/paper/guidance", text: "Paper" },
88+
{ id: 64, link: "/projects/sistent/components/paper/code", text: "Paper" },
8989

90-
{ id: 62, link: "/projects/sistent/components/radiogroup", text: "RadioGroup" },
91-
{ id: 63, link: "/projects/sistent/components/radiogroup/guidance", text: "RadioGroup" },
92-
{ id: 64, link: "/projects/sistent/components/radiogroup/code", text: "RadioGroup" },
90+
{ id: 65, link: "/projects/sistent/components/popper", text: "Popper" },
91+
{ id: 66, link: "/projects/sistent/components/popper/guidance", text: "Popper" },
92+
{ id: 67, link: "/projects/sistent/components/popper/code", text: "Popper" },
9393

94-
{ id: 65, link: "/projects/sistent/components/select", text: "Select" },
95-
{ id: 66, link: "/projects/sistent/components/select/guidance", text: "Select" },
96-
{ id: 67, link: "/projects/sistent/components/select/code", text: "Select" },
94+
{ id: 68, link: "/projects/sistent/components/radiogroup", text: "RadioGroup" },
95+
{ id: 69, link: "/projects/sistent/components/radiogroup/guidance", text: "RadioGroup" },
96+
{ id: 70, link: "/projects/sistent/components/radiogroup/code", text: "RadioGroup" },
9797

98-
{ id: 68, link: "/projects/sistent/components/stepper", text: "Stepper" },
99-
{ id: 69, link: "/projects/sistent/components/stepper/guidance", text: "Stepper" },
100-
{ id: 70, link: "/projects/sistent/components/stepper/code", text: "Stepper" },
98+
{ id: 71, link: "/projects/sistent/components/select", text: "Select" },
99+
{ id: 72, link: "/projects/sistent/components/select/guidance", text: "Select" },
100+
{ id: 73, link: "/projects/sistent/components/select/code", text: "Select" },
101101

102-
{ id: 71, link: "/projects/sistent/components/switch", text: "Switch" },
103-
{ id: 72, link: "/projects/sistent/components/switch/guidance", text: "Switch" },
104-
{ id: 73, link: "/projects/sistent/components/switch/code", text: "Switch" },
102+
{ id: 74, link: "/projects/sistent/components/switch", text: "Switch" },
103+
{ id: 75, link: "/projects/sistent/components/switch/guidance", text: "Switch" },
104+
{ id: 76, link: "/projects/sistent/components/switch/code", text: "Switch" },
105105

106-
{ id: 74, link: "/projects/sistent/components/tabs", text: "Tabs" },
107-
{ id: 75, link: "/projects/sistent/components/tabs/guidance", text: "Tabs" },
108-
{ id: 76, link: "/projects/sistent/components/tabs/code", text: "Tabs" },
106+
{ id: 77, link: "/projects/sistent/components/tabs", text: "Tabs" },
107+
{ id: 78, link: "/projects/sistent/components/tabs/guidance", text: "Tabs" },
108+
{ id: 79, link: "/projects/sistent/components/tabs/code", text: "Tabs" },
109109

110-
{ id: 77, link: "/projects/sistent/components/text-field", text: "Text Field" },
111-
{ id: 78, link: "/projects/sistent/components/text-field/guidance", text: "Text Field" },
112-
{ id: 79, link: "/projects/sistent/components/text-field/code", text: "Text Field" },
110+
{ id: 80, link: "/projects/sistent/components/text-field", text: "Text Field" },
111+
{ id: 81, link: "/projects/sistent/components/text-field/guidance", text: "Text Field" },
112+
{ id: 82, link: "/projects/sistent/components/text-field/code", text: "Text Field" },
113113

114-
{ id: 80, link: "/projects/sistent/components/text-input", text: "Text Input" },
115-
{ id: 81, link: "/projects/sistent/components/text-input/guidance", text: "Text Input" },
116-
{ id: 82, link: "/projects/sistent/components/text-input/code", text: "Text Input" },
117-
118-
{ id: 83, link: "/projects/sistent/components/toolbar", text: "Toolbar" },
119-
{ id: 84, link: "/projects/sistent/components/toolbar/guidance", text: "Toolbar" },
120-
{ id: 85, link: "/projects/sistent/components/toolbar/code", text: "Toolbar" },
121-
122-
{ id: 86, link: "/projects/sistent/components/tooltip", text: "Tooltip" },
123-
{ id: 87, link: "/projects/sistent/components/tooltip/guidance", text: "Tooltip" },
124-
{ id: 88, link: "/projects/sistent/components/tooltip/code", text: "Tooltip" },
114+
{ id: 83, link: "/projects/sistent/components/text-input", text: "Text Input" },
115+
{ id: 84, link: "/projects/sistent/components/text-input/guidance", text: "Text Input" },
116+
{ id: 85, link: "/projects/sistent/components/text-input/code", text: "Text Input" },
125117

118+
{ id: 86, link: "/projects/sistent/components/toolbar", text: "Toolbar" },
119+
{ id: 87, link: "/projects/sistent/components/toolbar/guidance", text: "Toolbar" },
120+
{ id: 88, link: "/projects/sistent/components/toolbar/code", text: "Toolbar" },
126121

122+
{ id: 89, link: "/projects/sistent/components/tooltip", text: "Tooltip" },
123+
{ id: 90, link: "/projects/sistent/components/tooltip/guidance", text: "Tooltip" },
124+
{ id: 91, link: "/projects/sistent/components/tooltip/code", text: "Tooltip" },
127125

128126
];

src/sections/Projects/Sistent/components/content.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ const componentsData = [
184184
id: 24,
185185
name: "Toolbar",
186186
description:
187-
"The toolbar is a horizontal container for grouping interactive elements like buttons, filters, or navigation controls, typically placed at the top of a UI section.",
187+
"The toolbar is a horizontal container for grouping interactive elements like buttons, filters, or navigation controls, typically placed at the top of a UI section.",
188188
url: "/projects/sistent/components/toolbar",
189189
src: "/toolbar",
190190
},
@@ -224,7 +224,14 @@ const componentsData = [
224224
src: "/iconbutton",
225225
},
226226
{
227-
id: 30,
227+
"id": 30,
228+
"name": "FormControlLabel",
229+
"description": "A control + label pair used for checkboxes or radio buttons.",
230+
"url": "/projects/sistent/components/formcontrollabel",
231+
"src": "/formcontrollabel",
232+
},
233+
{
234+
id: 31,
228235
name: "Stepper",
229236
description: "Stepper provides a way to display progress through a sequence of logical steps.",
230237
url: "/projects/sistent/components/stepper",
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
import React, { useState } from "react";
2+
import { navigate } from "gatsby";
3+
import { useLocation } from "@reach/router";
4+
5+
import {
6+
FormControlLabel,
7+
Checkbox,
8+
Radio,
9+
Switch,
10+
SistentThemeProvider
11+
} from "@sistent/sistent";
12+
13+
import { SistentLayout } from "../../sistent-layout";
14+
import TabButton from "../../../../../reusecore/Button";
15+
import { CodeBlock } from "../button/code-block";
16+
import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode";
17+
18+
const codes = [
19+
`<FormControlLabel
20+
control={<Checkbox />}
21+
label="Accept Terms"
22+
/>`,
23+
`<FormControlLabel
24+
control={<Radio />}
25+
label="Option A"
26+
/>`,
27+
`<FormControlLabel
28+
control={<Switch />}
29+
label="Enable Notifications"
30+
/>`,
31+
`<FormControlLabel
32+
control={<Checkbox disabled />}
33+
label="Disabled Option"
34+
disabled
35+
/>`
36+
];
37+
38+
39+
const FormControlLabelCode = () => {
40+
const location = useLocation();
41+
const { isDark } = useStyledDarkMode();
42+
const [checked, setChecked] = useState(true);
43+
44+
return (
45+
<SistentLayout title="FormControlLabel">
46+
<div className="content">
47+
<a id="Identity">
48+
<h2>FormControlLabel</h2>
49+
</a>
50+
<p>
51+
The <code>FormControlLabel</code> component wraps controls like checkboxes, radios, and switches,
52+
adding a label to the right side by default. It improves accessibility and user experience by combining form elements with clear labeling.
53+
</p>
54+
55+
<div className="filterBtns">
56+
<TabButton
57+
className={
58+
location.pathname === "/projects/sistent/components/formcontrollabel"
59+
? "active"
60+
: ""
61+
}
62+
onClick={() => navigate("/projects/sistent/components/formcontrollabel")}
63+
title="Overview"
64+
/>
65+
<TabButton
66+
className={
67+
location.pathname === "/projects/sistent/components/formcontrollabel/guidance"
68+
? "active"
69+
: ""
70+
}
71+
onClick={() => navigate("/projects/sistent/components/formcontrollabel/guidance")}
72+
title="Guidance"
73+
/>
74+
<TabButton
75+
className={
76+
location.pathname === "/projects/sistent/components/formcontrollabel/code"
77+
? "active"
78+
: ""
79+
}
80+
onClick={() => navigate("/projects/sistent/components/formcontrollabel/code")}
81+
title="Code"
82+
/>
83+
</div>
84+
85+
<div className="main-content">
86+
<h3>With Checkbox</h3>
87+
<div className="showcase">
88+
<div className="items">
89+
<SistentThemeProvider initialMode={isDark ? "dark" : "light"}>
90+
<FormControlLabel
91+
control={
92+
<Checkbox
93+
checked={checked}
94+
onChange={() => setChecked(!checked)}
95+
/>
96+
}
97+
label="Accept Terms"
98+
/>
99+
</SistentThemeProvider>
100+
</div>
101+
<CodeBlock name="formcontrollabel-checkbox" code={codes[0]} />
102+
</div>
103+
104+
<h3>Disabled Example</h3>
105+
<div className="showcase">
106+
<div className="items">
107+
<SistentThemeProvider initialMode={isDark ? "dark" : "light"}>
108+
<FormControlLabel
109+
control={<Checkbox disabled />}
110+
label="Disabled Option"
111+
disabled
112+
/>
113+
</SistentThemeProvider>
114+
</div>
115+
<CodeBlock name="formcontrollabel-disabled" code={codes[3]} />
116+
</div>
117+
118+
<h3>With Radio Button</h3>
119+
<div className="showcase">
120+
<div className="items">
121+
<SistentThemeProvider initialMode={isDark ? "dark" : "light"}>
122+
<FormControlLabel control={<Radio />} label="Option A" />
123+
</SistentThemeProvider>
124+
</div>
125+
<CodeBlock name="formcontrollabel-radio" code={codes[1]} />
126+
</div>
127+
128+
<h3>With Switch</h3>
129+
<div className="showcase">
130+
<div className="items">
131+
<SistentThemeProvider initialMode={isDark ? "dark" : "light"}>
132+
<FormControlLabel control={<Switch />} label="Enable Notifications" />
133+
</SistentThemeProvider>
134+
</div>
135+
<CodeBlock name="formcontrollabel-switch" code={codes[2]} />
136+
</div>
137+
</div>
138+
</div>
139+
</SistentLayout>
140+
);
141+
};
142+
143+
export default FormControlLabelCode;

0 commit comments

Comments
 (0)