Giter VIP home page Giter VIP logo

sidebars's Introduction

Responsive sidebars

This project is somewhat of a research experiment into the most convenient way of implementing responsive sidebars.

Priorities

  • Simple design, easy to understand.
  • Responsive design:
    • In landscape mode the sidebars should push the main content aside.
    • In portrait mode they should cover the main content.
  • The sidebar trigger should not move when clicked; this is annoying to the user.
  • The sidebar should be 'ready' when it slides into view, and not rearrange its content while opening.
    (This is visually distracting, but a very common implementation;
    e.g. variable-width sidebars with width: 0 when closed)

Design

The code is deliberately kept minimal to not distract from the sidebar mechanics.
The main version uses flexbox, but there are other branches exploring CSS grid and absolute positioning.

3 flex items are used for their adaptive features: the sidebars #left and #right, and the main content #main.
This allows pushing the main content aside when the landscape sidebars open (by transitioning the #left and #right widths). However, since we want the sidebars to be fixed-width, so they do not rearrange their content while opening, the actual sidebars are not these variable-width flex items, but child divs with fixed widths.

As a result, the sidebars make use of 2 separate transitions:

  • One to push the main content aside when the sidebars open in landscape mode,
    by transitioning the #left and #right flex items' width from 0 to the sidebar width.
  • Another to slide the (portrait and landscape) fixed-width sidebar child divs in and out of view,
    by transitioning their transform: translateX(-100%) property.

Implementations

For a more mature implementation, see gatsby-theme-simpwa and its starter gatsby-starter-simpwa.
You can see them both deployed here.

sidebars's People

Contributors

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