Update Appearance.tsx

This commit is contained in:
Ryan Alexander 2021-08-16 04:14:10 +10:00 committed by GitHub
parent a17487606f
commit 07061c4af1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -372,7 +372,7 @@ export function Component(props: Props) {
}
/>
</div>
<span>{x}</span>
<span style={`color: ${getContrastingColour(theme[x])}`}>{x}</span>
<div className={styles.override}>
<div
className={styles.picker}
@ -445,3 +445,12 @@ export const Appearance = connectState(Component, (state) => {
settings: state.settings,
};
});
function getContrastingColour(hex: string){
hex = hex.replace("#", "");
const r = parseInt(hex.substr(0,2),16);
const g = parseInt(hex.substr(2,2),16);
const b = parseInt(hex.substr(4,2),16);
const cc = ((r*299)+(g*587)+(b*114))/1000;
return (cc >= 128) ? 'black' : 'white';
}