Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6bcb47f

Browse files
authored
chore: S2 LabeledValue follow-up (#10061)
* chore: LabeledValue follow-ups * add labeled value to example apps * fix segmented control in vite example app * fix typecheck docs * Revert "add labeled value to example apps" This reverts commit 0f63bce. * Revert "Revert "add labeled value to example apps"" This reverts commit a00978c. * update docs * fix typecheck * doc updates
1 parent 8e585df commit 6bcb47f

5 files changed

Lines changed: 76 additions & 2 deletions

File tree

examples/s2-next-macros/src/app/Lazy.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import {
6060
Image,
6161
InlineAlert,
6262
Keyboard,
63+
LabeledValue,
6364
Link,
6465
Meter,
6566
NumberField,
@@ -162,6 +163,7 @@ export default function Lazy() {
162163
<TextArea placeholder="Enter a description" label="Description" />
163164
<TextField placeholder="Enter a email" label="Email" />
164165
<TextField placeholder="Enter a password" label="Password" />
166+
<LabeledValue label="Actual hours" value={0} />
165167
<SelectBoxGroup aria-label="Choose a cloud">
166168
<SelectBox id="aws" textValue="Amazon Web Services">
167169
<Server />

examples/s2-parcel-example/src/Lazy.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
Image,
4747
InlineAlert,
4848
Keyboard,
49+
LabeledValue,
4950
Link,
5051
Meter,
5152
NumberField,
@@ -148,6 +149,7 @@ export default function Lazy() {
148149
<TextArea placeholder="Enter a description" label="Description" />
149150
<TextField placeholder="Enter a email" label="Email" />
150151
<TextField placeholder="Enter a password" label="Password" />
152+
<LabeledValue label="Actual hours" value={0} />
151153
<SelectBoxGroup aria-label="Choose a cloud">
152154
<SelectBox id="aws" textValue="Amazon Web Services">
153155
<Server />

examples/s2-vite-project/src/Lazy.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
Image,
4747
InlineAlert,
4848
Keyboard,
49+
LabeledValue,
4950
Link,
5051
Meter,
5152
NumberField,
@@ -148,6 +149,7 @@ export default function Lazy() {
148149
<TextArea label="Description" />
149150
<TextField label="Email" />
150151
<TextField label="Password" />
152+
<LabeledValue label="Actual hours" value={0} />
151153
<SelectBoxGroup aria-label="Choose a cloud">
152154
<SelectBox id="aws" textValue="Amazon Web Services">
153155
<Server />
@@ -202,7 +204,7 @@ export default function Lazy() {
202204
The missing link.
203205
</Link>
204206
<Link href="/foo">Foo</Link>
205-
<SegmentedControl aria-label="Time granularity" styles={style({width: 384})}>
207+
<SegmentedControl aria-label="Time granularity" styles={style({width: 384})} isJustified>
206208
<SegmentedControlItem id="day">Day</SegmentedControlItem>
207209
<SegmentedControlItem id="week">Week</SegmentedControlItem>
208210
<SegmentedControlItem id="month">Month</SegmentedControlItem>

examples/s2-webpack-5-example/src/Lazy.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
Image,
4747
InlineAlert,
4848
Keyboard,
49+
LabeledValue,
4950
Link,
5051
Meter,
5152
NumberField,
@@ -148,6 +149,7 @@ export default function Lazy() {
148149
<TextArea placeholder="Enter a description" label="Description" />
149150
<TextField placeholder="Enter a email" label="Email" />
150151
<TextField placeholder="Enter a password" label="Password" />
152+
<LabeledValue label="Actual hours" value={0} />
151153
<SelectBoxGroup aria-label="Choose a cloud">
152154
<SelectBox id="aws" textValue="Amazon Web Services">
153155
<Server />

packages/dev/s2-docs/pages/s2/LabeledValue.mdx

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const description = 'Displays a non-editable value with a label';
1717
component={LabeledValue}
1818
docs={types.exports.LabeledValueProps}
1919
links={types.links}
20-
props={['label', 'size', 'labelPosition', 'labelAlign', 'contextualHelp']}
20+
props={['label', 'size', 'labelPosition', 'contextualHelp']}
2121
initialProps={{
2222
label: 'File name',
2323
value: 'Budget.pdf'
@@ -133,6 +133,72 @@ import {Link} from '@react-spectrum/s2/Link';
133133
<LabeledValue label="Website" value={<Link href="https://www.adobe.com/">Adobe.com</Link>} />
134134
```
135135

136+
## Form
137+
138+
Use `LabeledValue` within a `Form` to display non-editable information alongside editable fields.
139+
140+
```tsx render docs={docs.exports.Form} links={docs.links} props={['size', 'labelAlign', 'necessityIndicator', 'isRequired', 'isDisabled']} type="s2"
141+
"use client";
142+
import {Button} from '@react-spectrum/s2/Button';
143+
import {ComboBox, ComboBoxItem} from '@react-spectrum/s2/ComboBox';
144+
import {Form} from '@react-spectrum/s2/Form';
145+
import {LabeledValue} from '@react-spectrum/s2/LabeledValue';
146+
import {NumberField} from '@react-spectrum/s2/NumberField';
147+
import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
148+
149+
<Form/* PROPS */>
150+
<div
151+
role="group"
152+
className={style({display: 'flex', alignItems: 'center', gap: 48})}>
153+
<ComboBox label="Duration type" styles={style({width: 120})}>
154+
<ComboBoxItem>Simple</ComboBoxItem>
155+
<ComboBoxItem>Calculated assignment</ComboBoxItem>
156+
<ComboBoxItem>Calculated work</ComboBoxItem>
157+
<ComboBoxItem>Effort driven</ComboBoxItem>
158+
</ComboBox>
159+
<NumberField
160+
label="Duration days"
161+
placeholder="# of days"
162+
defaultValue={1}
163+
styles={style({width: 120})}/>
164+
</div>
165+
<div
166+
role="group"
167+
aria-labelledby="working hours"
168+
className={style({display: 'flex', alignItems: 'center', gap: 48, font: 'ui'})}>
169+
<NumberField
170+
label="Planned hours"
171+
placeholder=""
172+
defaultValue={1}
173+
styles={style({width: 120})}/>
174+
{/*- begin highlight -*/}
175+
<LabeledValue
176+
label="Actual hours"
177+
value={0}
178+
styles={style({width: 120})}/>
179+
{/*- end highlight -*/}
180+
</div>
181+
<div
182+
role="group"
183+
aria-labelledby="working hours"
184+
className={style({display: 'flex', alignItems: 'center', gap: 48, font: 'ui'})}>
185+
<LabeledValue
186+
label="Project duration"
187+
value={1}
188+
styles={style({width: 120})}/>
189+
<LabeledValue
190+
label="Actual duration"
191+
value={0}
192+
styles={style({width: 120})}/>
193+
</div>
194+
<Button
195+
type="submit"
196+
variant="primary">
197+
Submit
198+
</Button>
199+
</Form>
200+
```
201+
136202

137203
## API
138204

0 commit comments

Comments
 (0)