Skip to content

Commit 77f1b6a

Browse files
committed
chore: Run latest version of prettier on codebase
1 parent 5ebf9b2 commit 77f1b6a

15 files changed

Lines changed: 6031 additions & 3011 deletions

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ updates:
1414

1515
- package-ecosystem: "github-actions"
1616
directory: "/"
17-
schedule:
17+
schedule:
1818
interval: "monthly"
1919
reviewers:
2020
- "theopensystemslab/planx"

CHANGELOG.md

Lines changed: 86 additions & 5 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
A library of [Web Components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) for tasks related to addresses and planning permission in the UK built with [Lit](https://lit.dev/), [Vite](https://vitejs.dev/), and [Ordnance Survey APIs](https://developer.ordnancesurvey.co.uk/).
66

7-
***Web map***
7+
**_Web map_**
88

99
`<my-map />` is an [OpenLayers](https://openlayers.org/)-powered map to support drawing and modifying red-line boundaries. Other supported modes include: highlighting an OS Feature that intersects with a given address point; clicking to select and merge multiple OS Features into a single boundary; and displaying static point or polygon data. Events are dispatched with the calculated area and geojson representation when you change your drawing.
1010

1111
![chrome-capture-2022-7-16-map](https://user-images.githubusercontent.com/5132349/184860750-bf7514db-7cab-4f9c-aa32-791099ecd6cc.gif)
1212

13-
***Postcode search***
13+
**_Postcode search_**
1414

1515
`<postcode-search />` is a [GOV.UK-styled](https://frontend.design-system.service.gov.uk/) input that validates UK postcodes using these [utility methods](https://www.npmjs.com/package/postcode). When a postcode is validated, an event is dispatched containing the sanitized string.
1616

17-
***Address autocomplete***
17+
**_Address autocomplete_**
1818

1919
`<address-autocomplete />` fetches addresses in a given UK postcode using the [OS Places API](https://developer.ordnancesurvey.co.uk/os-places-api) and displays them using GOV.UK's [accessible-autocomplete](https://github.com/alphagov/accessible-autocomplete) component. An event is dispatched with the OS record when you select an address.
2020

@@ -31,23 +31,25 @@ Find these components in the wild, including what we're learning through public
3131

3232
## Bring your own API keys
3333

34-
Different features rely on different APIs - namely from Ordnance Survey and Mapbox.
34+
Different features rely on different APIs - namely from Ordnance Survey and Mapbox.
3535

36-
You can set keys directly as props (eg `osApiKey`) on the applicable web components or [use a proxy](https://github.com/theopensystemslab/map/blob/main/docs/how-to-use-a-proxy.md) to mask these secrets.
36+
You can set keys directly as props (eg `osApiKey`) on the applicable web components or [use a proxy](https://github.com/theopensystemslab/map/blob/main/docs/how-to-use-a-proxy.md) to mask these secrets.
3737

3838
Address autocomplete utilises the OS Places API.
3939

4040
For the map:
41+
4142
- The `basemap` prop defaults to `"OSVectorTile"` which requires the OS Vector Tiles API
4243
- Basemap `"OSRaster"` uses the OS Maps API
4344
- Basemap `"MapboxSatellite"` requires a Mapbox Access Token with with scope `style:read`
4445
- The `"OSM"` (OpenStreetMap) basemap is available for users without any keys, and as a fallback if any of the above basemaps fail to build
4546
- `clickFeatures` requires the OS Features API
4647

4748
When using Ordnance Survey APIs:
49+
4850
- Update the `osCopyright` attribution prop with your license number
4951
- Configure an optional `osProxyEndpoint` to avoid exposing your keys (set this instead of `osApiKey`)
50-
- ** We are not currently supporting a similar proxy for Mapbox because access tokens can be restricted to specific URLs via your account
52+
- \*\* We are not currently supporting a similar proxy for Mapbox because access tokens can be restricted to specific URLs via your account
5153

5254
## Running locally
5355

@@ -75,6 +77,7 @@ We use [Pitsby](https://pitsby.com/) for documenting our web components. It's si
7577
We publish this package via [NPM](https://www.npmjs.com/package/@opensystemslab/map).
7678

7779
To create a new release:
80+
7881
1. Open a new PR against `main` which bumps the package.json "version" & creates a CHANGELOG.md entry, request code review & merge on approval
7982
1. Run `npm publish` or `npm publish --tag next` if making a pre-release (requires permissions to OSL team in NPM & access to 2-factor auth method)
8083
1. [Draft a new release](https://github.com/theopensystemslab/map/releases) via GitHub web: tag should match version, automatically generate changenotes and link above PR, then "Publish" and set as latest version (or set as pre-release if you used `--tag next` in above command)

docs/how-to-use-a-proxy.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# How to: Use a MyMap & AddressAutocomplete with a proxy
22

33
## Context
4-
Both `MyMap` and `AddressAutocomplete` can call the Ordnance Survey API directly, or via a proxy.
4+
5+
Both `MyMap` and `AddressAutocomplete` can call the Ordnance Survey API directly, or via a proxy.
56

67
Calling the API directly may be suitable for internal use, where exposure of API keys is not a concern, whilst calling a proxy may be more suitable for public use.
78

89
A proxy endpoint can be supplied via the `osProxyEndpoint` property on these components.
910

10-
Proxies are required to complete the following actions in order to work successfully -
11+
Proxies are required to complete the following actions in order to work successfully -
1112

1213
- Append a valid OS API key as a search parameter to incoming requests
1314
- Modify outgoing response with suitable CORS / CORP headers to allow the originating site access to the returned assets
1415

1516
## Diagram
17+
1618
```mermaid
1719
sequenceDiagram
1820
autonumber
@@ -28,25 +30,29 @@ sequenceDiagram
2830
```
2931

3032
## Examples
31-
Please see the sample code below for how a proxy could be implemented -
33+
34+
Please see the sample code below for how a proxy could be implemented -
3235

3336
### Express
37+
3438
Below is an annotated example of a simple proxy using [Express](https://github.com/expressjs/express) & [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware).
3539

3640
**index.js**
41+
3742
```js
3843
import express from "express";
3944
import { useOrdnanceSurveyProxy } from "proxy";
4045

41-
const app = express()
42-
const port = 3000
46+
const app = express();
47+
const port = 3000;
4348

44-
app.use('/proxy/ordnance-survey', useOrdnanceSurveyProxy)
49+
app.use("/proxy/ordnance-survey", useOrdnanceSurveyProxy);
4550

46-
app.listen(port)
51+
app.listen(port);
4752
```
4853

4954
**proxy.js**
55+
5056
```js
5157
import { createProxyMiddleware } from "http-proxy-middleware";
5258

@@ -94,4 +100,5 @@ export const appendAPIKey = (fullPath, req) => {
94100
return resultPath;
95101
};
96102
```
97-
> A working and more fleshed out example (in TypeScript) can be seen [here in the PlanX API](https://github.com/theopensystemslab/planx-new/blob/production/api.planx.uk/proxy/ordnanceSurvey.ts).
103+
104+
> A working and more fleshed out example (in TypeScript) can be seen [here in the PlanX API](https://github.com/theopensystemslab/planx-new/blob/production/api.planx.uk/proxy/ordnanceSurvey.ts).

index.html

Lines changed: 108 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
3-
4-
<head>
5-
<meta charset="UTF-8" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>OS Web Components Sandbox</title>
8-
<script type="module" src="./src/index.ts"></script>
9-
<!-- OS vector tile source specifies fonts in .pbf format, which OpenLayers can't load, so make them available directly -->
10-
<link rel="preconnect" href="https://fonts.googleapis.com" />
11-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
12-
<link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300;400;600&display=swap"
13-
rel="stylesheet" />
14-
<!-- Examples of available style options for postcode-search & address-autocomplete -->
15-
<!-- <style>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>OS Web Components Sandbox</title>
7+
<script type="module" src="./src/index.ts"></script>
8+
<!-- OS vector tile source specifies fonts in .pbf format, which OpenLayers can't load, so make them available directly -->
9+
<link rel="preconnect" href="https://fonts.googleapis.com" />
10+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
11+
<link
12+
href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300;400;600&display=swap"
13+
rel="stylesheet"
14+
/>
15+
<!-- Examples of available style options for postcode-search & address-autocomplete -->
16+
<!-- <style>
1617
address-autocomplete {
1718
--autocomplete__label__font-size: 25px;
1819
--autocomplete__input__padding: 6px 40px 7px 12px;
@@ -37,33 +38,37 @@
3738
--postcode__input__height: 60px;
3839
}
3940
</style> -->
40-
</head>
41+
</head>
4142

42-
<body style="font-family:Inter,Helvetica,sans-serif;">
43-
<div style="display:flex;flex-direction:column;">
44-
<h1 style="color:red;font-size:16px;">
45-
*** This is a testing sandbox - these components are unaware of each other!***
46-
</h1>
47-
<div style="margin-bottom:1em">
48-
<my-map
49-
id="example-map"
50-
ariaLabelOlFixedOverlay="Interactive example map"
51-
zoom="20"
52-
maxZoom="23"
53-
drawMode
54-
drawMany
55-
drawType="Point"
56-
basemap="MapboxSatellite"
57-
showCentreMarker
58-
osCopyright="© Crown copyright and database rights 2024 OS (0)100024857"
59-
osProxyEndpoint="https://api.editor.planx.dev/proxy/ordnance-survey"
60-
/>
61-
</div>
62-
<div style="margin-bottom:1em">
63-
<postcode-search hintText="Optional hint text shows up here" id="example-postcode" />
64-
</div>
65-
<div style="margin-bottom:1em; background-color: white;">
66-
<!--
43+
<body style="font-family: Inter, Helvetica, sans-serif">
44+
<div style="display: flex; flex-direction: column">
45+
<h1 style="color: red; font-size: 16px">
46+
*** This is a testing sandbox - these components are unaware of each
47+
other!***
48+
</h1>
49+
<div style="margin-bottom: 1em">
50+
<my-map
51+
id="example-map"
52+
ariaLabelOlFixedOverlay="Interactive example map"
53+
zoom="20"
54+
maxZoom="23"
55+
drawMode
56+
drawMany
57+
drawType="Point"
58+
basemap="MapboxSatellite"
59+
showCentreMarker
60+
osCopyright="© Crown copyright and database rights 2024 OS (0)100024857"
61+
osProxyEndpoint="https://api.editor.planx.dev/proxy/ordnance-survey"
62+
/>
63+
</div>
64+
<div style="margin-bottom: 1em">
65+
<postcode-search
66+
hintText="Optional hint text shows up here"
67+
id="example-postcode"
68+
/>
69+
</div>
70+
<div style="margin-bottom: 1em; background-color: white">
71+
<!--
6772
Examples (as of March 2022):
6873
SE5 OHU (Southwark): default/"standard" postcode example, fetches 65 LPI addresses
6974
SE19 1NT (Lambeth): 56 DPA addresses -> 128 LPI addresses (87 "approved"), now requires paginated fetch
@@ -73,86 +78,78 @@ <h1 style="color:red;font-size:16px;">
7378
Example with default value (used for planx "change" & "back" button behavior):
7479
<address-autocomplete postcode="SE5 0HU" id="example-autocomplete" initialAddress="75, COBOURG ROAD, LONDON" />
7580
-->
76-
<address-autocomplete postcode="SE5 0HU" id="example-autocomplete" arrowStyle="light" labelStyle="static" />
81+
<address-autocomplete
82+
postcode="SE5 0HU"
83+
id="example-autocomplete"
84+
arrowStyle="light"
85+
labelStyle="static"
86+
/>
87+
</div>
7788
</div>
78-
</div>
79-
<script>
80-
// --- MAP --- //
81-
const map = document.querySelector("my-map");
82-
map.clipGeojsonData = {
83-
"type": "Feature",
84-
"geometry": {
85-
"type": "Polygon",
86-
"coordinates": [
87-
[
88-
[
89-
-0.128307852848053,
90-
51.50748361634746
91-
],
92-
[
93-
-0.1274388171272278,
94-
51.50773069282454
95-
],
96-
[
97-
-0.12710085879135133,
98-
51.507243216327
99-
],
89+
<script>
90+
// --- MAP --- //
91+
const map = document.querySelector("my-map");
92+
map.clipGeojsonData = {
93+
type: "Feature",
94+
geometry: {
95+
type: "Polygon",
96+
coordinates: [
10097
[
101-
-0.12802890311050416,
102-
51.50705957656797
98+
[-0.128307852848053, 51.50748361634746],
99+
[-0.1274388171272278, 51.50773069282454],
100+
[-0.12710085879135133, 51.507243216327],
101+
[-0.12802890311050416, 51.50705957656797],
102+
[-0.128307852848053, 51.50748361634746],
103103
],
104-
[
105-
-0.128307852848053,
106-
51.50748361634746
107-
]
108-
]
109-
]
110-
},
111-
};
112-
113-
map.addEventListener("ready", (event) => {
114-
console.log("map ready");
115-
});
104+
],
105+
},
106+
};
116107

117-
// applicable when drawMode is enabled
118-
map.addEventListener("geojsonChange", ({ detail: geojson }) => {
119-
console.debug({ geojson });
120-
});
108+
map.addEventListener("ready", (event) => {
109+
console.log("map ready");
110+
});
121111

122-
// applicable when showFeaturesAtPoint is enabled
123-
map.addEventListener("featuresAreaChange", ({ detail: featuresArea }) => {
124-
console.debug({ featuresArea });
125-
});
126-
map.addEventListener("featuresGeojsonChange", ({ detail: featuresGeojson }) => {
127-
console.debug({ featuresGeojson });
128-
});
112+
// applicable when drawMode is enabled
113+
map.addEventListener("geojsonChange", ({ detail: geojson }) => {
114+
console.debug({ geojson });
115+
});
129116

130-
// applicable when geojsonData is provided
131-
map.addEventListener("geojsonDataArea", ({ detail: geojsonDataArea }) => {
132-
console.debug({ geojsonDataArea });
133-
});
117+
// applicable when showFeaturesAtPoint is enabled
118+
map.addEventListener("featuresAreaChange", ({ detail: featuresArea }) => {
119+
console.debug({ featuresArea });
120+
});
121+
map.addEventListener(
122+
"featuresGeojsonChange",
123+
({ detail: featuresGeojson }) => {
124+
console.debug({ featuresGeojson });
125+
},
126+
);
134127

135-
// --- POSTCODE SEARCH --- //
136-
const search = document.querySelector("postcode-search");
128+
// applicable when geojsonData is provided
129+
map.addEventListener("geojsonDataArea", ({ detail: geojsonDataArea }) => {
130+
console.debug({ geojsonDataArea });
131+
});
137132

138-
search.addEventListener("postcodeChange", ({ detail }) => {
139-
console.debug({ detail });
140-
});
133+
// --- POSTCODE SEARCH --- //
134+
const search = document.querySelector("postcode-search");
141135

142-
// --- ADDRESS AUTOCOMPLETE --- //
143-
const autocomplete = document.querySelector("address-autocomplete");
136+
search.addEventListener("postcodeChange", ({ detail }) => {
137+
console.debug({ detail });
138+
});
144139

145-
autocomplete.addEventListener("ready", ({ detail: data }) => {
146-
console.log("autocomplete ready", { data });
147-
});
140+
// --- ADDRESS AUTOCOMPLETE --- //
141+
const autocomplete = document.querySelector("address-autocomplete");
148142

149-
autocomplete.addEventListener(
150-
"addressSelection",
151-
({ detail: address }) => {
152-
console.debug({ detail: address });
153-
}
154-
);
155-
</script>
156-
</body>
143+
autocomplete.addEventListener("ready", ({ detail: data }) => {
144+
console.log("autocomplete ready", { data });
145+
});
157146

158-
</html>
147+
autocomplete.addEventListener(
148+
"addressSelection",
149+
({ detail: address }) => {
150+
console.debug({ detail: address });
151+
},
152+
);
153+
</script>
154+
</body>
155+
</html>

pitsby.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ module.exports = {
99
styles: ["./dist/map.css"],
1010
scripts: ["./dist/component-lib.es.js", "./dist/component-lib.umd.js"],
1111
custom: {
12-
windowTitle: 'Docs - Place Components',
12+
windowTitle: "Docs - Place Components",
1313
},
1414
};

0 commit comments

Comments
 (0)