Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@workday/canvas-kit-labs-react-color-picker
Advanced tools
Readme
Color Picker is a popup for selecting a color.
The Color Picker is designed to be used different contexts. The pattern shown below is one where the Color Picker is used as a popup from a button target by using hooks around the callbacks provided by the component.
yarn add @workday/canvas-kit-labs-react-color-picker
or
yarn add @workday/canvas-kit-labs-react-color-picker
import * as React from 'react';
import ColorPicker from '@workday/canvas-kit-labs-react-color-picker';
import {colors} from '@workday/canvas-kit-react-core';
import {Button} from '@workday/canvas-kit-react-button';
import {Popper, Popup} from '@workday/canvas-kit-react-popup';
const MyComponent: React.FunctionComponent = () => {
const [isOpen, setIsOpen] = React.useState(false);
const [color, setColor] = React.useState('');
const buttonRef = React.useRef(null);
const toggleOpen = () => setIsOpen(!isOpen);
const handleSubmit = React.useCallback(
(submitColor: string) => {
setColor(submitColor.toUpperCase());
setIsOpen(false);
},
[setIsOpen]
);
return (
<>
<Button buttonRef={buttonRef} variant={Button.Variant.Primary} onClick={toggleOpen}>
Toggle Color Picker
</Button>
<Popper placement={'bottom'} open={isOpen} anchorElement={buttonRef.current!}>
<Popup style={{marginTop: 8}} padding={PopupPadding.s}>
<ColorPicker
resetColor={colors.blueberry400}
resetLabel={'Reset'}
showCustomHexInput={true}
onColorChange={handleSubmit}
onColorReset={() => handleSubmit(colors.blueberry400)}
onSubmitClick={toggleOpen}
value={color}
/>
</Popup>
</Popper>
</>
);
};
None
onColorChange: (color: string) => void
This handler is called when the user selects a color through either a mouse or keyboard event. It is called with the hex value of the color selected by the user, or with a custom hex value entered by the user in the custom input.
onColorReset: Function
When this handler is provided, a Reset button will be displayed at the top of the picker using the
resetLabel
provided. This handler is called when the reset button is selected through either a mouse or keyboard event.
resetColor: string
The color to display as part of the Reset button. It is strongly recommended that consumers provide a properly globalized value.
Note: This prop is only necessary when the
onColorReset
handler is provided.
resetLabel: string
The text to display as part of the Reset button. It is strongly recommended that consumers provide a properly globalized value.
Note: This prop is only necessary when the
onColorReset
handler is provided.
Default: Reset
value: string
The hex value of the color to display styled in a selected state. If the value doesn't match one of the available colors, the hex value will be displayed in the custom input.
colorSet: string[]
The hex values of the colors to display in the color picker grid. If no custom colors are provided, a default set will be rendered.
showCustomHexInput: boolean
When
true
theColorInput
component and a submit button will be displayed at the bottom of the picker allowing the user to enter a custom hex value.
Default: false
customHexInputLabel: string
The text to display abover the custom input. It is strongly recommended that consumers provide a properly globalized value.
Note: This prop is only used when
showCustomHexInput
istrue
.
Default: Custom Hex Color
onSubmitClick: (event: React.FormEvent) => void
When this handler is provided, an action can be tied to clicking the check button provided. This handler is called when the check button is selected through a keyboard event only.
Note: This prop is only used when
showCustomHexInput
istrue
.
FAQs
Color Picker is a component for selecting a color.
The npm package @workday/canvas-kit-labs-react-color-picker receives a total of 1,720 weekly downloads. As such, @workday/canvas-kit-labs-react-color-picker popularity was classified as popular.
We found that @workday/canvas-kit-labs-react-color-picker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.