Skip to content

Commit

Permalink
#7007 Replace validate color with tiny color 2
Browse files Browse the repository at this point in the history
  • Loading branch information
prasanthlouis committed Dec 6, 2023
1 parent 9dc2fbd commit fe85658
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions dev-test/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ collections: # A list of collections the CMS should be able to edit
multiple: true,
}
- { label: 'Hidden', name: 'hidden', widget: 'hidden', default: 'hidden' }
- { label: 'Color', name: 'color', widget: 'color' }
- label: 'Object'
name: 'object'
widget: 'object'
Expand Down
2 changes: 1 addition & 1 deletion packages/decap-cms-widget-colorstring/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"react-color": "^2.18.1",
"validate-color": "^2.1.0"
"tinycolor2": "^1.4.1"
},
"peerDependencies": {
"@emotion/react": "^11.11.1",
Expand Down
8 changes: 5 additions & 3 deletions packages/decap-cms-widget-colorstring/src/ColorControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import ChromePicker from 'react-color';
import validateColor from 'validate-color';
import tinycolor from 'tinycolor2';
import { zIndex } from 'decap-cms-ui-default';

function ClearIcon() {
Expand Down Expand Up @@ -131,8 +131,10 @@ export default class ColorControl extends React.Component {
)}
<ColorSwatchBackground />
<ColorSwatch
background={validateColor(this.props.value) ? this.props.value : '#fff'}
color={validateColor(this.props.value) ? 'rgba(255, 255, 255, 0)' : 'rgb(223, 223, 227)'}
background={tinycolor(this.props.value).isValid() ? this.props.value : '#fff'}
color={
tinycolor(this.props.value).isValid() ? 'rgba(255, 255, 255, 0)' : 'rgb(223, 223, 227)'
}
onClick={this.handleClick}
>
?
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17389,11 +17389,6 @@ v8-to-istanbul@^8.1.0:
convert-source-map "^1.6.0"
source-map "^0.7.3"

validate-color@^2.1.0:
version "2.2.4"
resolved "https://registry.yarnpkg.com/validate-color/-/validate-color-2.2.4.tgz#77acf863458cd637ee944f604932512f6cbe6103"
integrity sha512-Znolz+b6CwW6eBXYld7MFM3O7funcdyRfjKC/X9hqYV/0VcC5LB/L45mff7m3dIn9wdGdNOAQ/fybNuD5P/HDw==

validate-npm-package-license@^3.0.1, validate-npm-package-license@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a"
Expand Down

0 comments on commit fe85658

Please sign in to comment.