@backmatter/studio 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/ui/Field.tsx CHANGED
@@ -6,18 +6,26 @@ import { colors, space, type } from "../styles/tokens.stylex";
6
6
  export function Field({
7
7
  label,
8
8
  hint,
9
+ inline = false,
9
10
  children,
10
11
  }: {
11
12
  label: string;
12
13
  /** Functional note under the control: counts, ids, shortcuts. */
13
14
  hint?: React.ReactNode;
15
+ /** Puts a small control, such as a switch, on the label's row at the far side. */
16
+ inline?: boolean;
14
17
  children: React.ReactNode;
15
18
  }) {
16
19
  return (
17
- <label {...stylex.props(styles.field)} onClickCapture={keepButtonsUnpressed}>
18
- <span {...stylex.props(styles.label)}>{label}</span>
20
+ <label
21
+ {...stylex.props(styles.field, inline && styles.fieldInline)}
22
+ onClickCapture={keepButtonsUnpressed}
23
+ >
24
+ <span {...stylex.props(styles.label, inline && styles.labelInline)}>{label}</span>
19
25
  {children}
20
- {hint ? <span {...stylex.props(styles.hint)}>{hint}</span> : null}
26
+ {hint ? (
27
+ <span {...stylex.props(styles.hint, inline && styles.hintInline)}>{hint}</span>
28
+ ) : null}
21
29
  </label>
22
30
  );
23
31
  }
@@ -63,6 +71,20 @@ const styles = stylex.create({
63
71
  display: "block",
64
72
  fontSize: type.md,
65
73
  },
74
+ fieldInline: {
75
+ display: "flex",
76
+ flexWrap: "wrap",
77
+ alignItems: "center",
78
+ justifyContent: "space-between",
79
+ columnGap: space.lg,
80
+ minHeight: "24px",
81
+ },
82
+ labelInline: {
83
+ marginBottom: 0,
84
+ },
85
+ hintInline: {
86
+ flexBasis: "100%",
87
+ },
66
88
  label: {
67
89
  display: "block",
68
90
  marginBottom: space.sm,