marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
8k stars 284 forks source link

feat: add keyboard shortcut to buttons #2819

Closed Light2Dark closed 2 weeks ago

Light2Dark commented 2 weeks ago

📝 Summary

Screenshot 2024-11-08 at 10 44 00 PM

Fixes #633 . Buttons can now have shortcuts by declaring them mo.ui.button(label='Add', value=0, on_click=lambda x: x + 1, keyboard_shortcut="Cmd-L")

🔍 Description of Changes

📋 Checklist

📜 Reviewers

@akshayka OR @mscolnick

vercel[bot] commented 2 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 9, 2024 9:02am
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 9, 2024 9:02am
Light2Dark commented 2 weeks ago

thx for the comments. One more thing, the keyboard shortcuts should be universal right? Right now it only caters to certain combos.

We will need a function similar to https://github.com/adriangalilea/streamlit-shortcuts/blob/b2978ba52abd6e3e49089090aa53cb00a0f0dd60/src/streamlit_shortcuts/streamlit_shortcuts.py#L22

Maybe I can make another MR to add that func first b4 this one.

mscolnick commented 2 weeks ago

@Light2Dark yea I think universal makes sense as a default and can get more feedback.

mscolnick commented 2 weeks ago

For the normalize shortcuts, feel free to include that in this PR. We may also want to normalize the separator + and -, or validate.

Maybe worth some tests

Light2Dark commented 2 weeks ago

I think it's ready @mscolnick , do you know why the dagger pipeline is failing? All the tests seem to pass 🤔

github-actions[bot] commented 2 weeks ago

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.9.18-dev2