ryersondmp / sa11y

Sa11y is an accessibility quality assurance tool that visually highlights common accessibility and usability issues. Geared towards content authors, Sa11y straightforwardly identifies errors or warnings at the source with a simple tooltip on how to fix them.
https://sa11y.netlify.app
Other
284 stars 44 forks source link

Enable settings by default #93

Closed MatzeKitt closed 3 months ago

MatzeKitt commented 3 months ago

First of all: thank you for providing Sa11y! ❤️

I was curious whether there is a way to enable some settings by default. E.g. I want to automatically enable the contrast setting to also check this without having to first enable it manually by going into the settings. Besides manually setting the corresponding value into the local storage, is there any method to allow this? I couldn’t find any, unfortunately.

So my current workaround is:

new Sa11y();
localStorage.setItem( 'sa11y-remember-contrast', 'On' );
adamchaboryk commented 3 months ago

You're welcome, @MatzeKitt!! Thanks for the kind words. 🤠

Yes, the best way to do this would be to use props. The closest prop for this would be checkAllHideToggles, which will effectively turn all the toggleable checks on by default and would also hide their corresponding toggle in the Settings panel.

const sa11y = new Sa11y({
    checkAllHideToggles: true,
});

Please give this a try and let me know if this works for you!

MatzeKitt commented 3 months ago

Ah, I missed that. Works fine, thanks! 🙂

adamchaboryk commented 3 months ago

I like your idea about turning on some of those toggleable settings on by default. I think I'm going to make Contrast & Form Labels on by default for next release. Thank you for your request/feedback!!

MatzeKitt commented 3 months ago

Maybe you can also add a setting so that everyone can set a default for themself:

new Sa11y({
    defaultSettings: {
        contrast: true,
        labels: true,
        'links-advanced': false,
        readability: false,
        theme: window.matchMedia('(prefers-color-scheme: dark)'.matches ? 'dark' : 'light'
    }
});