8.2.13 • Published 2 days ago

@local-logic/elements-react v8.2.13

Weekly downloads
-
License
MIT
Repository
-
Last release
2 days ago

Local Logic Elements React (Alpha)

⚠️ This package is in active development and is not production-ready.

Local Logic Elements React provides a set of modular, composable UI components built on top of the Local Logic API.

Getting started

Installation

First, install with yarn, pnpm, or npm:

yarn add @local-logic/elements-react
pnpm add @local-logic/elements-react
npm i --save @local-logic/elements-react

Be sure to install all peer dependencies.

The script is also available in UMD and EMS format from the Local Logic CDN: https://sdk.locallogic.co/elements-react///index.min.js

Note: Using the CDN approach in production is discouraged. The CDN requires the client download the entire elements library, regardless of which elements are used.

Usage

You can now import LocalLogicProvider:

import { LocalLogicProvider } from "@local-logic/elements-react";

const App = () => {
  return (
    <LocalLogicProvider
      apiKey="<YOUR_TOKEN>"
    >
      //...
    </LocalLogicProvider>
  );
}

ℹ️ Your apiKey should be provided to you by a Local Logic team member.

Within the context of your LocalLogicProvider, you can now add Elements.

import { Scores } from "@local-logic/elements-react";

const MyComponent = () => {
  return (
    <Scores
      options={{
        lat: 43.642567,
        lng: -79.387054,
        geographyLevels: ["10", "30"]
      }}
    />
  )
}

API

LocalLogicProvider

LocalLogicProvider component provides request caching, and accepts configuration options. It can be placed anywhere, but should wrap all Local Logic Elements.

Options

NameRequiredTypeDefaultDescription
apiKeytruestringAuth apiKey required for making requests to the Local Logic API.
options.appearancefalseAppearanceAPIThe appearance option provides theme and variable support customizing the look and feel of Local Logic Elements.
options.localefalse"en" \| "fr""en"The locale option specifies the language of the scores and the UI interface.

useLocalLogic

The useLocalLogic hook provides access to the client and appearance objects.

Options

None.

Returns

NameTypeDescription
clientMethodsCan be used to make requests to the Local Logic API.
appearanceAppearanceAPI["appearance"]Contains Local Logic theme and variable values.

Scores

The Scores component provide a UI visualization of Local Logic scores and associated points of interest.

Options

NameRequiredTypeDefaultDescription
options.latfalsenumberA decimal number between -90 and 90 (Latitude).
options.lngfalsenumberA decimal number between -180 and 180 (Longitude).
options.geographyIdsfalsestring[]A comma separated list of geography ids, ex. g30_dpz89rm7 or g30_dpz89rm7, g10_dpz89rm7. If this parameter is provided, the lat and lng parameters are optional.
options.geographyLevelsfalse("10" \| "20" \| "30")[]A list of geography levels to include, ex. 10,30. If no geography levels are provided, no geography scores will be returned.
options.locationScoresRoundingfalseboolean.5The type of rounding to apply to the scores returned under data.location. Either .5 (default) to round at the nearest 0.5, or none, to disable rounding.
options.includefalse("high_schools" \| ... \| "daycares")[]All scoresAn array containing ScoreNames to return, ex. ["car_friendly", "pedestrian_friendly"]. If no names are provided, all scores will be returned.
onChangefalse({ type, data }) => voidThe onChange callback is triggered when the component state changes.

TypeScript Support

Local Logic Elements React comes packaged with TypeScript declarations.

8.2.13

2 days ago

8.2.12

6 days ago

8.2.11

10 days ago

8.2.10

13 days ago

8.2.9

25 days ago

8.2.7

3 months ago

8.2.8

3 months ago

8.2.6

4 months ago

8.2.5

5 months ago

8.2.3

6 months ago

8.2.2

6 months ago

8.2.4

5 months ago

8.1.0

7 months ago

8.1.1

7 months ago

8.2.1

7 months ago

8.2.0

7 months ago

7.1.1

10 months ago

7.1.0

10 months ago

8.0.1

9 months ago

8.0.0

9 months ago

8.0.2

9 months ago

7.0.7

11 months ago

7.0.6

11 months ago

7.0.5

12 months ago

7.0.9

11 months ago

6.0.7

1 year ago

6.0.9

12 months ago

6.0.8

12 months ago

7.0.0

12 months ago

7.0.4

12 months ago

7.0.3

12 months ago

7.0.2

12 months ago

7.0.1

12 months ago

7.0.10

11 months ago

7.0.11

11 months ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.6

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

6.0.6

1 year ago

4.0.1

1 year ago

4.0.0

1 year ago

4.0.2

1 year ago

5.0.0

1 year ago

6.0.1

1 year ago

6.0.0

1 year ago

6.0.3

1 year ago

6.0.2

1 year ago

6.0.5

1 year ago

6.0.4

1 year ago

3.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

1.2.1

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.0

1 year ago

1.0.0-beta.44

1 year ago

1.0.0-beta.45

1 year ago

1.0.0-beta.42

1 year ago

1.0.0-beta.43

1 year ago

1.0.0-beta.40

2 years ago

1.0.0-beta.41

1 year ago

1.0.0-beta.33

2 years ago

1.0.0-beta.34

2 years ago

1.0.0-beta.39

2 years ago

1.0.0-beta.37

2 years ago

1.0.0-beta.38

2 years ago

1.0.0-beta.35

2 years ago

1.0.0-beta.36

2 years ago

1.0.0-beta.22

2 years ago

1.0.0-beta.23

2 years ago

1.0.0-beta.21

2 years ago

1.0.0-beta.28

2 years ago

1.0.0-beta.29

2 years ago

1.0.0-beta.26

2 years ago

1.0.0-beta.27

2 years ago

1.0.0-beta.24

2 years ago

1.0.0-beta.25

2 years ago

1.0.0-beta.31

2 years ago

1.0.0-beta.32

2 years ago

1.0.0-beta.30

2 years ago

1.0.0-beta.20

2 years ago

1.0.0-alpha.3

2 years ago

1.0.0-alpha.2

2 years ago

1.0.0-alpha.1

2 years ago

1.0.0-beta.4

2 years ago

1.0.0-beta.5

2 years ago

1.0.0-beta.11

2 years ago

1.0.0-beta.12

2 years ago

1.0.0-beta.10

2 years ago

1.0.0-beta.6

2 years ago

1.0.0-beta.7

2 years ago

1.0.0-beta.8

2 years ago

1.0.0-beta.9

2 years ago

1.0.0-beta.19

2 years ago

0.2.7

2 years ago

1.0.0-beta.17

2 years ago

1.0.0-beta.18

2 years ago

1.0.0-beta.15

2 years ago

1.0.0-beta.16

2 years ago

1.0.0-beta.13

2 years ago

1.0.0-beta.14

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.3

2 years ago