GithubHelp home page GithubHelp logo

informaticacba / webapp-menu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from angrycat9000/webapp-menu

1.0 0.0 0.0 403 KB

Tools for creating an accessible menu (for example: file, edit, toolbars) for web apps.

Home Page: https://webapp-menu.netlify.com/

License: MIT License

JavaScript 90.45% HTML 4.59% SCSS 4.96%

webapp-menu's Introduction

Published on webcomponents.org

webapp-menu

Quickly create accessible menus for in web apps. Eg. context menu, file menu, edit menu, toolbar. The library handles adding the appropriate aria- attributes and the keyboard and focus interaction.

No framework dependencies. It is written in with vanilla JS and can be used with any framework.

Screenshots & Demo

Live Demo

Toolbar

toolbar screenshot

Popup

context popup screenshot

Nested Menu

nested menu control screenshot

Setup

HTML

Include the Javascript in your HTML as a module import.

<script type="module"  src="https://unpkg.com/webapp-menu@^2/dist/webapp-menu.js"></script>

NPM

npm install --save webapp-menu

Include the file in your code:

import Menu from 'webapp-menu';

Usage

The menu components can be configured using either HTML or JavaScript.

See the storybook examples for more details.

Using HTML

<wam-popup controlledBy="some-button-id">
    <wam-item label="Text Only"></wam-item>
    <wam-item label="Text with Icon">
        <img slot="icon" src="hello.png"></span>
    </wam-item>
</wam-popup>

Using JavaScript

function iconFactory(icon) {
    const img = document.createElement('img');
    img.src = icon;
    return img;
}

const items = [
    {label:'Text Only'}
    {label:'Text with Icon', icon:'hello.png'},
];

const menu = document.createElement('wam-popup');
menu.iconFactory = iconFactory;
menu.items.set(items);
menu.controlledBy = document.getElementById('some-button-id');

webapp-menu's People

Contributors

angrycat9000 avatar mra11yx avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.