Skip to content

Commit

Permalink
feat(palette): implement YIQ for color switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
stuf committed Oct 1, 2019
1 parent a39ba25 commit 2c58e2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/components/Palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as React from 'karet';
import * as U from 'karet.util';
import * as R from 'ramda';

import * as H from '../shared';

import style from './Palette.module.scss';

function Palette({ items, currentColor }) {
Expand All @@ -15,9 +17,11 @@ function Palette({ items, currentColor }) {
return (
<li key={`color-${i}`} className={U.when(isActive, style.active)}>
<button
style={{ backgroundColor: it }}
style={{ backgroundColor: it, color: H.yiqFor(it) }}
onClick={U.doSet(currentColor, i)}
/>
>
{it}
</button>
</li>
);
}),
Expand Down
5 changes: 3 additions & 2 deletions src/components/Palette.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
padding: 0;
display: grid;
grid-gap: 2px;
grid-auto-rows: 20px;
grid-auto-rows: 1.5rem;

button {
display: block;
width: 100%;
height: 100%;
border: 0;
font-size: 10px;
}
}

.active {
border: solid 2px #f00;
border: solid 2px #fff;
}

0 comments on commit 2c58e2a

Please sign in to comment.