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

https://github.com/niborb/react-native-gravatar

React Native Gravatar component
https://github.com/niborb/react-native-gravatar

Last synced: 2 months ago
JSON representation

React Native Gravatar component

Awesome Lists containing this project

README

          

# React Native Gravatar component

[![npm version](https://img.shields.io/npm/v/react-native-avatar-gravatar.svg?style=flat-square)](https://www.npmjs.com/package/react-native-avatar-gravatar)
[![npm downloads](https://img.shields.io/npm/dm/react-native-avatar-gravatar.svg?style=flat-square)](https://www.npmjs.com/package/react-native-avatar-gravatar)

React Native Gravatar is a simple component that loads the avatar with an option to mask it with a circle, rounded or square shape.

- [Installation](#installation)
- [Usage](#usage)
- [Properties](#properties)
- [TypeScript](#typescript)
- [Development](#development)

## Installation
```
npm install react-native-avatar-gravatar
```

Requires `react >= 18` and `react-native >= 0.70`.

## Usage
```jsx
import React from 'react';
import Gravatar from 'react-native-avatar-gravatar';

const Application = () => (

);

export default Application;
```

## Properties

| Prop | Default | Type | Description |
| :----------- | :---------: | :-------------------------------------------------------------------------------: | :---------- |
| emailAddress | `''` | `string` | Email address for the gravatar. If not provided the default image is used. |
| size | `600` | `number` | Requested gravatar size. The rendered image uses `size / 2` for its width/height. Pass an explicit value for best results. |
| mask | `'circle'` | `'circle' \| 'square' \| 'rounded'` | Mask shape applied to the image. |
| defaultImage | `'retro'` | `'404' \| 'mm' \| 'identicon' \| 'monsterid' \| 'wavatar' \| 'retro' \| 'robohash' \| 'blank'` | Default gravatar style when no image is available. |
| resizeMode | `'contain'` | `'cover' \| 'contain' \| 'stretch' \| 'repeat' \| 'center'` | `resizeMode` forwarded to the underlying `Image`. |
| secure | `true` | `boolean` | When `false`, requests the image over HTTP instead of HTTPS. |

All extra `View` props are forwarded to the wrapping container.

## TypeScript

Types ship with the package:

```ts
import Gravatar, { GravatarProps, GravatarMask, GravatarDefaultImage } from 'react-native-avatar-gravatar';
```

## Development

```
npm install
npm run lint
npm run typecheck
npm test
npm run build
```

The compiled output (`lib/`) is generated by `tsc` and is what gets published to npm.