I'm working on making my website more accessible. One of the issues I'm encountering is text/background contrast. According to the spec, it's fine to place a high-contrast switch which enables a high-contrast mode. In order to satisfy this requirement, I'd like to place a button or switch on my site which, when activated, trips a function that scans the document for instances of background:low-contrast and replaces that attribute with background:high-contrast.
I've done the job with ng-class="{'high-contrast':highContrast}" and
<button
ng-controller="HighContrastController"
ng-click="$root.highContrast=!$root.highContrast"
class="high-contrast-switch">
<i class="fa text-white fa-adjust">
<span class="sr-only">High Contrast Mode</span>
</i>
</button>
with
function HighContrastController($rootScope) {
$rootScope.highContrast = false;
}
But I think I'd prefer to do this all in controller, which would enable me to apply high contrast globally, to all views, without cluttering my partials up with logic.
One way I could do it would be to forget the high-contrast class, and apply light and dark classes. highcontrast.css would apply high-contrast colours to those classes when loaded through the controller. Is there an angular way to do this or should I rely on regular javascript to load up highcontrast.css?