Skip to content

Commit b4110a8

Browse files
committed
docs: update README examples and badges
1 parent 00d475b commit b4110a8

1 file changed

Lines changed: 43 additions & 35 deletions

File tree

README.md

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
# react-native-material-palette
22

33
[![Build Status][build-badge]][build]
4-
[![Code Coverage][coverage-badge]][coverage]
54
[![Version][version-badge]][package]
65
[![MIT License][license-badge]][license]
7-
8-
[![PRs Welcome][prs-welcome-badge]][prs-welcome]
96
[![Chat][chat-badge]][chat]
10-
[![Code of Conduct][coc-badge]][coc]
117

128
[Android Palette API](https://developer.android.com/training/material/palette-colors.html) brought to react native. It extracts prominent colors from images to help you create visually engaging apps.
139

@@ -69,14 +65,17 @@ Each `PaletteSwatch` has the following properties:
6965
Specifies a rectangular area of the image to use for palette generation. Coordinates are in pixels.
7066

7167
```tsx
72-
const palette = await createPalette(source, {
73-
region: {
74-
left: 0,
75-
top: 0,
76-
right: 100,
77-
bottom: 100,
78-
},
79-
});
68+
const palette = await createPalette(
69+
{ uri: 'https://example.com/photo.jpg' },
70+
{
71+
region: {
72+
left: 0,
73+
top: 0,
74+
right: 100,
75+
bottom: 100,
76+
},
77+
}
78+
);
8079
```
8180

8281
##### `maximumColorCount`
@@ -90,18 +89,21 @@ Extract a single swatch using a custom target for fine-grained control over colo
9089
```tsx
9190
import { createPaletteForTarget } from 'react-native-material-palette';
9291

93-
const swatch = await createPaletteForTarget(source, {
94-
targetLightness: 0.5,
95-
minimumLightness: 0.2,
96-
maximumLightness: 0.8,
97-
targetSaturation: 0.7,
98-
minimumSaturation: 0.3,
99-
maximumSaturation: 1.0,
100-
lightnessWeight: 0.6,
101-
saturationWeight: 0.3,
102-
populationWeight: 0.1,
103-
exclusive: true,
104-
});
92+
const swatch = await createPaletteForTarget(
93+
{ uri: 'https://example.com/photo.jpg' },
94+
{
95+
targetLightness: 0.5,
96+
minimumLightness: 0.2,
97+
maximumLightness: 0.8,
98+
targetSaturation: 0.7,
99+
minimumSaturation: 0.3,
100+
maximumSaturation: 1.0,
101+
lightnessWeight: 0.6,
102+
saturationWeight: 0.3,
103+
populationWeight: 0.1,
104+
exclusive: true,
105+
}
106+
);
105107
```
106108

107109
It accepts the same `region` and `maximumColorCount` options as `createPalette` in an optional third argument.
@@ -114,7 +116,10 @@ A hook for using palette colors in components. It extracts a single swatch based
114116
import { usePaletteSwatch } from 'react-native-material-palette';
115117

116118
function MyComponent() {
117-
const swatch = usePaletteSwatch(source, { type: 'vibrant' });
119+
const swatch = usePaletteSwatch(
120+
{ uri: 'https://example.com/photo.jpg' },
121+
{ type: 'vibrant' }
122+
);
118123

119124
return (
120125
<View style={{ backgroundColor: swatch?.color ?? 'white' }}>
@@ -140,7 +145,10 @@ import { Palette } from 'react-native-material-palette';
140145

141146
function MyComponent() {
142147
return (
143-
<Palette.View source={imageSource} type="vibrant">
148+
<Palette.View
149+
source={{ uri: 'https://example.com/photo.jpg' }}
150+
type="vibrant"
151+
>
144152
{/* your content */}
145153
</Palette.View>
146154
);
@@ -166,7 +174,10 @@ import { Palette } from 'react-native-material-palette';
166174

167175
function MyComponent() {
168176
return (
169-
<Palette.Text source={imageSource} type="vibrant">
177+
<Palette.Text
178+
source={{ uri: 'https://example.com/photo.jpg' }}
179+
type="vibrant"
180+
>
170181
Hello, World!
171182
</Palette.Text>
172183
);
@@ -186,7 +197,10 @@ import { Palette } from 'react-native-material-palette';
186197

187198
function MyComponent() {
188199
return (
189-
<Palette.View source={imageSource} type="vibrant">
200+
<Palette.View
201+
source={{ uri: 'https://example.com/photo.jpg' }}
202+
type="vibrant"
203+
>
190204
<Palette.Text>Hello, World!</Palette.Text>
191205
</Palette.View>
192206
);
@@ -215,15 +229,9 @@ Made with [create-react-native-library](https://github.com/callstack/react-nativ
215229

216230
[build-badge]: https://github.com/callstack/react-native-material-palette/actions/workflows/ci.yml/badge.svg
217231
[build]: https://github.com/callstack/react-native-material-palette/actions/workflows/ci.yml
218-
[coverage-badge]: https://img.shields.io/coveralls/github/callstack/react-native-material-palette.svg
219-
[coverage]: https://coveralls.io/github/callstack/react-native-material-palette?branch=main
220232
[version-badge]: https://img.shields.io/npm/v/react-native-material-palette.svg
221233
[package]: https://www.npmjs.com/package/react-native-material-palette
222234
[license-badge]: https://img.shields.io/npm/l/react-native-material-palette.svg
223235
[license]: https://opensource.org/licenses/MIT
224-
[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
225-
[prs-welcome]: http://makeapullrequest.com
226-
[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg
227-
[coc]: https://github.com/callstack/react-native-material-palette/blob/main/CODE_OF_CONDUCT.md
228-
[chat-badge]: https://img.shields.io/discord/426714625279524876.svg&colorB=758ED3
236+
[chat-badge]: https://img.shields.io/badge/chat-Discord-5b65ea.svg
229237
[chat]: https://discord.gg/zwR2Cdh

0 commit comments

Comments
 (0)