react-iro-gradient-picker 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/package.json +1 -1
package/README.md
CHANGED
@@ -246,6 +246,56 @@ function FormatExample() {
|
|
246
246
|
}
|
247
247
|
```
|
248
248
|
|
249
|
+
### 🎨 Default Gradient Selection
|
250
|
+
|
251
|
+
Control which gradient is used when switching from solid to gradient tab:
|
252
|
+
|
253
|
+
```tsx
|
254
|
+
import React, { useState } from 'react';
|
255
|
+
import ColorPicker from 'react-iro-gradient-picker';
|
256
|
+
|
257
|
+
function GradientExample() {
|
258
|
+
const [color, setColor] = useState('#FF6B6B');
|
259
|
+
|
260
|
+
return (
|
261
|
+
<ColorPicker
|
262
|
+
solid
|
263
|
+
gradient
|
264
|
+
value={color}
|
265
|
+
onChange={setColor}
|
266
|
+
defaultGradientIndex={0} // Use first gradient from defaultColors (index 0)
|
267
|
+
/>
|
268
|
+
);
|
269
|
+
}
|
270
|
+
```
|
271
|
+
|
272
|
+
**How it works:**
|
273
|
+
|
274
|
+
- `defaultGradientIndex` controls which gradient from your `defaultColors` array is used as the default
|
275
|
+
- Default value is `7` (8th gradient in the array)
|
276
|
+
- When switching from **Solid → Gradient** tab, the picker shows this gradient instead of converting the solid color
|
277
|
+
- The selected gradient is automatically highlighted in the Popular Colors panel
|
278
|
+
- Helps maintain consistent UX by starting with a predefined gradient
|
279
|
+
|
280
|
+
**Examples:**
|
281
|
+
|
282
|
+
```tsx
|
283
|
+
// Use the first gradient (index 0)
|
284
|
+
<ColorPicker defaultGradientIndex={0} gradient solid />
|
285
|
+
|
286
|
+
// Use the 5th gradient (index 4)
|
287
|
+
<ColorPicker defaultGradientIndex={4} gradient solid />
|
288
|
+
|
289
|
+
// Default behavior (uses index 7)
|
290
|
+
<ColorPicker gradient solid />
|
291
|
+
```
|
292
|
+
|
293
|
+
**Smart bounds checking:**
|
294
|
+
|
295
|
+
- If index is negative, uses `0`
|
296
|
+
- If index exceeds available gradients, uses the last gradient
|
297
|
+
- If no gradients in `defaultColors`, uses a fallback gradient
|
298
|
+
|
249
299
|
### 📚 **[→ View Complete Documentation & Examples](https://romfatal.github.io/react-iro-gradient-picker/)**
|
250
300
|
|
251
301
|
## 🌟 What Makes This Special
|
@@ -431,6 +481,7 @@ linear-gradient(90deg, notacolor, #4ECDC4)
|
|
431
481
|
| colorBoardHeight | `number` | `120` | Board color height |
|
432
482
|
| defaultColors | `array` | [List](#default-color-list) | Default colors array for panel picker |
|
433
483
|
| defaultActiveTab | `string` | `undefined` | Default value for active tab when initializing the component, takes two values: `solid` or `gradient` |
|
484
|
+
| defaultGradientIndex | `number` | `7` | Index of the gradient from `defaultColors` to use when switching from solid to gradient tab |
|
434
485
|
| onChangeTabs | `function` | `null` | Default onChange function detect when tabs change and return one of the values: `solid` or `gradient` |
|
435
486
|
| onChange | `function` | `null` | Default onChange function returns string value in the given format |
|
436
487
|
| showReset | `bool` | `false` | Show/hide reset button in the picker interface |
|
package/package.json
CHANGED