diff --git a/ui/components/color-picker/base/_index.scss b/ui/components/color-picker/base/_index.scss index 075dbe4e69..7e05f4abe3 100644 --- a/ui/components/color-picker/base/_index.scss +++ b/ui/components/color-picker/base/_index.scss @@ -16,6 +16,12 @@ */ .slds-color-picker { position: relative; + + .slds-form-error { + padding-top: $spacing-x-small; + color: $color-text-error; + font-size: 0.75rem; + } } /** @@ -56,8 +62,12 @@ * @selector .slds-color-picker__summary-input * @restrict .slds-color-picker__summary > input */ -.slds-input.slds-color-picker__summary-input { - width: $size-xx-small; +.slds-color-picker__summary-input { + display: inline-block; + + .slds-input { + width: $size-xx-small; + } } /** @@ -77,13 +87,13 @@ background: $color-background; } - .slds-tabs--default__item { + .slds-tabs_default__item { text-transform: uppercase; letter-spacing: 0.05rem; } - .slds-tabs--default__content { - padding: $spacing-x-small 0; + .slds-tabs_default__content { + padding: $spacing-x-small 0 $spacing-xx-small; } } diff --git a/ui/components/color-picker/base/example.jsx b/ui/components/color-picker/base/example.jsx index ec4010a46a..505e7a7bac 100644 --- a/ui/components/color-picker/base/example.jsx +++ b/ui/components/color-picker/base/example.jsx @@ -9,6 +9,11 @@ export default ( ); export const states = [ + { + id: 'summary-error', + label: 'Summary Error', + element: + }, { id: 'color-picker-open', label: 'Open, default tab selected', @@ -17,6 +22,11 @@ export const states = [ { id: 'custom-tab-selected', label: 'Open, custom tab selected', - element: + element: + }, + { + id: 'custom-tab-selected-error', + label: 'Open, custom tab selected, error state', + element: } ]; diff --git a/ui/components/color-picker/custom-only/example.jsx b/ui/components/color-picker/custom-only/example.jsx index c9382da30e..38510e7c00 100644 --- a/ui/components/color-picker/custom-only/example.jsx +++ b/ui/components/color-picker/custom-only/example.jsx @@ -13,5 +13,10 @@ export const states = [ id: 'custom-color-picker-open', label: 'Open', element: + }, + { + id: 'custom-color-picker-open-error', + label: 'Open with Error', + element: } ]; diff --git a/ui/components/color-picker/index.jsx b/ui/components/color-picker/index.jsx index 221b49a0ad..7ce915d66c 100644 --- a/ui/components/color-picker/index.jsx +++ b/ui/components/color-picker/index.jsx @@ -44,6 +44,8 @@ const swatchColors = [ '#b85d0d' ]; +const errorMessage = 'Please ensure value is correct'; + /** * Swatch Subcomponent */ @@ -60,33 +62,49 @@ const Swatch = (props) => { /** * Summary Subcomponent */ -export const ColorPickerSummary = () => ( -
- - - - - -
-); +export const ColorPickerSummary = (props) => { + const { hasSummaryError } = props; + const errorId = 'color-picker-summary-error'; + + return ( +
+ + + + + + + + + {hasSummaryError ? ( +

+ {errorMessage} +

+ ) : null} +
+ ) +}; /** * Swatches (list of Swatch elements) Subcomponent @@ -112,12 +130,14 @@ export const ColorPickerSwatches = (props) => { /** * Custom Picker Subcomponent */ -const ColorPickerCustom = () => { +const ColorPickerCustom = (props) => { const rangeInputId = _.uniqueId('color-picker-input-range-'); const hexInputId = _.uniqueId('color-picker-input-hex-'); const rInputId = _.uniqueId('color-picker-input-r-'); const gInputId = _.uniqueId('color-picker-input-g-'); const bInputId = _.uniqueId('color-picker-input-b-'); + const { hasCustomError } = props; + const customErrorId = 'color-picker-custom-error'; return (
@@ -144,10 +164,16 @@ const ColorPickerCustom = () => {
- + R} inputId={rInputId}> @@ -162,6 +188,12 @@ const ColorPickerCustom = () => {
+ + { hasCustomError ? ( +

+ {errorMessage} +

+ ) : null }
); } @@ -171,8 +203,8 @@ const ColorPickerCustom = () => { */ const ColorPickerFooter = () => (
- - + +
); @@ -186,7 +218,7 @@ const ColorPickerTabs = (props) => ( - + ); @@ -198,6 +230,11 @@ class ColorPicker extends React.Component { this.state = { selectedTabIndex: props.selectedTabIndex || 0 }; + + this.isFullFeatureMode = this.isFullFeatureMode.bind(this) + this.isPredefinedMode = this.isPredefinedMode.bind(this) + this.isCustomOnlyMode = this.isCustomOnlyMode.bind(this) + this.isSwatchesOnlyMode = this.isSwatchesOnlyMode.bind(this) } isFullFeatureMode() { @@ -222,21 +259,27 @@ class ColorPicker extends React.Component { render () { const { selectedTabIndex } = this.state; - const { isOpen } = this.props; + const { isOpen, hasSummaryError, hasCustomError } = this.props; const popoverState = isOpen ? 'slds-show' : 'slds-hide'; - const colorPickerSummary = this.isSwatchesOnlyMode() ? null : ; + const colorPickerSummary = this.isSwatchesOnlyMode() ? null : ( + + ); const footerContent = this.isSwatchesOnlyMode() ? null : ; - let colorPickerContent = null; if (this.isFullFeatureMode()) { - colorPickerContent = + colorPickerContent = ( + + ) } else if (this.isPredefinedMode()) { colorPickerContent = } else if (this.isCustomOnlyMode()) { - colorPickerContent = + colorPickerContent = } else if (this.isSwatchesOnlyMode()) { colorPickerContent =