0.1.7 • Published 10 months ago

@ahamove/react v0.1.7

Weekly downloads
-
License
-
Repository
-
Last release
10 months ago

@ahamove/react

npm npm

Overview

The @ahamove/react library provides a set of React components designed to help developers integrate Ahamove's services into our applications easily. This library includes various UI components such as AddressAutocomplete and a ThemeProvider to ensure a consistent and customizable design, built upon the Mantine component library.

Installation

To install @ahamove/react, you can use npm or yarn:

npm install @ahamove/react

or

yarn add @ahamove/react

Usage

Here is an example of how to use the @ahamove/react library in a React application.

import "./App.css";
import "@ahamove/react/style.css";

import { useState } from "react";
import { AddressAutocomplete } from "@ahamove/react/address-autocomplete";
import { ThemeProvider, ahamoveTheme } from "@ahamove/react/theme";

function App() {
  const [address, setAddress] = useState<Address | null>({
    address:
      "AhaMove, Đường Thành Thái, Phường 12 (Quận 10), Quận 10, Hồ Chí Minh, Việt Nam",
    lat: 10.769445,
    lng: 106.663756,
  });
  const customTheme = {
    ...ahamoveTheme,
    breakpoints: {
      ...ahamoveTheme?.breakpoints,
      tablet: "768px",
    },
  };

  return (
    <div
      style={{
        width: "400px",
      }}
    >
      <ThemeProvider theme={customTheme}>
        <AddressAutocomplete
          inputProps={{}}
          lang="en"
          address={address}
          apiURL="__API_URL__"
          apiKey="__API_KEY__"
          onChange={setAddress}
        />
      </ThemeProvider>
      <pre
        style={{
          whiteSpace: "pre-wrap",
          textAlign: "left",
          border: "1px solid rgb(206, 212, 218)",
          borderRadius: "4px",
          fontSize: "14px",
          lineHeight: "1.5",
          padding: "10px",
          minHeight: "100px",
        }}
      >
        <code>{JSON.stringify(address, null, 2)}</code>
      </pre>
    </div>
  );
}

export default App;

Components

AddressAutocomplete

Ahamove AddressAutocomplete

AddressAutocomplete is a component that provides an autocomplete input for addresses, integrating with Ahamove's API. It is built on top of Mantine's components to ensure a smooth and modern user experience.

PropTypeDescription
inputPropsObjectObject containing additional props for the input element.
langStringLanguage for the autocomplete suggestions.
addressObjectThe initial address object with address, lat, and lng.
apiURLStringThe URL for the AhaMove API.
apiKeyStringThe API key for authenticating requests.
onChangeFunctionCallback function that is triggered when the address changes.

ThemeProvider

ThemeProvider is a component that provides theming capabilities for the library's components. It leverages Mantine's theming system to allow extensive customization. You need to wrap your components with the ThemeProvider.

PropTypeDescription
themeObjectThe default theme object for the components based on Ahamove's design system. It's applied by default if no custom theme is provided.

Customization

You can customize the styles of the components by providing your own theme object to the ThemeProvider, utilizing Mantine's theming capabilities.

const customTheme = {
  ...ahamoveTheme,
  breakpoints: {
    ...ahamoveTheme?.breakpoints,
    tablet: "768px",
  },
};

<ThemeProvider theme={customTheme}>{/* Your components */}</ThemeProvider>;

API Key

To use the AddressAutocomplete component, you will need an API key (__API_KEY__) and URL (__API_URL__). You can obtain this key from the Ahamove developer portal.

License

This library is licensed under the MIT License.

Support

For any questions or support, please contact our support team.

0.1.7

10 months ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.0.2

1 year ago

0.1.0

1 year ago

0.0.1

1 year ago