• Stars
    star
    220
  • Rank 180,422 (Top 4 %)
  • Language Vue
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An ultra simple pure vue horizontal layout for modern responsive web with zero dependencies. (SPA/SSG/SSR)

chrome firefox edge SSR SSG License MIT FOSSA Status

Vue Horizontal vue-horizontal vue-horizontal

Designing your web app for a horizontal experience can tedious and overwhelming if you are new to web development. While a vertical design comes naturally as html is naturally vertical by design display:block. With display:flex, aligning your content horizontally becomes natural and intuitive but it doesn't support overflow or navigation. You start to add more hacks and tricks to get the design you wanted, but those hacks are not consistent and cross-browser tested, SSG or SEO friendly. You get the idea.

There are many libraries already in open-source world, some using direct DOM manipulation, some importing another legacy JavaScript or JQuery library. You don't want that. Vue already does that. This is Vue native created for Vue, and only Vue is the peer dependency required. All modes of rendering (SPA/SSR/SSG) are supported and tested with E2E tools.

The actual library is only about 400 LOC while there are at least 100x more LOC in the documentation, end-to-end testing and a bunch of other fun stuff.

DEMO β€’ DOCUMENTATION β€’ FEATURES

Vue Horizontal recipes

Features and Design Philosophy

  • SSR/SSG/SPA: all modes of rendering supported
  • Mobile first for the responsive web
  • Customizable navigation: scroll bar, buttons or basically everything
  • UX focused, smooth scrolling, snapping for variety of use case.
  • Small size of 3 KB for CDN users
  • Highly extensible for any use case with well documented recipes.
    • You control how to structure your content with HTML
    • You control how it looks with CSS
    • You control how to navigate your layout with Vue.js

Installation

# for Vue 2
npm i vue-horizontal
# for Vue 3
# migration notes: https://github.com/fuxingloh/vue-horizontal/pull/87
npm i vue-horizontal@next 
# or
yarn add vue-horizontal
# or via <script>
https://cdn.jsdelivr.net/npm/[email protected]/dist/vue-horizontal.esm.min.js

Usage

Import Locally
<script>
import VueHorizontal from "vue-horizontal";

export default {
  components: {VueHorizontal}
}
</script>
Import Globally
import Vue from 'vue';
import VueHorizontal from "vue-horizontal";

Vue.component(VueHorizontal)
Import Script
<!-- For latest release: https://github.com/fuxingloh/vue-horizontal/releases -->
<script src="https://unpkg.com/[email protected]"></script>

Using Vue Horizontal

<template>
  <vue-horizontal responsive>
    <section v-for="item in items" :key="item.title">
      <h3>{{ item.title }}</h3>
      <p>{{ item.content }}</p>
    </section>
  </vue-horizontal>
</template>

<script>
import VueHorizontal from "vue-horizontal";

export default {
  components: {VueHorizontal},
  data() {
    return {
      // E.g: creates 20 array items...
      items: [...Array(20).keys()].map((i) => {
        return {title: `Item ${i}`, content: `πŸš€ Content ${i}`};
      }),
    }
  }
}
</script>

<style scoped>
section {
  padding: 16px 24px;
  background: #f5f5f5;
}
</style>

More features and examples

Known Limitations

CSS Scroll Behavior: Smooth

In Vue Horizontal, smooth scrolling is enabled by default. With scroll-behavior: smooth, it enables smooth scrolling experience when scroll event is triggered by programmatic calls. Although this is not a breaking functional feature, it provides a "smooth" scrolling user experience.

As of December 2020, there is only a 76% cross browser compatibility (88% if you include Safari experimental feature flag). Meantime you should polyfill this feature with more information provided here. Polyfill should be done by the user, there are no plans to incorporate this natively in the library.

CSS Scroll Snap

Scroll snap align or scroll-snapping, is a CSS technique that allows customizable scrolling experiences like pagination of carousels by setting defined snap positions. Vue Horizontal has it enabled by default, to disable you can set <vue-horizontal snap="none">.

As of December 2020, there is a 94%+ cross browser compatibility. You can choose to polyfill this, but it's more of an aesthetic feature rather than a breaking functional requirement.

Development

Setup, develop & test.

npm install # install
npm run serve # dev
npm run cypress:run # e2e testing
  • End-to-end test cases are also written because of the UI nature of this framework. Cypress is used under the hood.
  • There are also additional integration testing done to ensure SSR and SSG works.

Contributions

  • For any question or feature request please feel free to create an issue or pull request.
  • For feature request, do check out the examples as some of them might have been implemented.

Prior art

Originally, this project started out as another project called vue-horizontal-list. I created the origin project because I liked how AirBnb does their horizontal layout. I couldn't find a library that implements it vue natively without relying on a legacy js/jquery dependency.

This project is another take on it with an ultra simple implementation that is extensible and moves the responsibility to the user rather than the library.

License

FOSSA Status

More Repositories

1

vue-masonry-wall

A pure vue responsive masonry layout without direct dom manipulation and ssr support.
Vue
210
star
2

vue-horizontal-list

A pure vue native horizontal list implementation for mobile/touch and responsive web.
Vue
179
star
3

contented

Contented is a Markdown-based authoring workflow & processor that encourage developer authoring within its contextual Git repository.
TypeScript
52
star
4

multi-labeler

Multi labeler for title, body, comments, commit messages, branch, author or files with automated status checks.
TypeScript
32
star
5

airtable

A lightweight Java 8 Airtable API client for https://airtable.com/api with all features implemented.
Java
19
star
6

nuxt-app

Nuxt app template project with my customisation.
Vue
18
star
7

oracles.dfc.fuxing.dev

Open-source web app that is developed by the community of developers and researchers to understand the oracle network built on DeFiChain Native network.
TypeScript
3
star
8

Internal-External-Storage-Synchronization

Internal storage: sqlite, External storage: cloud like azure, with this library you can sync data. with internet or not
Java
3
star
9

terraform-aws-vpc-peering

Terraform AWS peering module to peer all VPC together forming a mesh network.
HCL
2
star
10

aws-es-proxy

aws-es-proxy is a small web server application sitting between your HTTP client (browser, curl, etc...) and Amazon Elasticsearch service.
2
star
11

hibernate-validator-enum

So, null & unknown value handling for enum has always been an issue for me, saw the implementation on Amazon Java SDK packages and created @ValidEnum constraints to support using Hibernate Validator library.
Java
2
star
12

crypto-frontmatter

A collection of frontmatter for crypto projects.
TypeScript
2
star
13

solana-container

TypeScript
2
star
14

turbo-plan

Plan turbo run tasks in a separate action to run them parallel in a matrix job.
2
star
15

hibernate-utils

Hibernate utils for JPA entity manager, run transaction in lambda.
Java
1
star
16

dfi-rawtx-bitcoinjs

Creating a RawTx using generic bitcoinjs libraries
TypeScript
1
star
17

defi-txn-composer

Vue
1
star
18

oss-governance-example

1
star
19

dusd.dfc.fuxing.dev

TypeScript
1
star
20

turbo-repo-filter-dependencies-bug

1
star
21

jellyfishsdk-docs

@birthdayresearch/contented example
1
star
22

hibernate-postgres-jsonb

Using Hibernate with Postgres JSONB
Java
1
star
23

css-horizontal-collapse-demo

Chrome Fixed It. - This used to be "A demo of how CSS horizontal collapse can cause oddities in components rendered in the horizontal space."
Vue
1
star
24

background-image.fuxing.dev

A micro-site about background image for the web and how to do them properly.
Vue
1
star
25

oxtu

OXTU (UTXO in reverse) is a space-efficient UTXO set for Bitcoin (and bitcoin-like) blockchains.
Rust
1
star
26

karfia

Karfia is an open-source framework to define, test, deploy, and scale blockchain nodes on container-orchestration platforms.
TypeScript
1
star
27

hardhat-container

TypeScript
1
star