|
@@ -0,0 +1,135 @@
|
|
|
+import * as React from "react";
|
|
|
+import {
|
|
|
+ makeStyles,
|
|
|
+ useId,
|
|
|
+ Button,
|
|
|
+ Input,
|
|
|
+ Label,
|
|
|
+ Text,
|
|
|
+ Select,
|
|
|
+ Checkbox,
|
|
|
+ Field,
|
|
|
+ Textarea,
|
|
|
+ Radio,
|
|
|
+ RadioGroup
|
|
|
+} from "@fluentui/react-components";
|
|
|
+import {
|
|
|
+ PersonRegular,
|
|
|
+ MicRegular,
|
|
|
+ bundleIcon,
|
|
|
+ CalendarMonthFilled,
|
|
|
+ CalendarMonthRegular,
|
|
|
+} from "@fluentui/react-icons";
|
|
|
+import type { ButtonProps } from "@fluentui/react-components";
|
|
|
+import { DatePicker } from "@fluentui/react-datepicker-compat";
|
|
|
+import "./index.css"
|
|
|
+const useStyles = makeStyles({
|
|
|
+ root: {
|
|
|
+ display: "flex",
|
|
|
+ flexDirection: "column",
|
|
|
+ gap: "20px",
|
|
|
+ // Prevent the example from taking the full width of the page (optional)
|
|
|
+ maxWidth: "400px",
|
|
|
+ // Stack the label above the field (with 2px gap per the design system)
|
|
|
+ "> div": { display: "flex", flexDirection: "column", gap: "2px" },
|
|
|
+ },
|
|
|
+});
|
|
|
+
|
|
|
+const MicButton: React.FC<ButtonProps> = (props) => {
|
|
|
+ return (
|
|
|
+ <Button
|
|
|
+ {...props}
|
|
|
+ appearance="transparent"
|
|
|
+ icon={<MicRegular />}
|
|
|
+ size="small"
|
|
|
+ />
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
+export const ContentBeforeAfter = () => {
|
|
|
+ const styles = useStyles();
|
|
|
+
|
|
|
+ const beforeId = useId("content-before");
|
|
|
+ const afterId = useId("content-after");
|
|
|
+ const beforeAndAfterId = useId("content-before-and-after");
|
|
|
+ const beforeLabelId = useId("before-label");
|
|
|
+ const afterLabelId = useId("after-label");
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div className={styles.root}>
|
|
|
+ <div>
|
|
|
+ <Label htmlFor={beforeId}>姓名</Label>
|
|
|
+ <Input contentBefore={<PersonRegular />} id={beforeId} />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div>
|
|
|
+ <Label htmlFor={afterId}>地址</Label>
|
|
|
+ <Input
|
|
|
+ contentAfter={<MicButton aria-label="Enter by voice" />}
|
|
|
+ id={afterId}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div>
|
|
|
+ <Label htmlFor={beforeAndAfterId}>费用</Label>
|
|
|
+ <Input
|
|
|
+ contentBefore={
|
|
|
+ <Text size={400} id={beforeLabelId}>
|
|
|
+ $
|
|
|
+ </Text>
|
|
|
+ }
|
|
|
+ contentAfter={
|
|
|
+ <Text size={400} id={afterLabelId}>
|
|
|
+ .00
|
|
|
+ </Text>
|
|
|
+ }
|
|
|
+ aria-labelledby={`${beforeAndAfterId} ${beforeLabelId} ${afterLabelId}`}
|
|
|
+ id={beforeAndAfterId}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <Field label="性别">
|
|
|
+ <RadioGroup>
|
|
|
+ <Radio value="apple" label="男" />
|
|
|
+ <Radio value="pear" label="女" />
|
|
|
+ <Radio value="banana" label="未知" />
|
|
|
+ </RadioGroup>
|
|
|
+ </Field>
|
|
|
+ </div>
|
|
|
+ <div className="checkbox-form">
|
|
|
+ <Label htmlFor={beforeAndAfterId}>爱好</Label>
|
|
|
+ <Field>
|
|
|
+ <Checkbox label="写代码" />
|
|
|
+ <Checkbox label="看书" />
|
|
|
+ <Checkbox label="健身" />
|
|
|
+ </Field>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <label>Color</label>
|
|
|
+ <Select>
|
|
|
+ <option>Red</option>
|
|
|
+ <option>Green</option>
|
|
|
+ <option>Blue</option>
|
|
|
+ </Select>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <Field label="Select a date">
|
|
|
+ <DatePicker placeholder="Select a date..." />
|
|
|
+ </Field>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <Field label="Default Textarea">
|
|
|
+ <Textarea />
|
|
|
+ </Field>
|
|
|
+ </div>
|
|
|
+ <div className="form-btngroup">
|
|
|
+ <Button appearance="primary" icon={<CalendarMonthRegular />}>
|
|
|
+ 确定
|
|
|
+ </Button>
|
|
|
+ <Button appearance="outline" icon={<CalendarMonthFilled />}>
|
|
|
+ 取消
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+};
|