A library that helps you write a static dropdown menu that follows the digital accessibility recommendations.

Overview

JSPanel

A library that helps you write a static dropdown menu, a panel, that follows the digital accessibility recommendations.

Get started

First of all, get the source code in the src folder of this repository. You need to copy the javascript file & the css file:

<link rel="stylesheet" src="src/panel-style.css">
<script src="src/JSPanel.js">

Note: the source code is available in TypeScript & JavaScript.

Create your own panel

According to the digital accessibility recommendations, the panel needs to be opened by a button. Here is an example of what your code should be:

<html>
<head>
  <style>
    #container {
      position: fixed;
      bottom: 30px;
      right: 30px;
    }
  </style>
</head>
<body>

  <div id="container">
    <button id="panel-controller">
  </div>

  <script src="src/JSPanel.js"></script>
  <script>
    const button = document.querySelector("#panel-controller");
    const panel = new JSPanel(button, {
      bottom: 0 + button.getBoundingClientRect().height,
      right: 0,
      items: [
        { title: "My Profile", onclick: () => console.log("et voilà") }
      ],
    });
  </script>
</body>
</html>

Note: the aria- attributes are added dynamically.

A panel has 5 different options:

name type default value description
top number null The top CSS property.
right number null The right CSS property.
bottom number null The bottom CSS property.
left number null The left CSS property.
items Array of items required The items to be displayed in the panel.

By default, the panel is placed in the upper left corner (top:0,left:0).

The items have also specific options:

name type default value description
title string (required) The title of the item.
id positive number from 0, incrementing The id of the item. Used to recognize items via some methods like removeItem() etc.
icon string null The path to an image.
fontawesome_icon string null The className of a Fontawesome icon.
fontawesome_color string null The color of the Fontawesome icon.
className string null Additional classes to be added to the item, separated by a white space.
attributes [string, string][] null Additional attributes to be added to the item. Exemple: [["data-thing", "thing"], ...[]]
onclick () => void null The callback function when the user clicks on the item.
separator boolean false Displays a line. This item cannot have any other options.

In order to use fontawesome_icon and fontawesome_color, make sure you've installed Fontawesome in your project.

Make the panel dynamic

Use the following methods to modify the content of the panel after its creation:

  • toggleItem(id:number, disable=false): set disable to true if you want to disable the items. Set disable to false if you just want the item to disappear (display:none). Select the item with its ID (by default the first item has an ID of 0, then 1 etc.).

  • removeItem(id:number): removes an item.

  • removeItems(ids:number[]): removes several items.

  • getAllIDS(): gets the id of each item.

  • getItem(id:number): gets an item according to its ID.

  • addItem(item): adds a new item.

  • replaceItemWith(item, id:number): selects an item with its ID and replaces it by the new one.

  • deletePanel(): deletes the panel.

Customize the panel

You can change the style of the panel by modifying the CSS file. There are the main variables defined at the beginning of the file:

:root {
    --panel-background-color: #fff;
    --panel-box-shadow: 0 0 4px rgba(204, 204, 204, 0.75);
    --panel-width: 160px;
    --panel-text-color: #404040;
    --panel-hover-item-background-color: #f4f6fa;
    --panel-hover-item-color: #385074;
    --panel-icon-width: 13px;
    --panel-separator-color: #dfe3eb;
}

For further modifications, you'll need to modify the CSS properties. Be careful not to modify the file too much at the risk of compromising the proper functioning of the panel.

Digital Accessibility

Following the digital accessibility recommendations for this kind of panels, it is necessary to open or close the panel by clicking either the Enter or Space key. See https://www.accede-web.com/en/guidelines/rich-interface-components/show-hide-panels/ for more information.

License

MIT License

You might also like...

Follows Instagram @iamfadlyid_

Follows Instagram @iamfadlyid_

Requirements • Installation • Fature Test • Bug Report • Features • Thanks to Requirements Node.js Git FFmpeg (for sticker command) Libwebp (for stick

Sep 10, 2022

Easy view and filter all follows and following. Auto update by GitHub Action.

Easy view and filter all follows and following. Auto update by GitHub Action.

😳 List All Followers And Following Easy view and filter all follows and following. Auto update by GitHub Action. Since GitHub's default follows and f

Dec 28, 2022

375 DSA Tracker helps you build your confidence in solving any coding related question and helps you prepare for your placements. It is your personal web-based progress tracker based on 375 DSA Sheet by Aman Dhattarwal & Shradha Didi

375 DSA Tracker helps you build your confidence in solving any coding related question and helps you prepare for your placements. It is your personal web-based progress tracker based on 375 DSA Sheet by Aman Dhattarwal & Shradha Didi

375-DSA Tracker 👨‍💻 Me and my friend Abhilash Jena made a 375 DSA Tracker website based on 375 DSA Sheet by Aman Dhattarwal & Shradha Didi which hel

Nov 11, 2022

Gofiber with NextJS Static HTML is a small Go program to showcase for bundling a static HTML export of a Next.js app

Gofiber and NextJS Static HTML Gofiber with NextJS Static HTML is a small Go program to showcase for bundling a static HTML export of a Next.js app. R

Jan 22, 2022

Lexical is an extensible JavaScript web text-editor framework with an emphasis on reliability, accessibility and performance

Lexical is an extensible JavaScript web text-editor framework with an emphasis on reliability, accessibility and performance. Lexical aims to provide a best-in-class developer experience, so you can easily prototype and build features with confidence.

Dec 30, 2022

Functions and objects that make it easier to add fields to Portable Text editors for accessibility meta information, like language changes or abbreviations.

Porta11y Porta11y is a collection of accessibility-focused annotations, decorators and validators for Sanity’s Portable Text editor. Portable Text is

Aug 25, 2022

Proofie is an experimental proof-reader for VSCode that helps you write better.

Proofie is an experimental proof-reader for VSCode that helps you write better.

Proofie Proofie is an experimental proof-reader for VSCode that helps you write better. Install You can install proofie from the VSCode Marketplace. O

Jul 25, 2022

shell script replacement; write shell scripts in js instead of bash, then run them with a single static binary

yavascript YavaScript is a bash-like script runner which is distributed as a single statically-linked binary. Scripts are written in JavaScript. There

Dec 29, 2022

Learn GraphQL by building a blogging engine. Create resolvers, write schemas, write queries, design the database, test and also deploy.

GraphQL Blog graphqlblog.com Learn GraphQL by building a blogging engine. Create resolvers, write schemas, write queries, design the database, test an

Aug 17, 2022
Releases(v1.2.1)
Owner
CodoPixel
I code for fun and improvement.
CodoPixel
VanillaSelectBox - A dropdown menu with lots of features that takes a select tag and transforms it into a single or multi-select menu with 1 or 2 levels

vanillaSelectBox v1.0.0 vanillaSelectBox : v1.00 : Adding a package.json file New : Possibility to change the dropdown tree and change the remote sear

philippe MEYER 103 Dec 16, 2022
Pure JavaScript (VanillaJS) dropdown menu, with multiple select and searching support

JS Select Pure JavaScript (VanillaJS) dropdown menu, with multiple select and searching support How to use To use the select plugins, two main file mu

Luigi Verolla 4 Mar 17, 2022
Responsive Dropdown Menu Bar

Responsive Dropdown Menu Watch it on youtube Responsive Dropdown Menu Beautiful and clean responsive navigation bar includes a beautiful drop-down sid

Marlon 44 Oct 21, 2022
Obsidian-dataview-table-filter-menu - Dynamically created filter menu for dataview tables in obsidian

Dataview table Filter Menu for Obsidian Dynamically created filter menu for data

shiro 17 Sep 24, 2022
A little animation for a big menu where the letters of a word shuffle to become the first letter of each menu item.

Letter Shuffle Animation for a Menu A little animation for a big menu where the letters of a word shuffle to become the first letter of each menu item

Codrops 29 Dec 4, 2022
This restaurant project is a SPA (single-page application) website. The user can navigate between the home, menu and contact page. I used the MealDB API to display some menu items.

Fresh Cuisine This restaurant project is from the Odin Project and it is a SPA (single-page application) website. The user can navigate between the ho

Virag Kormoczy 7 Nov 2, 2022
jSide Menu is a well designed, simple and clean side navigation menu with dropdowns.

jQuery jSide Menu jSide Menu is a well designed, simple and clean side navigation menu with dropdowns. Browse: Live Demo & Using Guide Main Features F

CodeHim 24 Feb 14, 2022
Digital Identifier is a secure, decentralized, anonymous and tampered proof way of maintaining and verifying all essential identity-based documents to create a unique digital identity of a person.

Digital Identifier ?? To design and develop a secure, decentralized, anonymous and tampered proof way of maintaining and verifying all essential ident

Mukul Kolpe 4 Dec 17, 2022
Get AI newsletter recommendations tailored to developers and startups using ChatGPT prompt.

ChatGPT Newsletter AI newsletter via ChatGPT prompt for developers and startups. Technical Details Building your own custom ChatGPT involves four step

GPTea 33 Jul 31, 2023
Reference for How to Write an Open Source JavaScript Library - https://egghead.io/series/how-to-write-an-open-source-javascript-library

Reference for How to Write an Open Source JavaScript Library The purpose of this document is to serve as a reference for: How to Write an Open Source

Sarbbottam Bandyopadhyay 175 Dec 24, 2022