From 2c4b9167e7fbbe9a88dbf27f0b15d3f7808bc0ff Mon Sep 17 00:00:00 2001 From: nganphan123 Date: Tue, 7 Jan 2025 12:30:12 -0800 Subject: [PATCH] finish select code Signed-off-by: nganphan123 --- .../Sistent/components/select/code-block.js | 20 ++ .../Sistent/components/select/code.js | 220 +++++++++++++++++- .../Sistent/components/select/guidance.js | 6 +- 3 files changed, 235 insertions(+), 11 deletions(-) create mode 100644 src/sections/Projects/Sistent/components/select/code-block.js diff --git a/src/sections/Projects/Sistent/components/select/code-block.js b/src/sections/Projects/Sistent/components/select/code-block.js new file mode 100644 index 000000000000..2a7463d6ceec --- /dev/null +++ b/src/sections/Projects/Sistent/components/select/code-block.js @@ -0,0 +1,20 @@ +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/select/code.js b/src/sections/Projects/Sistent/components/select/code.js index 2fe492150816..c4c9ec608b9e 100644 --- a/src/sections/Projects/Sistent/components/select/code.js +++ b/src/sections/Projects/Sistent/components/select/code.js @@ -1,14 +1,21 @@ import React from "react"; -import { Button, SistentThemeProvider } from "@layer5/sistent"; +import { SistentThemeProvider } from "@layer5/sistent"; import { CodeBlock } from "./code-block"; -import { FaArrowRight } from "@react-icons/all-files/fa/FaArrowRight"; import { SistentLayout } from "../../sistent-layout"; import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; import SectionNav from "./section-nav"; import Header from "./header"; -import { FormControl, InputLabel, MenuItem, Select } from "@mui/material"; +import { + FormControl, + FormHelperText, + InputLabel, + ListSubheader, + MenuItem, + OutlinedInput, + Select, +} from "@mui/material"; const codes = { "variant-outlined": ` @@ -85,11 +92,88 @@ const codes = { `, + + "customize-label": ` + + Age + + +`, + "customize-helper-text": ` + + + This is a helper text + +`, + + "customize-placeholder": `const [selectedAge, setSelectedAge] = React.useState(""); + + + +`, + + "customize-grouping": ``, + + multiselect: `const [multipleAges, setMultipleAges] = React.useState([]); +const handleMultiplSelect = (event) => { + let agesList = event.target.value; + setMultipleAges(agesList); +}; + + +`, }; -const ButtonCode = () => { +const SelectCode = () => { const { isDark } = useStyledDarkMode(); - + const [selectedAge, setSelectedAge] = React.useState(""); + const [multipleAges, setMultipleAges] = React.useState([10]); + const handleMultiplSelect = (event) => { + let agesList = event.target.value; + setMultipleAges(agesList); + }; return (
@@ -210,9 +294,108 @@ const ButtonCode = () => {
- -

Customize behaviors

+
+

Customization

+

Label

+

+ To add a label to the select component, wrap it inside a FormControl + component. Add an InputLabel component and link it to the select + component using the labelId prop. Ensure the label prop in the + Select component matches the InputLabel text. +

+
+
+ + + Age + + + +
+ +
+

Helper text

+
+
+ + + + This is a helper text + + +
+ +
+

Placeholder

+

+ To add a placeholder, use the renderValue prop to display a + placeholder text when no value is selected. +

+
+
+ + + +
+ +
+

Grouping

+ To group selection options, use the ListSubheader component to create + headers for each group within the dropdown menu. This helps users to + easily navigate and find the options they need. +
+
+ + + +
+ +

Additional props such as error, required, and disabled can be passed to the select component to customize its behavior. @@ -265,13 +448,30 @@ const ButtonCode = () => { clarity.

- -

Customize select area

+
+

Multi-select

+
+
+ + + +
+ +
); }; -export default ButtonCode; +export default SelectCode; diff --git a/src/sections/Projects/Sistent/components/select/guidance.js b/src/sections/Projects/Sistent/components/select/guidance.js index 763c841dd183..24adf0c502c9 100644 --- a/src/sections/Projects/Sistent/components/select/guidance.js +++ b/src/sections/Projects/Sistent/components/select/guidance.js @@ -153,7 +153,11 @@ const SelectGuidance = () => {

Placeholder

- Placeholder can be used to give more context about the selection. + A placeholder is a short hint or description that is displayed + inside an input field or select component before the user enters a + value. It provides a clue to the user about what kind of information + is expected in the field. The placeholder text disappears when the + user starts typing or selects an option.