ebpa / tui.el

An experimental text-based UI framework for Emacs modeled after React - **requires emacs 26.1 or newer**
GNU General Public License v3.0
183 stars 6 forks source link

Random button dashboard #3

Closed nickdrozd closed 1 year ago

nickdrozd commented 5 years ago
(tui-define-component tui-random
  :get-initial-state
  (lambda ()
    `(:current-number ,(random 100)))
  :render
  (lambda ()
    (tui-let (&state current-number)
      (tui-div
       (tui-line
        "Random number: "
        current-number)
       (tui-link
        :target
        (lambda ()
          (tui--set-state
           component
           `(:current-number ,(number-to-string (random 100)))))
        "Regenerate")))))
ebpa commented 5 years ago

See the current dev branch.

Useful for testing:

(tui-render-with-buffer "*random-button-test*"
  (tui-random))

Use tui-button for the button styling you were aiming for. Want to create a PR into dev to add that demo?