Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WRR-14756: Publish ColorPicker component #1803

Open
wants to merge 37 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
81061b4
WRQ-30515: Created component skeleton (#1650)
ion-andrusciac-lgp Aug 1, 2024
8699710
WRQ-30516: [POC] Added Grid Color Picker (#1651)
daniel-stoian-lgp Aug 1, 2024
4b68b69
WRQ-30515: Created component skeleton (#1653)
ion-andrusciac-lgp Aug 6, 2024
55b9ac7
WRQ-30516: Optimized styling for grid color picker (#1654)
daniel-stoian-lgp Aug 6, 2024
d3343aa
WRQ-30517: Slider type panel for the WebOS ColorPicker. (#1655)
alexandrumorariu Aug 6, 2024
183ca1d
WRQ-30519: [POC] webOS ColorPicker - spectrum color picker (#1656)
adrian-cocoara-lgp Aug 6, 2024
719bbf7
WRQ-30519: Added accelerator to spectrum color picker (#1659)
paul-beldean-lgp Aug 9, 2024
ed05176
WRQ-30515: Added handler to display colors state in actions log when …
ion-andrusciac-lgp Aug 9, 2024
716f51b
fixed spectrum canvas size (#1662)
paul-beldean-lgp Aug 9, 2024
834dd8f
WRQ-30517: Create a slider type for webOS ColorPicker (part2) (#1661)
alexandrumorariu Aug 9, 2024
a221536
WRQ-32413: [POC] webOS ColorPicker - add responsiveness (#1668)
adrian-cocoara-lgp Aug 16, 2024
900440a
WRQ-32412: WebOS ColorPicker fixes and improvements (#1672)
alexandrumorariu Aug 22, 2024
2abd154
WRQ-32437: Fixed deletion of favorite colors for ColorPicker (#1676)
daniel-stoian-lgp Aug 26, 2024
a72c437
Merge branch 'develop' into feature/ColorPickerPOC
hong6316 Aug 27, 2024
8806de2
WRR-1870: Adjust Slider ColorPicker based on feedback (#1684)
alexandrumorariu Sep 12, 2024
674d9b5
Merge branch 'develop' of github.com:enactjs/sandstone into feature/C…
adrian-cocoara-lgp Sep 25, 2024
8d7037c
Merge branch 'develop' of https://github.com/enactjs/sandstone into f…
stanca-pop-lgp Nov 25, 2024
339cf30
Merge branch 'develop' of https://github.com/enactjs/sandstone into f…
daniel-stoian-lgp Dec 6, 2024
fc5223f
Merge branch 'develop' of https://github.com/enactjs/sandstone into f…
stanca-pop-lgp Dec 9, 2024
5e4e369
WRR-12000: Enhanced ColorPicker code and made component public (#1759)
stanca-pop-lgp Dec 9, 2024
32471d1
Merge branch 'develop' of github.com:enactjs/sandstone into feature/C…
adrian-cocoara-lgp Dec 12, 2024
90d34d8
Merge branch 'develop' of github.com:enactjs/sandstone into feature/C…
adrian-cocoara-lgp Dec 17, 2024
136e4f0
Merge remote-tracking branch 'origin/develop' into feature/ColorPicke…
daniel-stoian-lgp Dec 17, 2024
61249a4
WRR-12002: ColorPicker - add unit/ui/ss tests (#1778)
adrian-cocoara-lgp Dec 19, 2024
9eaddfe
merge with develop and fix merging conflicts
adrian-cocoara-lgp Jan 8, 2025
25b1721
Merge remote-tracking branch 'origin/feature/ColorPickerPOC' into fea…
adrian-cocoara-lgp Jan 8, 2025
b063e42
fix colorpicker's layout
adrian-cocoara-lgp Jan 9, 2025
74682f7
fixed slider know background-color on focus
stanca-pop-lgp Jan 13, 2025
4d63ec9
Merge branch 'develop' of github.com:enactjs/sandstone into feature/C…
adrian-cocoara-lgp Jan 16, 2025
b2f9904
Merge branch 'feature/ColorPickerPOC' of github.com:enactjs/sandstone…
adrian-cocoara-lgp Jan 16, 2025
a48d876
WRR-14756: Refactor ColorPicker to use `TabGroup` instead of `TabLayo…
adrian-cocoara-lgp Jan 17, 2025
423826c
deleted unnecessary else block
adrian-cocoara-lgp Jan 17, 2025
955a586
Merge branch 'develop' of github.com:enactjs/sandstone into feature/C…
adrian-cocoara-lgp Jan 17, 2025
5c52781
fix isomorphic tests
adrian-cocoara-lgp Jan 17, 2025
517d66e
fix isomorphic slice and fix layout
adrian-cocoara-lgp Jan 17, 2025
b86d69c
fix isomorphic part 2
adrian-cocoara-lgp Jan 17, 2025
34cf660
removed JSDoc example
adrian-cocoara-lgp Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
608 changes: 330 additions & 278 deletions ColorPicker/ColorPicker.js

Large diffs are not rendered by default.

119 changes: 50 additions & 69 deletions ColorPicker/ColorPicker.module.less
Original file line number Diff line number Diff line change
@@ -1,93 +1,74 @@
// ColorPicker.module.less
//
@import '../styles/colors.less';
@import '../styles/mixins.less';
@import '../styles/variables.less';

.colorPicker {
align-items: center;
justify-content: space-between;

.colorsRow {
width: 522px;
padding-top: 9px;
}
@import "../styles/mixins.less";
@import "../styles/variables.less";

@keyframes shakeColor {
0% { transform: translateX(0) }
25% { transform: translateX(3px) }
50% { transform: translateX(-3px) }
75% { transform: translateX(3px) }
100% { transform: translateX(0) }
}

.coloredButton {
border-radius: 72px;
border: 3px solid #ffffff;
height: 120px;
margin-left: 0;
min-width: 120px;
padding: 0;
transform: none;
.pickerTabGroup {
min-width: @sand-colorpicker-tabgroup-width;
padding-bottom: @sand-colorpicker-padding;
}

.focus({
transform: scale(1.1);
});
.colorPicker {
display: flex;
height: @sand-colorpicker-height;
justify-content: center;
padding: @sand-colorpicker-padding;
}

.disabled({
opacity: @sand-disabled-opacity;
})
}
.favoriteColorsRow {
text-align: center;

.coloredDiv,
.coloredInput {
border-radius: 24px;
}
.favoriteColor {
border-radius: 50%;
border: @sand-colorpicker-border-medium solid;
transition: transform .2s;

.coloredDiv {
display: block;
height: 81px;
border: 3px solid #ffffff;

&.button, &.focusExpand {
margin: 24px;
.deleteButton {
position: absolute;
z-index: -2;
}

.focus({
box-shadow: 0 0 12px 3px inset;
transform: scale(1.1);
});
}

.coloredInput {
opacity: 0;

&:hover {
cursor: pointer;
}
.shakeFavoriteColor {
animation: shakeColor 0.2s;
animation-iteration-count: infinite;
}
}

.colorPopup {
height: max-content;
.selectedColorContainer {
justify-content: center;
margin-top: @sand-colorpicker-selectedcolor-margin;

.colorPopupHeader {
font-size: 66px;
text-transform: capitalize;
margin: 0 0 0 15px;
}

.closeButton {
&.button, &.focusExpand {
margin: 0;
}
.selectedColor {
border-radius: @sand-colorpicker-selectedcolor-border-radius;
border: @sand-colorpicker-border-medium solid;
height: @sand-colorpicker-selectedcolor-height;
margin-inline: 0;
transition: transform .2s;

.icon {
font-size: 48px;
.selectedColorIcon {
transition: transform .2s;
}
}

.colorPickerSliders {
padding: 45px 0;

.colorSlider {
margin: 0 27px;
}
.focus({
box-shadow: 0 0 12px 6px inset;

.colorSliderText {
font-size: 54px;
margin: 0 24px;
}
.selectedColorIcon {
transform: scale(1.2);
}
});
}
}
116 changes: 116 additions & 0 deletions ColorPicker/ColorPickerGrid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/**
* Sandstone component to allow the user to choose a color from a grid.
*
* @example
* <ColorPickerGrid
* selectedColor="#FF00FF"
* selectedColorHandler={setSelectedColor}
* />
*
* @exports ColorPickerGrid
* @exports ColorPickerGridBase
* @private
*/
import Spottable from '@enact/spotlight/Spottable';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import {useCallback} from 'react';

import Skinnable from '../Skinnable';

import {generateOppositeColor, rgbStringToHex} from './utils';

import componentCss from './ColorPickerGrid.module.less';

const SpottableDiv = Spottable('div');

const colors = [
['#ffffff', '#00374a', '#004d65', '#016e8f', '#008cb4', '#00a1d8', '#01c7fc', '#52d6fc', '#93e3fd', '#cbf0ff'],
['#ebebeb', '#011d57', '#012f7b', '#0042a9', '#0056d6', '#0061fe', '#3a87fe', '#74a7ff', '#a7c6ff', '#d3e2ff'],
['#d6d6d6', '#11053b', '#1a0a52', '#2c0977', '#371a94', '#4d22b2', '#5e30eb', '#864ffe', '#b18cfe', '#d9c9fe'],
['#c2c2c2', '#2e063d', '#450d59', '#61187c', '#7a219e', '#982abc', '#be38f3', '#d357fe', '#e292fe', '#efcaff'],
['#adadad', '#3c071b', '#551029', '#791a3d', '#99244f', '#b92d5d', '#e63b7a', '#ee719e', '#f4a4c0', '#f9d3e0'],
['#999999', '#5c0701', '#831100', '#b51a00', '#e22400', '#ff4015', '#ff6250', '#ff8c82', '#ffb5af', '#ffdbd8'],
['#858585', '#5a1c00', '#7b2900', '#ad3e00', '#da5100', '#ff6a00', '#ff8648', '#ffa57d', '#ffc5ab', '#ffe2d6'],
['#707070', '#583300', '#7a4a00', '#a96800', '#d38301', '#ffab01', '#feb43f', '#ffc777', '#ffd9a8', '#ffecd4'],
['#5c5c5c', '#563d00', '#785800', '#a67b01', '#d19d01', '#fdc700', '#fecb3e', '#ffd977', '#fee4a8', '#fff2d5'],
['#474747', '#666100', '#8d8602', '#c4bc00', '#f5ec00', '#fefb41', '#fff76b', '#fff994', '#fffbb9', '#fefcdd'],
['#333333', '#4f5504', '#6f760a', '#9ba50e', '#c3d117', '#d9ec37', '#e4ef65', '#eaf28f', '#f2f7b7', '#f7fadb'],
['#000000', '#263e0f', '#38571a', '#4e7a27', '#669d34', '#76bb40', '#96d35f', '#b1dd8b', '#cde8b5', '#dfeed4']
];

/**
* The color picker base component which sets-up the component's structure.
*
* This component is most often not used directly but may be composed within another component as it
* is within {@link sandstone/ColorPickerGrid|ColorPickerGrid}.
*
* @class ColorPickerGridBase
* @memberof sandstone/ColorPicker
* @ui
* @private
*/
const ColorPickerGridBase = (props) => {
const {className, disabled, selectedColorHandler, ...rest} = props;

const handleClick = useCallback((e) => {
if (disabled) return;
selectedColorHandler(rgbStringToHex(e.target.style.backgroundColor));
}, [disabled, selectedColorHandler]);

return (
<div className={classnames(componentCss.colorPicker, className)} {...rest} >
{
colors.map((row, rowIndex) => {
return (
<div key={rowIndex}>
{
colors[rowIndex].map((color, colorIndex) => {
return <SpottableDiv className={componentCss.colorBlock} spotlightDisabled={disabled} onClick={handleClick} style={{backgroundColor: color, '--sand-colorpicker-grid-focus-border-color': generateOppositeColor(color)}} key={colorIndex} />;
})
}
</div>
);
})
}
</div>
);
};

ColorPickerGridBase.displayName = 'ColorPickerGridBase';

ColorPickerGridBase.propTypes = {/** @lends sandstone/ColorPicker.ColorPickerGridBase.prototype */
/**
* Applies a disabled style and prevents interacting with the component.
*
* @type {Boolean}
* @default false
* @private
*/
disabled: PropTypes.bool,

/**
* A function to run when the current color changes.
*
* @type {Function}
* @private
*/
selectedColorHandler: PropTypes.func
};

/**
* A color picker component, ready to use in Sandstone applications.
*
* @class ColorPickerGrid
* @memberof sandstone/ColorPicker
* @extends sandstone/ColorPicker.ColorPickerGridBase
* @ui
* @private
*/
const ColorPickerGrid = Skinnable(ColorPickerGridBase);

export default ColorPickerGrid;
export {
ColorPickerGrid,
ColorPickerGridBase
};
20 changes: 20 additions & 0 deletions ColorPicker/ColorPickerGrid.module.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ColorPickerGrid.module.less
//
@import "../styles/colors.less";
@import "../styles/mixins.less";
@import "../styles/variables.less";

.colorPicker {
display: flex;

.colorBlock {
border: @sand-colorpicker-border-large solid @sand-colorpicker-colorblock-border-color;
height: @sand-colorpicker-grid-colorblock-size;
width: @sand-colorpicker-grid-colorblock-size;

.focus({
border-color: var(--sand-colorpicker-grid-focus-border-color);
box-shadow: 0 0 12px 3px inset;
})
}
}
Loading
Loading