Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ describe("calcite-color-picker", () => {
propertyName: "clearable",
defaultValue: false,
},
{
propertyName: "fieldDisabled",
defaultValue: false,
},
{
propertyName: "format",
defaultValue: "auto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { scale } = ATTRIBUTES;

type ColorPickerStoryArgs = Pick<
ColorPicker,
"channelsDisabled" | "hexDisabled" | "savedDisabled" | "scale" | "clearable" | "value"
"channelsDisabled" | "hexDisabled" | "savedDisabled" | "fieldDisabled" | "scale" | "clearable" | "value"
>;

export default {
Expand All @@ -16,6 +16,7 @@ export default {
channelsDisabled: false,
hexDisabled: false,
savedDisabled: false,
fieldDisabled: false,
scale: scale.defaultValue,
clearable: false,
value: "#b33f33",
Expand All @@ -36,6 +37,7 @@ export const simple = (args: ColorPickerStoryArgs): string => html`
scale="${args.scale}"
${boolean("clearable", args.clearable)}
value="${args.value}"
${boolean("field-disabled", args.fieldDisabled)}
></calcite-color-picker>
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ export class ColorPicker extends LitElement implements InteractiveComponent {
/** When `true`, interaction is prevented and the component is displayed with lower opacity. */
@property({ reflect: true }) disabled = false;

/** When `true`, hides the color graph. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep terminology consistent and use color field here.

@property() fieldDisabled = false;
Comment thread
Amretasre002762670 marked this conversation as resolved.
Outdated

/**
* The format of `value`.
*
Expand Down Expand Up @@ -1469,6 +1472,7 @@ export class ColorPicker extends LitElement implements InteractiveComponent {
staticDimensions: {
thumb: { radius: thumbRadius },
},
fieldDisabled,
hexDisabled,
hueScopeLeft,
messages,
Expand Down Expand Up @@ -1506,28 +1510,30 @@ export class ColorPicker extends LitElement implements InteractiveComponent {
return (
<InteractiveContainer disabled={this.disabled}>
<div class={CSS.container}>
<div class={CSS.controlAndScope}>
<canvas
class={CSS.colorField}
onPointerDown={this.handleColorFieldPointerDown}
ref={this.initColorField}
/>
<div
ariaLabel={vertical ? messages.value : messages.saturation}
ariaValueMax={vertical ? HSV_LIMITS.v : HSV_LIMITS.s}
ariaValueMin="0"
ariaValueNow={(vertical ? color?.saturationv() : color?.value()) || "0"}
class={{ [CSS.scope]: true, [CSS.colorFieldScope]: true }}
onKeyDown={this.handleColorFieldScopeKeyDown}
ref={this.storeColorFieldScope}
role="slider"
style={{
top: `${adjustedColorFieldScopeTop || 0}px`,
left: `${adjustedColorFieldScopeLeft || 0}px`,
}}
tabIndex="0"
/>
</div>
{fieldDisabled ? null : (
<div class={CSS.controlAndScope}>
Comment thread
Amretasre002762670 marked this conversation as resolved.
<canvas
class={CSS.colorField}
onPointerDown={this.handleColorFieldPointerDown}
ref={this.initColorField}
/>
<div
ariaLabel={vertical ? messages.value : messages.saturation}
ariaValueMax={vertical ? HSV_LIMITS.v : HSV_LIMITS.s}
ariaValueMin="0"
ariaValueNow={(vertical ? color?.saturationv() : color?.value()) || "0"}
class={{ [CSS.scope]: true, [CSS.colorFieldScope]: true }}
onKeyDown={this.handleColorFieldScopeKeyDown}
ref={this.storeColorFieldScope}
role="slider"
style={{
top: `${adjustedColorFieldScopeTop || 0}px`,
left: `${adjustedColorFieldScopeLeft || 0}px`,
}}
tabIndex="0"
/>
</div>
)}
<div class={CSS.previewAndSliders}>
<calcite-color-picker-swatch
class={CSS.preview}
Expand Down