From bfd7e4ca470fae778d1c2a8aaa75b0d52361625e Mon Sep 17 00:00:00 2001 From: nooras Date: Sat, 19 Oct 2024 20:40:58 +0530 Subject: [PATCH] Add TextField component to the sistent components page #5948 --- src/components/SistentNavigation/content.js | 15 + .../sistent/components/text-field/code.js | 8 + .../sistent/components/text-field/guidance.js | 8 + .../sistent/components/text-field/index.js | 8 + .../Projects/Sistent/components/index.js | 7 + .../components/text-field/code-block.js | 19 + .../Sistent/components/text-field/code.js | 747 ++++++++++++++++++ .../Sistent/components/text-field/guidance.js | 201 +++++ .../Sistent/components/text-field/index.js | 412 ++++++++++ 9 files changed, 1425 insertions(+) create mode 100644 src/pages/projects/sistent/components/text-field/code.js create mode 100644 src/pages/projects/sistent/components/text-field/guidance.js create mode 100644 src/pages/projects/sistent/components/text-field/index.js create mode 100644 src/sections/Projects/Sistent/components/text-field/code-block.js create mode 100644 src/sections/Projects/Sistent/components/text-field/code.js create mode 100644 src/sections/Projects/Sistent/components/text-field/guidance.js create mode 100644 src/sections/Projects/Sistent/components/text-field/index.js diff --git a/src/components/SistentNavigation/content.js b/src/components/SistentNavigation/content.js index 51f8f57618ae..34db2995ae3c 100644 --- a/src/components/SistentNavigation/content.js +++ b/src/components/SistentNavigation/content.js @@ -43,4 +43,19 @@ export const content = [ link: "/projects/sistent/components/text-input/code", text: "Text Input", }, + { + id: 15, + link: "/projects/sistent/components/text-field", + text: "Text Field", + }, + { + id: 16, + link: "/projects/sistent/components/text-field/guidance", + text: "Text Field", + }, + { + id: 17, + link: "/projects/sistent/components/text-field/code", + text: "Text Field", + }, ]; diff --git a/src/pages/projects/sistent/components/text-field/code.js b/src/pages/projects/sistent/components/text-field/code.js new file mode 100644 index 000000000000..ec4056851b3e --- /dev/null +++ b/src/pages/projects/sistent/components/text-field/code.js @@ -0,0 +1,8 @@ +import React from "react"; +import { TextFieldCode } from "../../../../../sections/Projects/Sistent/components/text-field/code"; + +const TextFieldCodePage = () => { + return ; +}; + +export default TextFieldCodePage; diff --git a/src/pages/projects/sistent/components/text-field/guidance.js b/src/pages/projects/sistent/components/text-field/guidance.js new file mode 100644 index 000000000000..a18f55ebb86b --- /dev/null +++ b/src/pages/projects/sistent/components/text-field/guidance.js @@ -0,0 +1,8 @@ +import React from "react"; +import { TextFieldGuidance } from "../../../../../sections/Projects/Sistent/components/text-field/guidance"; + +const TextFieldGuidancePage = () => { + return ; +}; + +export default TextFieldGuidancePage; diff --git a/src/pages/projects/sistent/components/text-field/index.js b/src/pages/projects/sistent/components/text-field/index.js new file mode 100644 index 000000000000..4031dd295f6d --- /dev/null +++ b/src/pages/projects/sistent/components/text-field/index.js @@ -0,0 +1,8 @@ +import React from "react"; +import SistentTextField from "../../../../../sections/Projects/Sistent/components/text-field"; + +const SistentTextFieldPage = () => { + return ; +}; + +export default SistentTextFieldPage; diff --git a/src/sections/Projects/Sistent/components/index.js b/src/sections/Projects/Sistent/components/index.js index 8bb294655b0f..f2afe5c521e1 100644 --- a/src/sections/Projects/Sistent/components/index.js +++ b/src/sections/Projects/Sistent/components/index.js @@ -30,6 +30,13 @@ const componentsData = [ "A text input is made up of multiple elements that combine to form a component that helps users to read, write, and edit text in an interface.", url: "/projects/sistent/components/modal", }, + { + id: 4, + name: "Text Field", + description: + "The TextField component is a versatile input field used to capture user input in forms and user interfaces.", + url: "/projects/sistent/components/text-field", + } ]; const SistentComponents = () => { diff --git a/src/sections/Projects/Sistent/components/text-field/code-block.js b/src/sections/Projects/Sistent/components/text-field/code-block.js new file mode 100644 index 000000000000..b3e4945c40e5 --- /dev/null +++ b/src/sections/Projects/Sistent/components/text-field/code-block.js @@ -0,0 +1,19 @@ +import React, { useState } from "react"; +import Code from "../../../../../components/CodeBlock"; +export const CodeBlock = ({ name, code }) => { + const [showCode, setShowCode] = useState(false); + const onChange = () => { + setShowCode((prev) => !prev); + }; + return ( +
+ + + {showCode && ( + + )} +
+ ); +}; diff --git a/src/sections/Projects/Sistent/components/text-field/code.js b/src/sections/Projects/Sistent/components/text-field/code.js new file mode 100644 index 000000000000..25f1d0229d1d --- /dev/null +++ b/src/sections/Projects/Sistent/components/text-field/code.js @@ -0,0 +1,747 @@ +import React from "react"; +import { navigate } from "gatsby"; +import { useLocation } from "@reach/router"; + +import { Box, SistentThemeProvider, TextField } from "@layer5/sistent"; +import { CodeBlock } from "./code-block"; +import { SistentLayout } from "../../sistent-layout"; + +import TabButton from "../../../../../reusecore/Button"; +import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; + +const codes = [ + ` +
+ + + + + + +
+
+ + + + + + +
+
+ + + + + + +
+
`, + ` +
+ + +
+
+ + +
+
+ + +
+
`, + ` +
+ + + +
+
+ + + +
+
+ + + +
+
`, + ` +
+ + +
+
+ + +
+
+ + +
+
`, + ` + + `, +]; + +export const TextFieldCode = () => { + const location = useLocation(); + const { isDark } = useStyledDarkMode(); + + return ( + +
+ +

TextField

+
+

+ The TextField component is a versatile input field used to capture user input in forms and user interfaces. It can handle a variety of input types, such as text, numbers, emails, and passwords, and offers built-in styling and validation features. +

+
+ navigate("/projects/sistent/components/text-field")} + title="Overview" + /> + + navigate("/projects/sistent/components/text-field/guidance") + } + title="Guidance" + /> + navigate("/projects/sistent/identity/color/code")} + title="Code" + /> +
+
+

+ A TextField allow user to enter and edit any text. It mostly present in Forms or dialogue box in UI. + TextField are crucial and integral elements in an interface. It allows to get data from enetered user. +

+ +

Form Props

+
+

+ Standard form attributes are supported, for example required, disabled, type, etc. + HelperText attributes is used to give context about a field's input, + such as how the input will be used. +

+
+
+ + +
+ + + + + + +
+
+ + + + + + +
+
+ + + + + + +
+
+
+
+ +
+ +

Validation

+
+

+ The error property toggles the error state. The helperText prop can then be used to provide feedback to the user about the error. As shown below it can be used with variant such as outlined (default), filled, and standard. +

+
+
+ + +
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+ +

Multiline

+
+

+ The multiline prop transforms the text field into a TextareaAutosize element. Unless the rows prop is set, the height of the text field dynamically matches its content (using TextareaAutosize). You can use the minRows and maxRows props to bound it. +

+
+
+ + +
+ + + +
+
+ + + +
+
+ + + +
+
+
+
+ +
+ +

Sizes

+
+

+ TextField can have small or normal field sizes. According the requirement it can be adjusted. +

+
+
+ + +
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+ +

Full Width

+
+

+ FullWidth attribute can be used to make the input take up the full width of its container. +

+
+
+ + + + + +
+ + +
+
+
+
+ ); +}; + + diff --git a/src/sections/Projects/Sistent/components/text-field/guidance.js b/src/sections/Projects/Sistent/components/text-field/guidance.js new file mode 100644 index 000000000000..516790eb08fd --- /dev/null +++ b/src/sections/Projects/Sistent/components/text-field/guidance.js @@ -0,0 +1,201 @@ +import React from "react"; +import { navigate } from "gatsby"; +import { useLocation } from "@reach/router"; +import { Box, SistentThemeProvider, TextField } from "@layer5/sistent"; +import { SistentLayout } from "../../sistent-layout"; + +import TabButton from "../../../../../reusecore/Button"; +import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; + +export const TextFieldGuidance = () => { + const location = useLocation(); + const { isDark } = useStyledDarkMode(); + + return ( + +
+ +

TextField

+
+

+ The TextField component is a versatile input field used to capture user input in forms and user interfaces. It can handle a variety of input types, such as text, numbers, emails, and passwords, and offers built-in styling and validation features. +

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

+ For proper application, these TextField can be used for different + purposes. It can be effectively used in any project to increase User Interaction. + Lets see how can we use TextField effectively in our project. +

+ +

Basic TextField

+
+

+ The TextField wrapper component is a complete form control including a label, variant, helper text etc. TextField comes with three variants: outlined (default), filled, and standard. +

+

Outlined (default)

+

+ Outlined TextField are TextField that do not have a fill, but have a + border or stroke to define its bounding box as well as a text label + to convey a thought for users to take action upon. Colors can also + be used to style these buttons in order to fit into the theme align + with brand guidelines. +

+ + + + + +

Filled

+

+ Filled TextField are TextField that consist a background color fill and + a text in it. Depending on the theme or intended action, the color + fill can range from a primary brand color to any other applicable + color in a brand’s color palette. +

+ + + + + +

Standard

+

+ Standard TextField are TextField that do not have background color fill and + a text in it. Colors can also be used to style these buttons in order to fit + into the theme align with brand guidelines. +

+ + + + + + +

When to use different properties?

+
+

+ You might come across in a situation you needed some helper text, field with number, disabled field etc. Let's see different properties availble for TextField. +

+

Type prop

+

+ Type prop can have a value such as password, number or text. +

+ + +
+ + + +
+
+
+

Helper Text

+

+ Helper text also very effective for your form or for better understanding. +

+ + +
+ +
+
+
+

Error

+

+ Error handling is very important for UI. User might come in sitatution where they enter invalid value or forget to enter any data in TextField. Here come error prop helps to indicate partucular field are required or user have entered invalid value. +

+ + +
+ +
+
+
+
+
+
+ ); +}; diff --git a/src/sections/Projects/Sistent/components/text-field/index.js b/src/sections/Projects/Sistent/components/text-field/index.js new file mode 100644 index 000000000000..d89a3e043fc6 --- /dev/null +++ b/src/sections/Projects/Sistent/components/text-field/index.js @@ -0,0 +1,412 @@ +import React from "react"; +import { navigate } from "gatsby"; +import { useLocation } from "@reach/router"; + +import { Box, SistentThemeProvider, TextField } from "@layer5/sistent"; +import TabButton from "../../../../../reusecore/Button"; +import { SistentLayout } from "../../sistent-layout"; +import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; + +const SistentTextField = () => { + const location = useLocation(); + const { isDark } = useStyledDarkMode(); + + return ( + +
+ +

TextField

+
+

+ The TextField component is a versatile input field used to capture user input in forms and user interfaces. It can handle a variety of input types, such as text, numbers, emails, and passwords, and offers built-in styling and validation features. +

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

+ A Text fileds allow user to enter and edit any text. It mostly present in Forms or dialogue box in UI. + TextField are crucial and integral elements in an interface. It allows to get data from enetered user. +

+ +

Form Props

+
+

+ Standard form attributes are supported, for example required, disabled, type, etc. + HelperText attributes is used to give context about a field's input, + such as how the input will be used. +

+ + +
+ + + + + + +
+
+ + + + + + +
+
+ + + + + + +
+
+
+ +

Validation

+
+

+ The error property toggles the error state. The helperText prop can then be used to provide feedback to the user about the error. As shown below it can be used with variant such as outlined (default), filled, and standard. +

+ + +
+ + +
+
+ + +
+
+ + +
+
+
+ +

Multiline

+
+

+ The multiline prop transforms the text field into a TextareaAutosize element. Unless the rows prop is set, the height of the text field dynamically matches its content (using TextareaAutosize). You can use the minRows and maxRows props to bound it. +

+ + +
+ + + +
+
+ + + +
+
+ + + +
+
+
+ +

Sizes

+
+

+ TextField can have small or normal field sizes. According the requirement it can be adjusted. +

+ + +
+ + +
+
+ + +
+
+ + +
+
+
+ +

Full Width

+
+

+ FullWidth attribute can be used to make the input take up the full width of its container. +

+ + + + + +
+
+
+ ); +}; + +export default SistentTextField;