Skip to content
Draft
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
Prev Previous commit
Next Next commit
Add utility functions
  • Loading branch information
camdecoster committed Aug 19, 2025
commit d6d1e9e025aa8283c895ddb2ec810becbb7250b0
11 changes: 9 additions & 2 deletions src/components/color/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,26 @@ const cleanOne = val => {
return 'rgb(' + rgbStr + ')';
}

const isDark = cstr => color(cstr).isDark()
const equals = (cstr1, cstr2) => cstr1 && cstr2 && color(cstr1).rgb().string() === color(cstr2).rgb().string();

const isValid = cstr => {
try { return !!color(cstr); }
catch { return false; }
}

module.exports = {
addOpacity,
background,
clean,
color,
combine,
contrast,
defaultLine,
defaults,
equals,
fill,
interpolate,
isDark,
isValid,
lightLine,
opacity,
rgb,
Expand Down