Skip to content

Commit 678529c

Browse files
fix(react-color picker) Thumb design (#33743)
Co-authored-by: Dmytro Kirpa <[email protected]>
1 parent 5a9a15f commit 678529c

8 files changed

+23
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "fix: thumb design for ColorPicker - partner's ask",
4+
"packageName": "@fluentui/react-color-picker-preview",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/react-components/react-color-picker-preview/library/src/components/AlphaSlider/AlphaSlider.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('AlphaSlider', () => {
3030
<div>
3131
<div
3232
class="fui-ColorSlider fui-AlphaSlider"
33-
style="--fui-AlphaSlider--direction: 90deg; --fui-AlphaSlider--progress: 100%; --fui-AlphaSlider__thumb--color: transparent; --fui-AlphaSlider__rail--color: hsl(0 100%, 50%);"
33+
style="--fui-AlphaSlider--direction: 90deg; --fui-AlphaSlider--progress: 100%; --fui-AlphaSlider__thumb--color: hsla(0 100%, 50%, 1); --fui-AlphaSlider__rail--color: hsl(0 100%, 50%);"
3434
>
3535
<input
3636
class="fui-ColorSlider__input fui-AlphaSlider__input"

packages/react-components/react-color-picker-preview/library/src/components/AlphaSlider/useAlphaSliderState.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const useAlphaSliderState_unstable = (state: AlphaSliderState, props: Alp
4444
const rootVariables = {
4545
[alphaSliderCSSVars.sliderDirectionVar]: sliderDirection,
4646
[alphaSliderCSSVars.sliderProgressVar]: `${valuePercent}%`,
47-
[alphaSliderCSSVars.thumbColorVar]: `transparent`,
47+
[alphaSliderCSSVars.thumbColorVar]: `hsla(${hslColor.h} ${hslColor.s * 100}%, ${hslColor.l * 100}%, ${hslColor.a})`,
4848
[alphaSliderCSSVars.railColorVar]: `hsl(${hslColor.h} ${hslColor.s * 100}%, ${hslColor.l * 100}%)`,
4949
};
5050

packages/react-components/react-color-picker-preview/library/src/components/AlphaSlider/useAlphaSliderStyles.styles.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ const useStyles = makeStyles({
4242
*/
4343
const useThumbStyles = makeStyles({
4444
thumb: {
45-
backgroundColor: `var(${alphaSliderCSSVars.thumbColorVar})`,
45+
backgroundColor: tokens.colorNeutralBackground1,
4646
[`${thumbPositionVar}`]: `clamp(var(${innerThumbRadiusVar}), var(${alphaSliderCSSVars.sliderProgressVar}), calc(100% - var(${innerThumbRadiusVar})))`,
47+
'::before': {
48+
backgroundColor: `var(${alphaSliderCSSVars.thumbColorVar})`,
49+
},
4750
},
4851
horizontal: {
4952
transform: 'translateX(-50%)',

packages/react-components/react-color-picker-preview/library/src/components/ColorArea/ColorArea.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('ColorArea', () => {
1515
<div>
1616
<div
1717
class="fui-ColorArea"
18-
style="--fui-AreaX--progress: 100%; --fui-AreaY--progress: 50%; --fui-Area__thumb--color: transparent; --fui-Area--main-color: hsl(324, 100%, 50%);"
18+
style="--fui-AreaX--progress: 100%; --fui-AreaY--progress: 50%; --fui-Area__thumb--color: rgb(128, 0, 76); --fui-Area--main-color: hsl(324, 100%, 50%);"
1919
>
2020
<div
2121
class="fui-ColorArea__thumb"

packages/react-components/react-color-picker-preview/library/src/components/ColorArea/useColorArea.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from 'react';
2+
import { tinycolor } from '@ctrl/tinycolor';
23
import { useId, slot, useMergedRefs, mergeCallbacks, getIntrinsicElementProps } from '@fluentui/react-utilities';
34
import type { ColorAreaProps, ColorAreaState } from './ColorArea.types';
45
import type { HsvColor } from '../../types/color';
@@ -153,7 +154,7 @@ export const useColorArea_unstable = (props: ColorAreaProps, ref: React.Ref<HTML
153154
const rootVariables = {
154155
[colorAreaCSSVars.areaXProgressVar]: `${saturation}%`,
155156
[colorAreaCSSVars.areaYProgressVar]: `${value}%`,
156-
[colorAreaCSSVars.thumbColorVar]: 'transparent',
157+
[colorAreaCSSVars.thumbColorVar]: tinycolor(hsvColor).toRgbString(),
157158
[colorAreaCSSVars.mainColorVar]: `hsl(${hsvColor.h}, 100%, 50%)`,
158159
};
159160
const state: ColorAreaState = {

packages/react-components/react-color-picker-preview/library/src/components/ColorArea/useColorAreaStyles.styles.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ const useThumbStyles = makeStyles({
5454
outlineStyle: 'none',
5555
forcedColorAdjust: 'none',
5656
borderRadius: tokens.borderRadiusCircular,
57-
boxShadow: `0 0 0 calc(var(${thumbSizeVar}) * .18) ${tokens.colorNeutralBackground1} inset`,
57+
border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralForeground4}`,
58+
boxShadow: tokens.shadow4,
5859
backgroundColor: `var(${colorAreaCSSVars.thumbColorVar})`,
5960
transform: 'translate(-50%, 50%)',
6061
[`${thumbPositionXVar}`]: `clamp(var(${innerThumbRadiusVar}), var(${colorAreaCSSVars.areaXProgressVar}), calc(100% - var(${innerThumbRadiusVar})))`,
@@ -67,7 +68,7 @@ const useThumbStyles = makeStyles({
6768
borderRadius: tokens.borderRadiusCircular,
6869
boxSizing: 'border-box',
6970
content: "''",
70-
border: `calc(var(${thumbSizeVar}) * .05) solid ${tokens.colorNeutralStroke1Pressed}`,
71+
border: `${tokens.strokeWidthThick} solid ${tokens.colorNeutralBackground1}`,
7172
},
7273
},
7374
focusIndicator: createFocusOutlineStyle({

packages/react-components/react-color-picker-preview/library/src/components/ColorSlider/useColorSliderStyles.styles.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,17 @@ const useThumbStyles = makeStyles({
129129
outlineStyle: 'none',
130130
forcedColorAdjust: 'none',
131131
borderRadius: tokens.borderRadiusCircular,
132-
boxShadow: `0 0 0 calc(var(${thumbSizeVar}) * .18) ${tokens.colorNeutralBackground1} inset`,
132+
border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralForeground4}`,
133+
boxShadow: tokens.shadow4,
133134
backgroundColor: `var(${colorSliderCSSVars.thumbColorVar})`,
134135
[`${thumbPositionVar}`]: `clamp(var(${innerThumbRadiusVar}), var(${colorSliderCSSVars.sliderProgressVar}), calc(100% - var(${innerThumbRadiusVar})))`,
135136
'::before': {
136137
position: 'absolute',
137-
top: '0px',
138-
left: '0px',
139-
bottom: '0px',
140-
right: '0px',
138+
inset: '0px',
141139
borderRadius: tokens.borderRadiusCircular,
142140
boxSizing: 'border-box',
143141
content: "''",
144-
border: `calc(var(${thumbSizeVar}) * .05) solid ${tokens.colorNeutralStroke1Pressed}`,
142+
border: `${tokens.strokeWidthThick} solid ${tokens.colorNeutralBackground1}`,
145143
},
146144
},
147145
horizontal: {

0 commit comments

Comments
 (0)