Coder Social home page Coder Social logo

jet-toggle's Introduction

A simple vanilla JS thingie for making toggle-able elements using JetEngine Listings.

This will be of use to almost nobody.

Three components: a button or clickable element, a corresponding content area, and a container that holds the whole thing.

Clicking a button will hide all content areas and show the related content area.

All of these elements will be scoped to a single section element.

All buttons are classed with jt-button and content areas with jt-content, as well as jt-button-[post id] and jt-content-[post id].

The containing listing grid element will have the jt-toggle-container class.

CSS

Rule to hide all elements by default and unhide the first in each section. This will govern behavior on page load.

  • jt-content -- hidden
  • jt-content-active -- visible

How to use this thing

Your layout will have two corresponding listing grids: buttons and content. Apply the .jt-toggle-container class to the section or column that houses them both.

In the button Listing, set the CSS classes to dynamic using the Post ID. Using the "before" area, assign:

jt-button jt-button-

Assuming your post ID is 123, the end result is that your button will have these classes:

jt-button .jt-button-123

Do exactly the same thing in your content Listing. Set CSS classes to dynamic with Post ID and the "before" field to:

jt-content jt-content-

Resulting in your content container having these classes:

jt-content jt-content-123

Cool thing

The event handling that controls the visibility of each content area will be limited to the section in question. Slick.

jet-toggle's People

Watchers

 avatar  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.