Skip to content

Web component postcode box#572

Open
ajparsons wants to merge 5 commits into
markdown-helpfrom
webcomponent-postcode
Open

Web component postcode box#572
ajparsons wants to merge 5 commits into
markdown-helpfrom
webcomponent-postcode

Conversation

@ajparsons

Copy link
Copy Markdown
Contributor

(I'll need to do some rearranging of this as I fix up those bits in the markdown-help branch - but these are mostly independent choices)

In tidying up the help pages, I found our embeddable form to put a postcode lookup on another site! This PR fixes a few things and gives it a new coat of paint so we can use it as part of the making contact project.

Fixing things up and adding some new parameter options

When we introduced the message type screen, we broke an assumption around how passed in fields like name etc propagate to the writing page. This just ensures that all fields sent to the who page get passed until they end up on the right page.

Similarly, as it fits into the general pattern here - I've made message_type able to be passed through.

To enable something in the next step, I've made it possible to specify if there is a single option shown, the who page should not be skipped (so it can be used to create a 'find out about your MP' link rather than a write to your MP link).

Web component

The big thing here is wrapping the previous approach (which was a few variations of a form with all the formatting included) in a web component approach and creating a useful form builder to customise it.

There is a basic approach (a form that will send a postcode to wtt) that is enhanced by our javascript file to style and add further options. This includes a language switcher (options modeled on the approach taken by democracy club). Forms are given a purpose to either write or find out about representatives - and can be customised to just certain levels of representation.

I've decided that the JS itself contains the translations - as it was fiddly in PHP to access both sets at once and this means if we fix things up it will fix up already installed versions. Similarly decided against an iframe approach (which is what democracy club do) - as it's a bit more complicated at this point to change more of the flow.

A decision to check: as we run the JS on the other website, this passes the current page in as an external ref so we can see the origins of messages in other campaigns.

image

I've taken out references to the wordpress plugin for the moment - but if we get this merged creating a new wordpress gutenberg component for this approach would not be difficult.

Link generator

Taking some of those same form components to make it a bit easier to customise a link without knowledge of our internal identifiers.

If values have been pre-populated, store to pass over to write page
- Stop skipping the who page if there's a single rep, when
a purpose parameter is set to find
- Upgrades the plain form with language switcher
- Adds styling and descriptions
@ajparsons ajparsons requested a review from struan July 14, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant