Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vpukhanov/react-character-map

An easy to include character map selector component built with React
https://github.com/vpukhanov/react-character-map

character-map component component-library react

Last synced: 8 days ago
JSON representation

An easy to include character map selector component built with React

Awesome Lists containing this project

README

        

# @vpukhanov/react-character-map [![Storybook](https://raw.githubusercontent.com/storybookjs/brand/master/badge/badge-storybook.svg)](https://react-character-map.now.sh/)

`@vpukhanov/react-character-map` is an easy to include character map selector component built with React. It provides a simple user interface to select a character from a categorised list. It is based on the original `react-character-map` by Joel Day, but rebuilt from the ground up using TypeScript
and functional components.

[View live Storybook example](https://react-character-map.now.sh/)



react-character-map preview image

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [Basic Usage](#basic-usage)
- [Advanced Usage](#advanced-usage)
- [Contributions](#contributions)

## Installation

```
npm install @vpukhanov/react-character-map
```

## Usage

### Basic Usage

You can use the pre-configured `CharMap` component that includes the category menu and the character selector itself. Provide
`onSelect` callback to receive character data of the user's selection. Optionally provide the `characterData` prop to replace
the built-in symbols with your own. You can also change the category that is selected by default by passing in a
`defaultSelectedCategory` prop and define how the category names are displayed using the `categoryNames` prop.

```tsx
import { CharMap } from "@vpukhanov/react-character-map";
// ...
alert(`You selected ${char.char}!`)} />;
```

### Advanced Usage

You can also use separate `CharMapCategoriesList` and `CharMapSelector` components if you want to build a custom layout.
They have to be wrapped in a `CharMapContextProvider` in order to function correctly.

```tsx
import {
CharMapCategoriesList,
CharMapSelector,
CharMapContextProvider,
} from "@vpukhanov/react-character-map";
// ...


Some text between categories and selector

alert(`You selected ${char.char}!`)} />
;
```

`CharMapContextProvider` accepts the `characterData`, `defaultSelectedCategory` and `categoryNames` props described earlier.
`CharMapCategoriesList` allows for additional customisations by setting the optional `buttonClassName` and
`activeButtonClassName` props.

## Contributions

All contributions are welcomed, feel free to send a pull request straight away, unless it's a major change. In that case
please create an issue for prior discussion.