Skip to content

Commit ab23956

Browse files
committed
fix: refine <Ask/> component to use a fixed title, and instead put guidebook title below
1 parent 5dabe8c commit ab23956

File tree

4 files changed

+68
-32
lines changed

4 files changed

+68
-32
lines changed

Diff for: plugins/plugin-codeflare/src/components/Ask.tsx

+41-31
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ import {
3232
FormGroup,
3333
Select,
3434
SelectGroup,
35+
SelectProps,
3536
SelectOption,
3637
SelectOptionObject,
3738
TextInput,
3839
} from "@patternfly/react-core"
3940

4041
import HomeIcon from "@patternfly/react-icons/dist/esm/icons/home-icon"
4142
import InfoIcon from "@patternfly/react-icons/dist/esm/icons/info-circle-icon"
42-
import ChoiceIcon from "@patternfly/react-icons/dist/esm/icons/lightbulb-icon"
43+
import ChoiceIcon from "@patternfly/react-icons/dist/esm/icons/user-cog-icon"
4344

4445
import "../../web/scss/components/Ask.scss"
4546

@@ -120,11 +121,11 @@ export default class AskUI extends React.PureComponent<Props, State> {
120121

121122
private card(title: string, body: React.ReactNode) {
122123
return (
123-
<Card isLarge className="sans-serif flex-fill">
124+
<Card isPlain className="sans-serif">
124125
<CardHeader>
125126
<CardTitle>
126127
<div className="flex-layout">
127-
<ChoiceIcon className="larger-text slightly-deemphasize small-right-pad" /> {title.replace(/\?$/, "")}
128+
<ChoiceIcon className="larger-text slightly-deemphasize small-right-pad" /> Configure
128129
</div>
129130
</CardTitle>
130131
<CardActions hasNoOffset>{this.actions()}</CardActions>
@@ -217,6 +218,11 @@ export default class AskUI extends React.PureComponent<Props, State> {
217218
// Intentionally empty
218219
}
219220

221+
/** Format title for presentation */
222+
private title(ask: Ask) {
223+
return ask.title.replace(/\?$/, "")
224+
}
225+
220226
/** Render a UI for making a selection */
221227
private select(ask: Ask<Prompts.Select>) {
222228
const suggested = ask.prompt.choices.find((_) => _.name === this.state?.userSelection)
@@ -249,21 +255,20 @@ export default class AskUI extends React.PureComponent<Props, State> {
249255

250256
const onFilter = (evt: React.ChangeEvent | null, filter: string) => mkOptions(filter)
251257

252-
const placeholderText = "Select an option"
253258
const titleId = "kui--madwizard-ask-ui-title"
254259

255-
const props = {
260+
const props: SelectProps = {
256261
isOpen: true,
262+
isPlain: true,
257263
isGrouped: true,
258264
hasInlineFilter: true,
259265
isInputValuePersisted: true,
260266
isInputFilterPersisted: true,
261-
// variant: "typeahead" as const,
262-
// typeAheadAriaLabel: "Select an option",
263267
onFilter,
264268
"aria-labelledby": titleId,
265269
noResultsFoundText: "No matching choices",
266-
placeholderText,
270+
placeholderText: this.title(ask), // place the guidebook title here
271+
inlineFilterPlaceholderText: "Filter choices",
267272
onSelect: this._onSelect,
268273
onToggle: this._doNothing,
269274
toggleIndicator: <React.Fragment />,
@@ -272,9 +277,7 @@ export default class AskUI extends React.PureComponent<Props, State> {
272277

273278
return (
274279
<React.Fragment>
275-
<span id={titleId} hidden>
276-
{placeholderText}
277-
</span>
280+
<span id={titleId} hidden />
278281
{this.card(ask.title, <Select {...props} />)}
279282
</React.Fragment>
280283
)
@@ -297,26 +300,33 @@ export default class AskUI extends React.PureComponent<Props, State> {
297300

298301
return this.card(
299302
ask.title,
300-
<Form onSubmit={this._onFormSubmit}>
301-
<Grid hasGutter md={6}>
302-
{ask.prompt.choices.map((_) => (
303-
<FormGroup isRequired key={_.name} label={_.name}>
304-
<TextInput
305-
aria-label={`text-input-${_.name}`}
306-
isRequired
307-
value={form[_.name]}
308-
onChange={(value) => (form[_.name] = value)}
309-
/>
310-
</FormGroup>
311-
))}
312-
</Grid>
313-
314-
<ActionGroup>
315-
<Button variant="primary" type="submit">
316-
Next
317-
</Button>
318-
</ActionGroup>
319-
</Form>
303+
<Card>
304+
<CardHeader>
305+
<CardTitle>{this.title(ask)}</CardTitle>
306+
</CardHeader>
307+
<CardBody>
308+
<Form onSubmit={this._onFormSubmit}>
309+
<Grid hasGutter md={6}>
310+
{ask.prompt.choices.map((_) => (
311+
<FormGroup isRequired key={_.name} label={_.name}>
312+
<TextInput
313+
aria-label={`text-input-${_.name}`}
314+
isRequired
315+
value={form[_.name]}
316+
onChange={(value) => (form[_.name] = value)}
317+
/>
318+
</FormGroup>
319+
))}
320+
</Grid>
321+
322+
<ActionGroup>
323+
<Button variant="primary" type="submit">
324+
Next
325+
</Button>
326+
</ActionGroup>
327+
</Form>
328+
</CardBody>
329+
</Card>
320330
)
321331
}
322332

Diff for: plugins/plugin-codeflare/src/components/ProfileExplorer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ class ProfileCard extends React.PureComponent<ProfileCardProps, ProfileCardState
603603

604604
public render() {
605605
return (
606-
<Card isLarge>
606+
<Card isPlain>
607607
<CardHeader>
608608
<CardTitle>
609609
<div className="flex-layout">

Diff for: plugins/plugin-codeflare/web/scss/components/Ask.scss

+13
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@
2626
}
2727
}
2828

29+
@include Ask {
30+
&,
31+
.pf-c-card {
32+
width: 40rem;
33+
min-width: 0;
34+
max-width: 40rem;
35+
}
36+
37+
.pf-c-select__menu-item-main {
38+
white-space: normal;
39+
}
40+
}
41+
2942
@include Ask {
3043
.pf-c-card__actions {
3144
align-self: unset;

Diff for: plugins/plugin-codeflare/web/scss/components/ProfileExplorer/_index.scss

+13
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ body[kui-theme-style="dark"] {
6767
overflow-wrap: anywhere; /** WARNING: does not work on safari; we'll need the junkier word-break: break-all there */
6868
}
6969

70+
.pf-c-card {
71+
background-color: var(--color-sidecar-background-02);
72+
}
73+
.pf-c-tree-view__node-container {
74+
}
75+
7076
/** width management */
7177
.pf-c-card {
7278
flex: 1;
@@ -101,7 +107,14 @@ body[kui-theme-style="dark"] {
101107
}
102108

103109
.pf-c-tree-view__node-text {
110+
margin-top: 0;
104111
color: var(--color-text-02);
112+
font-size: var(--pf-global--FontSize--xs);
113+
}
114+
115+
.pf-c-tree-view__node-title {
116+
font-weight: 500;
117+
line-height: var(--pf-global--LineHeight--md);
105118
}
106119

107120
.pf-c-tree-view__node-toggle {

0 commit comments

Comments
 (0)