1.42.0 • Published 6 days ago

@etchteam/recycling-locator v1.42.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 days ago

Recycling Locator

Powered by RecycleNow.com, this tool can be used to search and find recycling locations throughout the United Kingdom. It’s been created as an embeddable widget that can be added to any website to help visitors discover more recycling options.

Add the widget to your website

To apply to embed the widget on your website, email us at PartnerEnquiries@wrap.org.uk.

Installation won't work until your application has been approved.

Option 1: Install the script

Add the script above the closing </body> tag.

<script src="https://rl.recyclenow.com/wrap-rlw.js" async defer></script>

Include an element with the id "wrap-rlw" into your HTML, this is where the widget will be output.

<div id="wrap-rlw"></div>

Include the global stylesheet (optional)

<link href="">

Option 2: Install the web component

Install via NPM

npm i -S @etchteam/recycling-locator`

Include the web component in your HTML, this is where the widget will be output.

<recycling-locator></recycling-locator>

Include the stylesheet within your website styles (optional)

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@etchteam/recycling-locator@latest/dist/recycling-locator.css">

⚠️ Dependabot is configured to notify daily for NPM version changes, falling out of date means the widget could stop working due to upstream breaking API changes.

Available settings

Locale

Use the locale attribute to set the language.

The language code for Welsh (cy) is currently the only supported language code.

Script

<script src="..." data-locale="cy"></script>

Web component

<recycling-locator locale="cy"></recycling-locator>

Theme

Accepted values are red, blue, green, orange, purple, brown, navy, or black.

Script

<script src="..." data-theme="red"></script>

Web component

<recycling-locator theme="red"></recycling-locator>

CSS variables

For more granular control over the theme, add CSS variables to your stylesheet.

:root{
  /* The primary colour is the main color that's changed via theme presets */
  --recycling-locator-color-primary-lightest: #eef5e5;
  --recycling-locator-color-primary-light: #dfefc8;
  --recycling-locator-color-primary: #8dc63f;
  --recycling-locator-color-primary-dark: #297f00;

  /* Other variables control specific parts of the UI */
  --recycling-locator-theme-background: #fff;
  --recycling-locator-theme-background-muted-light: #f5f6f8;
  --recycling-locator-theme-heading-color-light: #222;
  --recycling-locator-theme-color-light: #222;
  --recycling-locator-theme-color-muted-light: #4f4f4f;
  --recycling-locator-theme-color-hover: var(--recycling-locator-color-primary-dark);
  --recycling-locator-theme-border-color-light: #cfd1d3;
  --recycling-locator-theme-border-color-hover-light: var(--recycling-locator-color-primary-dark);
  --recycling-locator-theme-link-color: #0077ab;
}

Path

The initial path to load. Common examples include:

  • /{postcode} to pre-fill the location
  • /home-recycling for home recycling embeds
  • /material?materials=111&search=Cereal boxes to pre-select a material
  • /{postcode}/places/{placeName}/{placePostcode} to load a single place

To discover other possible initial path combinations, take note of the path in the URL whilst navigating on the standalone version of the tool at locator.recyclenow.com.

Script

<script src="..." data-initial-path="/home-recycling"></script>

Web component

<recycling-locator path="/home-recycling"></recycling-locator>

Materials

This setting is only available for the script embed method for backwards compatibility. The same can be achieved by passing materials in the path web component attribute.

Example with material id:

<script src="..." data-materials="1"></script>

Example with multiple materials:

<script src="..." data-materials="[1,2]"></script>

Listening for when the locator has loaded

The <recycling-locator> will dispatch a custom "ready" event when the UI has rendered.

document
  .querySelector('recycling-locator')
  .addEventListener('ready', () => {
    console.info('Ready to recycle');
  });

Contributing

Looking to contribute to the code? A good starting point is the contributing docs.

1.42.0

6 days ago

1.41.2

6 days ago

1.41.1

8 days ago

1.41.0

9 days ago

1.39.1

12 days ago

1.40.0

12 days ago

1.39.0

13 days ago

1.38.2

14 days ago

1.38.1

15 days ago

1.38.0

21 days ago

1.37.2

21 days ago

1.37.0

23 days ago

1.37.1

23 days ago

1.35.0

26 days ago

1.36.0

26 days ago

1.34.1

1 month ago

1.34.0

1 month ago

1.33.0

1 month ago

1.32.0

1 month ago

1.32.1

1 month ago

1.32.2

1 month ago

1.31.1

1 month ago

1.31.0

1 month ago

1.29.0

1 month ago

1.30.0

1 month ago

1.28.0

2 months ago

1.27.0

2 months ago

1.26.0

2 months ago

1.25.0

2 months ago

1.24.2

2 months ago

1.23.0

2 months ago

1.24.1

2 months ago

1.24.0

2 months ago

1.22.3

2 months ago

1.22.4

2 months ago

1.22.1

2 months ago

1.22.2

2 months ago

1.19.0

2 months ago

1.21.0

2 months ago

1.20.1

2 months ago

1.22.0

2 months ago

1.20.0

2 months ago

1.18.0

2 months ago

1.17.0

2 months ago

1.16.1

2 months ago

1.15.4

2 months ago

1.16.0

2 months ago

1.15.3

2 months ago

1.15.2

2 months ago

1.15.0

2 months ago

1.14.0

2 months ago

1.13.0

2 months ago

1.15.1

2 months ago

1.12.0

2 months ago

1.9.0

2 months ago

1.11.0

2 months ago

1.10.1

2 months ago

1.10.0

2 months ago

1.2.0

2 months ago

1.1.1

2 months ago

1.1.0

2 months ago

1.8.0

2 months ago

1.2.6

2 months ago

1.7.0

2 months ago

1.2.5

2 months ago

1.6.0

2 months ago

1.2.4

2 months ago

1.5.0

2 months ago

1.2.3

2 months ago

1.4.0

2 months ago

1.2.2

2 months ago

1.3.0

2 months ago

1.2.1

2 months ago

1.1.2

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago

0.0.0

2 months ago