-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Boilerplate next steps component (#1909)
* feat: Boilerplate next steps component * feat: update suggestions from QA
- Loading branch information
Showing
12 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
editor.planx.uk/src/@planx/components/NextSteps/Editor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { TYPES } from "@planx/components/types"; | ||
import { | ||
EditorProps, | ||
ICONS, | ||
InternalNotes, | ||
MoreInformation, | ||
} from "@planx/components/ui"; | ||
import { useFormik } from "formik"; | ||
import React from "react"; | ||
import Input from "ui/Input"; | ||
import InputRow from "ui/InputRow"; | ||
import ModalSection from "ui/ModalSection"; | ||
import ModalSectionContent from "ui/ModalSectionContent"; | ||
import RichTextInput from "ui/RichTextInput"; | ||
|
||
import { NextSteps, parseContent } from "./model"; | ||
|
||
type Props = EditorProps<TYPES.NextSteps, NextSteps>; | ||
|
||
export default NextSteps; | ||
|
||
function NextSteps(props: Props) { | ||
const formik = useFormik({ | ||
initialValues: parseContent(props.node?.data), | ||
onSubmit: (newValues) => { | ||
props.handleSubmit?.({ | ||
type: TYPES.NextSteps, | ||
data: newValues, | ||
}); | ||
}, | ||
}); | ||
|
||
return ( | ||
<form onSubmit={formik.handleSubmit} id="modal"> | ||
<ModalSection> | ||
<ModalSectionContent title="Next steps" Icon={ICONS[TYPES.NextSteps]}> | ||
<InputRow> | ||
<Input | ||
format="large" | ||
name="title" | ||
placeholder={formik.values.title} | ||
value={formik.values.title} | ||
onChange={formik.handleChange} | ||
/> | ||
</InputRow> | ||
<InputRow> | ||
<RichTextInput | ||
name="description" | ||
placeholder="Description" | ||
value={formik.values.description} | ||
onChange={formik.handleChange} | ||
/> | ||
</InputRow> | ||
</ModalSectionContent> | ||
</ModalSection> | ||
<MoreInformation | ||
changeField={formik.handleChange} | ||
definitionImg={formik.values.definitionImg} | ||
howMeasured={formik.values.howMeasured} | ||
policyRef={formik.values.policyRef} | ||
info={formik.values.info} | ||
/> | ||
<InternalNotes | ||
name="notes" | ||
value={formik.values.notes} | ||
onChange={formik.handleChange} | ||
/> | ||
</form> | ||
); | ||
} |
25 changes: 25 additions & 0 deletions
25
editor.planx.uk/src/@planx/components/NextSteps/Public.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Box from "@mui/material/Box"; | ||
import Typography from "@mui/material/Typography"; | ||
import { PublicProps } from "@planx/components/ui"; | ||
import React from "react"; | ||
|
||
import Card from "../shared/Preview/Card"; | ||
import QuestionHeader from "../shared/Preview/QuestionHeader"; | ||
import { NextSteps } from "./model"; | ||
|
||
type Props = PublicProps<NextSteps>; | ||
|
||
export default Component; | ||
|
||
function Component(props: Props) { | ||
return ( | ||
<Card handleSubmit={props.handleSubmit} isValid> | ||
<QuestionHeader {...props} /> | ||
<Box> | ||
<Typography variant="h2" style={{ color: "orangered" }}> | ||
UNDER DEVELOPMENT | ||
</Typography> | ||
</Box> | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { MoreInformation, parseMoreInformation } from "../shared"; | ||
|
||
export interface NextSteps extends MoreInformation { | ||
title: string; | ||
description: string; | ||
fn: string; | ||
} | ||
|
||
export const parseContent = ( | ||
data: Record<string, any> | undefined | ||
): NextSteps => ({ | ||
title: data?.title || DEFAULT_TITLE, | ||
description: data?.description || "", | ||
fn: data?.fn || "", | ||
...parseMoreInformation(data), | ||
}); | ||
|
||
const DEFAULT_TITLE = "What would you like to do next?"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,5 @@ export enum TYPES { | |
Send = 650, | ||
Calculate = 700, | ||
Confirmation = 725, | ||
NextSteps = 730, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters