![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
@ldrender/gradient-picker
Advanced tools
A powerful and customizable gradient picker for modern web applications
npm install @ldrender/gradient-picker
# Start development server
npm run dev
# Build for production
npm run build
import GradientPicker from '@ldrender/gradient-picker';
import '@ldrender/gradient-picker/dist/gradient-picker.css';
const gradientPicker = new GradientPicker({
el: '#gradient-picker',
preview: true,
stops: [
{ color: '#ff0000', offset: 0 },
{ color: 'rgb(0, 255, 0)', offset: 33 },
{ color: 'blue', offset: 66 },
{ color: 'hsl(270, 100%, 50%)', offset: 100 }
]
});
interface GradientPickerProps {
el: string; // Selector for the target element
stops?: GradientStop[]; // Initial color stops
type?: 'linear' | 'radial'; // Gradient type (default: 'linear')
direction?: string | number; // Gradient direction (default: 'right')
directionType?: 'select' | 'percent'; // Direction input type (default: 'select')
directionRadial?: boolean; // For gradient type 'radial', select if direction input is displayed (default: true)
returnType?: 'string' | 'object' | 'stops-list'; // Output format (default: 'string')
preview?: boolean; // Enable preview window (default: false)
}
interface GradientStop {
color: string; // CSS color value
offset: number; // Position in percentage (0-100)
id: number; // Unique identifier
}
string
: CSS gradient stringobject
: Gradient configuration objectstops-list
: Array of color stops onlyReturns the gradient configuration as an object.
interface GradientObject {
type: 'linear' | 'radial';
direction: string | number;
stops: Array<{ color: string; offset: number; }>;
}
Returns an array of color stops.
Adds a new color stop to the gradient.
Parses and imports a CSS gradient string.
gradientPicker.importFromCSSString('linear-gradient(to right, #ff0000 0%, #00ff00 50%)');
Changes the direction input type dynamically.
Fired whenever the gradient is modified:
document.querySelector('#gradient-picker').addEventListener('change', (event) => {
const value = event.target.value;
// value format depends on returnType option
});
The picker includes built-in validation for:
try {
gradientPicker.addColorStop('invalid-color', 50);
} catch (error) {
console.error('Invalid color format');
}
0 - 360
top
, right
, bottom
, left
top
, right
, bottom
, left
, center
0
= at center
1 - 89
= at center top
90 - 179
= at center right
,180 - 269
= at center bottom
,270 - 359
= at center left
360
= at center top
#ff0000
, #f00
rgb(255, 0, 0)
, rgba(255, 0, 0, 0.5)
hsl(0, 100%, 50%)
, hsla(0, 100%, 50%, 0.5)
red
, blue
, forestgreen
, etc.// Hexadecimal
gradientPicker.addColorStop('#ff0000', 0); // Standard hex
gradientPicker.addColorStop('#f00', 0); // Short hex
// RGB/RGBA
gradientPicker.addColorStop('rgb(255, 0, 0)', 0);
gradientPicker.addColorStop('rgba(255, 0, 0, 0.5)', 0);
// HSL/HSLA
gradientPicker.addColorStop('hsl(0, 100%, 50%)', 0);
gradientPicker.addColorStop('hsla(0, 100%, 50%, 0.5)', 0);
// Named Colors
gradientPicker.addColorStop('red', 0);
gradientPicker.addColorStop('blue', 50);
gradientPicker.addColorStop('green', 100);
The picker includes an optimized color normalization system with caching for improved performance.
Supports all standard CSS color names (140+ colors). Full list available in the source code. Named Colors List supporter
The picker includes a default stylesheet that can be customized to match your application's design. You must use the following variables : (You can override the default styles by defining these variables in your own stylesheet)
.gradient-picker {
--gradient-picker-box-shadow: inset 0 0 0.5px 1px hsla(0, 0%, 100%, 0.1),
0 0 0 1px hsla(230, 13%, 9%, 0.075),
0 0.3px 0.4px hsla(230, 13%, 9%, 0.02),
0 0.9px 1.5px hsla(230, 13%, 9%, 0.045),
0 3.5px 6px hsla(230, 13%, 9%, 0.09);
--gradient-picker-preview-height: 120px;
--gradient-picker-input-height: 36px;
--gradient-picker-input-padding: 0.5rem;
--gradient-picker-input-border: unset;
--gradient-picker-handler-border: solid 3px rgb(61, 61, 61);
--gradient-picker-line-height: 36px;
--gradient-picker-font-size: 14px;
--gradient-picker-border-radius: 8px;
--gradient-picker-focus-outline: none;
--gradient-picker-focus-box-shadow: 0 0 0 2px rgb(0, 95, 204);
--gradient-picker-focus-border-color: rgb(0, 95, 204);
--gradient-picker-remover-color: #555;
--gradient-picker-remover-color-hover: rgb(229, 64, 64);
--gradient-picker-background-color: #fff;
--gradient-picker-color: #000;
}
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
A gradient picker component
The npm package @ldrender/gradient-picker receives a total of 20 weekly downloads. As such, @ldrender/gradient-picker popularity was classified as not popular.
We found that @ldrender/gradient-picker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.