accessibility.js 604 B

123456789101112131415161718192021222324252627282930313233
  1. const protanopia = {
  2. negative: '#fb8c00',
  3. positive: '#2196f3',
  4. primary: '#1976D2',
  5. secondary: '#2196f3'
  6. }
  7. const deuteranopia = {
  8. negative: '#ef6c00',
  9. positive: '#2196f3',
  10. primary: '#1976D2',
  11. secondary: '#2196f3'
  12. }
  13. const tritanopia = {
  14. primary: '#e91e63',
  15. secondary: '#02C39A'
  16. }
  17. export function getAccessibleColor (name, base, cvd) {
  18. switch (cvd) {
  19. case 'protanopia': {
  20. return protanopia[name] ?? base
  21. }
  22. case 'deuteranopia': {
  23. return deuteranopia[name] ?? base
  24. }
  25. case 'tritanopia': {
  26. return tritanopia[name] ?? base
  27. }
  28. }
  29. return base
  30. }