Skip to content

Commit d6d1e9e

Browse files
committed
Add utility functions
1 parent c17371a commit d6d1e9e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/components/color/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,26 @@ const cleanOne = val => {
167167
return 'rgb(' + rgbStr + ')';
168168
}
169169

170-
const isDark = cstr => color(cstr).isDark()
170+
const equals = (cstr1, cstr2) => cstr1 && cstr2 && color(cstr1).rgb().string() === color(cstr2).rgb().string();
171+
172+
const isValid = cstr => {
173+
try { return !!color(cstr); }
174+
catch { return false; }
175+
}
171176

172177
module.exports = {
173178
addOpacity,
174179
background,
175180
clean,
181+
color,
176182
combine,
177183
contrast,
178184
defaultLine,
179185
defaults,
186+
equals,
180187
fill,
181188
interpolate,
182-
isDark,
189+
isValid,
183190
lightLine,
184191
opacity,
185192
rgb,

0 commit comments

Comments
 (0)