ranbuch / accessibility

add accessibility to your website
MIT License
287 stars 35 forks source link

replacing the icons #67

Open brianteeman opened 3 months ago

brianteeman commented 3 months ago

Unfortunately it is not as simple as replacing the content attribute with the CSS variables currently being used as the built-in css also manipulates the icons eg

https://github.com/ranbuch/accessibility/blob/6077514135979f53018e696e8e27e51b0b5305c3/src/main.ts#L652-L657

ranbuch commented 3 months ago

@brianteeman Version 5.0.4 will support more CSS variables in order to adjust the icons better. Trust me, you don't want to write your own CSS. Even if you'll manage to do so your code might break in future releases.

Keep me posted.

brianteeman commented 3 weeks ago

Switching from material icons to my own icon set lets me see various other places where content variables are needed. I will try to list them all here

  text: "".concat(!this.options.icon.useEmojis ? 'close' : 'X')
  text: "".concat(!this.options.icon.useEmojis ? 'refresh' : '♲')
  content: ${!this._acc.options.icon.useEmojis ? '"mic"' : '"🎤"'}

and finally 'class': this._acc.options.icon.useEmojis ? '' : 'material-icons',
which I guess really should be using the variable fontClass

brianteeman commented 3 weeks ago

i am guessing that similar changes are also required for the main icon as that is also hardcoded for either material or emoji

ranbuch commented 2 weeks ago

@brianteeman Please try version 5.1.4 and let me know.

brianteeman commented 2 weeks ago

unless I am missing something this doesnt work. With this PR the code generated is <button class="_menu-close-btn _menu-btn iconfont" title="Hotkey: ctrl+alt+a" tabindex="0">close</button>

the problem is that while material will replace the close with an icon fotnaweseome and others will not as they rely on a class

ranbuch commented 2 weeks ago

@brianteeman The readme file has this example (I should add it to the site as well):

const options = {
    icon: {
        fontFaceSrc: ['https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/v4-font-face.min.css'],
        fontFamily: '"FontAwesome"',
        img: '[optional - URL for an image that will replace the menu icon]',
        closeIcon: '[optional - replacement text for the close menu icon]',
        resetIcon: '[optional - replacement text for the reset all icon]'
    }
};
new Accessibility(options);

closeIcon and resetIcon has been added according to your previous comments.

brianteeman commented 2 weeks ago

Yes I saw that but closeIcon/resetIcon does not work with fontawesome. did you try it?

ranbuch commented 2 weeks ago

I see now that it's only working for Emoji mode. Please try version 5.1.5.

brianteeman commented 2 weeks ago

that doesnt work either - did you test it yourself? the problem is the same as I already said

the problem is that while material will replace the close with an icon fontaweseome and others will not as they rely on a class

ranbuch commented 2 weeks ago

Please try version 6.0.1 and see updated documentation. It's a bit more complicated because we need to change the HTML itself sometimes, not just CSS variables.

brianteeman commented 2 weeks ago

thanks - will test later today and report back but at a quick glance it does appear to be on the right path