caksoylar / keymap-drawer

Visualize keymaps that use advanced features like hold-taps and combos, with automatic parsing
https://caksoylar.github.io/keymap-drawer
MIT License
660 stars 57 forks source link

Feature request: Display multiple keys that could activate a layer #98

Closed calummm closed 3 months ago

calummm commented 4 months ago

Currently there appears to be a way to show each layer with the corresponding key or multiple keys required to press to activate that layer but no way to show an OR situation. I am experimenting with having multiple ways to activate a layer, in this case either thumb can activate each layer.

Perhaps we could show this with different colors or textures so as not to confuse.

Currently:

image

Possible solution:

image

caksoylar commented 4 months ago

Hi, this is possible via the mark_alternate_layer_activators setting: https://github.com/caksoylar/keymap-drawer/blob/main/CONFIGURATION.md#mark_alternate_layer_activators

It's an interesting idea to denote them with a different color, since that'd resolve the ambiguity of the AND vs. OR situation. I suspect it might not be clear on first glance what the different color means, but I'll think about it.

(PS: You might want to check out the new-ish dark_mode setting!)

calummm commented 4 months ago

Yes, I can see how it is confusing with two of the same color as I do use that for a special layer activation. Is there an exposed style selector I might be able to override? Perhaps nth child?

Thank you for the tip about dark mode.

caksoylar commented 4 months ago

You can always go by key position + layer, like .layer-DEF .keypos-33 > rect { fill: blue; } for 34th key on layer DEF. (I think it should be possible to select nth child with class .held as well but my CSS skills seem lacking for that.)

I'll try to add a tweak to parsing to add a special type like "held alternate" so you can override it in the CSS (and it will still default to held styling otherwise). We can consider whether we adjust the default style for it later.

caksoylar commented 4 months ago

I added this in 1b99a076ef43d87e7ebb1929cd133e6daf8a06d9, can you give it a try? You can use it with a new CSS override like

draw_config:
  svg_extra_style: "rect.held.alternate { fill: purple; }"
calummm commented 4 months ago

I was hoping I would be able to trigger this via workflow but cannot seem to. Tried using:

jobs:
  draw:
    uses: caksoylar/keymap-drawer/.github/workflows/draw-zmk.yml@1b99a076ef43d87e7ebb1929cd133e6daf8a06d9

Will setup keymap-drawer locally later and try your change

caksoylar commented 4 months ago

Instead of that, try using this:

jobs:
  draw:
    uses: caksoylar/keymap-drawer/.github/workflows/draw-zmk.yml@main
    with:
      install_branch: main  # install git version from main branch, not pypi
calummm commented 4 months ago

Finally got it working with

jobs:
  draw:
    uses: caksoylar/keymap-drawer/.github/workflows/draw-zmk.yml@1b99a076ef43d87e7ebb1929cd133e6daf8a06d9
    with:
      install_branch: 1b99a076ef43d87e7ebb1929cd133e6daf8a06d9 

Looks like it works well, tyvm. I'm not sure if we would need to account for light/dark mode? Probably I need to write a better selector. This is with fill: #478583

image

caksoylar commented 4 months ago

Thanks for confirming.

Finally got it working with

I'd have expected my example to work, it's weird if it didn't.

You can override the dark mode CSS separately like this if you like:

draw_config:
  svg_extra_style: |
    rect.held.alternate { fill: #478583; }
    @media (prefers-color-scheme: dark) { rect.held.alternate { fill: #478583; } }  # some other color here
calummm commented 3 months ago

Thank you for implementing so quickly. I think this should serve most people well.