Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dwightbcoder/action-ui

Package Overview
Dependencies
Maintainers
0
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dwightbcoder/action-ui

Action UI is a Javascript framework to simplify connecting actions to user interface elements

  • 1.3.45
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Action UI

Action UI is a ES6 Javascript framework for building event-base user interfaces

The goal of this package is to make decoupled event-driven API-powered websites and applications simpler to produce with minimal learning curve.

Please review the documentation via the Wiki

Quickly convert post-back forms to Fetch posts

By default actions attached to HTML elements (via a ui-action attribute) will be configured automatically allowing Action UI to take control of form submission simply be setting an action name to the <form>:

<script src="https://cdn.jsdelivr.net/npm/@dwightbcoder/action-ui"></script>

<form ui-action="save post" action="/post/store" method="POST">
    <label for="title">Title:</label><br>
    <input type="text" name="title" placeholder="Post title"><br>
    <br>
    <label for="body">Body:</label><br>
    <textarea name="body"></textarea><br>
    <br>
    <button type="submit">Save Post</button>
</form>

Whenever an action is triggered any element triggers will receive state CSS classes of loading, success, or fail.

For example disable form elements and show an overlay when it is submitted using CSS:

<style>
    form.loading
    {
        position: relative;
        pointer-events: none;
    }

    form.loading::after
    {
        content: "Saving...";
        top: 0; left: 0;
        width: 100%; height: 100%;
        background-color: rgba(255,255,255,.75);
        position: absolute; display: flex;
        align-items: center; justify-content: center;
    }
</style>

You can listen for action.after events for things like informing the user of success or failure:

document.addEventListener('action.after', e => {
    if ( e.detail.name == 'save post' )
    {
        alert( e.detail.success ? 'Success!' : 'Failed!' )
    }
})

Build an MVC SPA

Setup a simple index.html:

<!DOCTYPE html>
<html>
    <head>
        <script src="https://cdn.jsdelivr.net/npm/@dwightbcoder/action-ui"></script>
    </head>
    <body>
        <header>Header</header>
        <main ui-view="controller"></main>
        <footer>Footer</footer>
        <script>
            ActionUI.Router.start()
        </script>
    </body>
</html>

Create your views:

view/
    error.html
    default/
        index.html

You now have a simple SPA that will load view content from your external view html files and respond to to page navigation include reload, back, and forward.

Keywords

FAQs

Package last updated on 22 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc