react-color#GithubPicker JavaScript Examples
The following examples show how to use
react-color#GithubPicker.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js From whaticket with MIT License | 5 votes |
ColorPicker = ({ onChange, currentColor, handleClose, open }) => {
const [selectedColor, setSelectedColor] = useState(currentColor);
const colors = [
"#B80000",
"#DB3E00",
"#FCCB00",
"#008B02",
"#006B76",
"#1273DE",
"#004DCF",
"#5300EB",
"#EB9694",
"#FAD0C3",
"#FEF3BD",
"#C1E1C5",
"#BEDADC",
"#C4DEF6",
"#BED3F3",
"#D4C4FB",
"#4D4D4D",
"#999999",
"#FFFFFF",
"#F44E3B",
"#FE9200",
"#FCDC00",
"#DBDF00",
"#A4DD00",
"#68CCCA",
"#73D8FF",
"#AEA1FF",
"#FDA1FF",
"#333333",
"#808080",
"#cccccc",
"#D33115",
"#E27300",
"#FCC400",
"#B0BC00",
"#68BC00",
"#16A5A5",
"#009CE0",
"#7B64FF",
"#FA28FF",
"#666666",
"#B3B3B3",
"#9F0500",
"#C45100",
"#FB9E00",
"#808900",
"#194D33",
"#0C797D",
"#0062B1",
"#653294",
"#AB149E",
];
const handleChange = (color) => {
setSelectedColor(color.hex);
handleClose();
};
return (
<Dialog
onClose={handleClose}
aria-labelledby="simple-dialog-title"
open={open}
maxWidth="xs"
paperFullWidth
>
<GithubPicker
width={"100%"}
triangle="hide"
color={selectedColor}
colors={colors}
onChange={handleChange}
onChangeComplete={(color) => onChange(color.hex)}
/>
</Dialog>
);
}
Example #2
Source File: App.js From place with MIT License | 5 votes |
render() {
const content = !this.state.connected ? (
<div>Connecting... <span className="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span></div>
) : (this.state.signedIn ? (
<div>
<div className="float-right">
<button
className="btn btn-outline-secondary"
onClick={() => this.logOut()}>Log out</button>
</div>
<h4>Hello, <span className="font-weight-bold">{this.state.accountId}</span>!</h4>
<div>
PIXEL tokens: {this.state.balance.toFixed(6)}
</div>
<div>
Your pixels: {this.state.numPixels}
</div>
<div className="color-picker">
<HuePicker color={ this.state.pickerColor } width="100%" disableAlpha={true} onChange={(c) => this.hueColorChange(c)}/>
<GithubPicker className="circle-picker" colors={this.state.gammaColors} color={ this.state.pickerColor } triangle='hide' width="100%" onChangeComplete={(c) => this.changeColor(c)}/>
<GithubPicker className="circle-picker" colors={this.state.colors} color={ this.state.pickerColor } triangle='hide' width="100%" onChangeComplete={(c) => this.hueColorChange(c)}/>
</div>
</div>
) : (
<div style={{marginBottom: "10px"}}>
<button
className="btn btn-primary"
onClick={() => this.requestSignIn()}>Log in with NEAR Wallet</button>
</div>
));
return (
<div className="px-5">
<h1>NEAR Place</h1>
{content}
<div>
<canvas ref={this.canvasRef}
width={800}
height={800}
className={this.state.boardLoaded ? "pixel-board" : "pixel-board c-animated-background"}>
</canvas>
</div>
</div>
);
}
Example #3
Source File: CustomColor.jsx From razer-macos with GNU General Public License v2.0 | 4 votes |
export default function CustomColor({ deviceSelected }) {
const componentToHex = (c) => {
if (typeof c === 'undefined') {
return '00';
}
var hex = c.toString(16);
return hex.length == 1 ? '0' + hex : hex;
};
const rgbToHex = ({ r, g, b }) => {
return '#' + componentToHex(r) + componentToHex(g) + componentToHex(b);
};
const [currentColor, setCurrentColor] = useState({
hex: rgbToHex(deviceSelected.settings.customColor1.rgb),
rgb: deviceSelected.settings.customColor1.rgb,
});
const handleChange = (newColor) => {
setCurrentColor(newColor);
};
const handleClick = () => {
deviceSelected.settings.customColor1 = currentColor;
let payload = {
device: deviceSelected,
};
ipcRenderer.send('request-set-custom-color', payload);
};
const styles = { 'default': { picker: { background: '#202124', boxShadow: 'none'}, body: {
padding: '12px 0 0'
} }};
const stylesGithub = { 'default': { card: { background: '#000'}, triangle: {borderBottomColor: '#000'}}};
const hasAllColors = (staticFeature) => {
return staticFeature.configuration.enabledRed
&& staticFeature.configuration.enabledGreen
&& staticFeature.configuration.enabledBlue;
}
const staticFeature = deviceSelected.features.find(feature => feature.featureIdentifier === FeatureIdentifier.STATIC);
const allColors = hasAllColors(staticFeature);
let colors = [];
if(!allColors) {
const allNoneValues = [0];
const allColorValues = [0,25,50,75,100,125,150,175,200,225,255];
const allReds = staticFeature.configuration.enabledRed ? allColorValues : allNoneValues;
const allGreens = staticFeature.configuration.enabledGreen ? allColorValues : allNoneValues;
const allBlues = staticFeature.configuration.enabledBlue ? allColorValues : allNoneValues;
allReds.forEach(r => {
allGreens.forEach(g => {
allBlues.forEach(b => {
const hex = rgbToHex({r, g, b});
const value = parseInt(hex.replace('#', '0x'));
colors.push({ value, hex })
})
})
});
colors.sort((a,b) => {
return a.value - b.value;
});
colors = colors.map(color => color.hex);
}
return (
<div>
<div className='control'>
{allColors && (
<ChromePicker color={currentColor} onChange={handleChange} width='100%' disableAlpha={true} styles={styles} defaultView={'rgb'}/>
)}
{!allColors && (
<GithubPicker color={currentColor} onChange={handleChange} width='auto' colors={colors} styles={stylesGithub}/>
)}
</div>
<div className='control'>
<button onClick={handleClick}>Save custom color</button>
</div>
</div>
);
}
Example #4
Source File: CardModal.js From TrelloClone with MIT License | 4 votes |
CardModal = ({ cardId, open, setOpen, card, list }) => {
const classes = useStyles();
const [title, setTitle] = useState(card.title);
const [description, setDescription] = useState(card.description);
const dispatch = useDispatch();
useEffect(() => {
setTitle(card.title);
setDescription(card.description);
}, [card]);
const onTitleDescriptionSubmit = async (e) => {
e.preventDefault();
dispatch(editCard(cardId, { title, description }));
};
const onArchiveCard = async () => {
dispatch(archiveCard(cardId, true));
setOpen(false);
};
return (
<Modal open={open} onClose={() => setOpen(false)}>
<div className={`${classes.paper} ${classes.cardModal}`}>
<form onSubmit={(e) => onTitleDescriptionSubmit(e)}>
<div className={classes.modalTop}>
<TextField
variant='outlined'
margin='normal'
required
fullWidth
multiline
label='Card title'
value={title}
onChange={(e) => setTitle(e.target.value)}
onKeyPress={(e) => e.key === 'Enter' && onTitleDescriptionSubmit(e)}
className={classes.cardTitle}
/>
<Button onClick={() => setOpen(false)}>
<CloseIcon />
</Button>
</div>
<TextField
variant='outlined'
margin='normal'
fullWidth
multiline
label='Card description'
value={description}
onChange={(e) => setDescription(e.target.value)}
/>
<Button
type='submit'
variant='contained'
color='primary'
disabled={
title === card.title &&
(description === card.description ||
(description === '' && !card.description))
}
className={classes.button}
>
Save All Changes
</Button>
</form>
<div className={classes.modalSection}>
<CardMembers card={card} />
<div>
<h3 className={classes.labelTitle}>Label</h3>
<GithubPicker
className={classes.colorPicker}
onChange={async (color) => dispatch(editCard(cardId, { label: color.hex }))}
/>
<Button
className={classes.noLabel}
variant='outlined'
onClick={async () => dispatch(editCard(cardId, { label: 'none' }))}
>
No Label
</Button>
</div>
</div>
<Checklist card={card} />
<div className={classes.modalSection}>
<MoveCard cardId={cardId} setOpen={setOpen} thisList={list} />
<div className={classes.modalBottomRight}>
<Button
variant='contained'
className={classes.archiveButton}
onClick={onArchiveCard}
>
Archive Card
</Button>
<DeleteCard cardId={cardId} setOpen={setOpen} list={list} />
</div>
</div>
</div>
</Modal>
);
}