All Projects → bartkozal → Vue Fraction Grid

bartkozal / Vue Fraction Grid

Licence: mit
Flexbox based responsive fraction grid system

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Fraction Grid

gymnast
🤸 Configurable grid and layout engine for React
Stars: ✭ 35 (-60.23%)
Mutual labels:  grid, flexbox
React Native Responsive Grid
Bringing the Web's Responsive Design to React Native
Stars: ✭ 369 (+319.32%)
Mutual labels:  grid, flexbox
gutter-grid
A Sass flexbox based grid system that is able to replicate CSS grid-gap in IE11
Stars: ✭ 18 (-79.55%)
Mutual labels:  grid, flexbox
workshop-css-grid
Workshop made for freecodecamp meetup
Stars: ✭ 12 (-86.36%)
Mutual labels:  grid, flexbox
Feather Flex
Ultralight flexbox based grid system.
Stars: ✭ 11 (-87.5%)
Mutual labels:  grid, flexbox
Katana
Katana is CSS Layout System made with Flexbox
Stars: ✭ 57 (-35.23%)
Mutual labels:  grid, flexbox
Pintsize
Customisable 💪 Flexbox grid system
Stars: ✭ 330 (+275%)
Mutual labels:  grid, flexbox
fortune
🔮Fortune is your friendly CSS properties framework.
Stars: ✭ 16 (-81.82%)
Mutual labels:  grid, flexbox
React Flex Ready
A Flexbox grid ready, easy to implement and customize
Stars: ✭ 23 (-73.86%)
Mutual labels:  grid, flexbox
Flex Layout
Provides HTML UI layout for Angular applications; using Flexbox and a Responsive API
Stars: ✭ 5,705 (+6382.95%)
Mutual labels:  grid, flexbox
vue-grid
A powerful flexbox grid system for Vue.js 2.x, built with inline-styles
Stars: ✭ 23 (-73.86%)
Mutual labels:  grid, flexbox
Lemon
🍋 Minimal and responsive CSS framework for fast building websites.
Stars: ✭ 51 (-42.05%)
Mutual labels:  grid, flexbox
ReactSimpleFlexGrid
A way to quickly add a Grid Layout to your React app 🚀
Stars: ✭ 185 (+110.23%)
Mutual labels:  grid, flexbox
gridy
A Flexbox Grid System powered by SASS
Stars: ✭ 28 (-68.18%)
Mutual labels:  grid, flexbox
grd-sass
Sass port of 1000ch/grd that is a CSS grid framework using Flexbox.
Stars: ✭ 12 (-86.36%)
Mutual labels:  grid, flexbox
React Flexview
A powerful React component to abstract over flexbox and create any layout on any browser
Stars: ✭ 276 (+213.64%)
Mutual labels:  grid, flexbox
tetris-grid
◼️Lightweight and simple CSS grid
Stars: ✭ 16 (-81.82%)
Mutual labels:  grid, flexbox
hagrid
📏 Hagrid is a mixin library for responsive websites and web applications.
Stars: ✭ 30 (-65.91%)
Mutual labels:  grid, flexbox
React Styled Flexboxgrid
Grid system based on styled-components and flexbox for React
Stars: ✭ 515 (+485.23%)
Mutual labels:  grid, flexbox
Atgrid.css
CSS Grid System with attribute selectors
Stars: ✭ 37 (-57.95%)
Mutual labels:  grid, flexbox

vue-fraction-grid

Flexbox based responsive fraction grid system for Vue.js

Live Demo and Full Documentation

<container>
  <grid vertical="middle" :rwd="{compact: 'stack'}">
    <grid-item size="1/6" :rwd="{compact: '0/1'}">
      ...
    </grid-item>

    <grid-item size="3/6" :rwd="{compact: '1/1'}">
      ...
    </grid-item>

    <grid-item size="2/6" :rwd="{compact: '1/1'}">
      ...
    </grid-item>
  </grid>
</container>

Installation

Install the package using yarn or npm:

$ yarn add vue-fraction-grid

# or

$ npm install --save vue-fraction-grid

Global

Load the plugin by calling Vue.use():

import Vue from "vue";
import VueFractionGrid from "vue-fraction-grid";

Vue.use(VueFractionGrid);

Now you have access in your templates to <container>, <grid> and <grid-item> components.

Local

You may prefer to explicitly import the components in your templates:

<template>
  <container>
    <grid>
      <grid-item size="1/2">
        ...
      </grid-item>
      <grid-item size="1/2">
        ...
      </grid-item>
    </grid>
  </container>
</template>

<script>
import Container from "vue-fraction-grid/components/Container";
import Grid from "vue-fraction-grid/components/Grid";
import GridItem from "vue-fraction-grid/components/GridItem";

export default {
  components: {
    Container,
    Grid,
    GridItem
  }
};
</script>

CDN

Load the script file from CDN:

<div id="root"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/vue/2.2.1/vue.min.js"></script>
<script src="//unpkg.com/vue-fraction-grid"></script>
<script>
  new Vue({
    el: "#root",
    template: "<container>...</container>"
  });
</script>

Settings

Vue.use(VueFractionGrid, {
  container: "1020px",
  gutter: "24px",
  approach: "mobile-first",
  breakpoints: {
    compact: "320px 414px"
  }
});

Configure grid by passing options as a second argument of Vue.use(). Configuration is merged to defaults that are listed above.

Available settings:

container   - Default containers width. Works with any valid CSS values like: '1440px',
              '52em', '100vw' etc. Set it to '100%' to use full-width fluid grid. Because
              this is the maximum value, the grid will scale nicely for smaller viewports.
gutter      - Gutter width. Works with any valid CSS values like '30px', '1rem' etc.
approach    - 'mobile-first' or 'desktop-first'. Choose which approach of responsive web design
              do you prefer. Breakpoint rules are based on this option.
breakpoints - List the grid breakpoints. Key is the breakpoint name for `:rwd` prop.
              Value is the size and can include one or two CSS values separated
              with a space.

Components

Container

Syntax:

<container [width="<length>|<percentage>" ]></container>

Center content of the site in the container:

<container>
  ...
</container>

Override container's maximum width with width prop. This is useful when you need more than one container's type e.g. regular and full-width.

<container width="100%">
  ...
</container>
<container width="25vw">
  ...
</container>

Grid

Syntax:

<grid
  [horizontal="left|center|right"
  vertical="top|middle|bottom"
  direction="reverse|stack|stack-reverse"
  wrap="nowrap|wrap|wrap-reverse"
  :rwd="{ breakpointName: direction }"
  flat
  pair]
></grid>

The most common usage and simple example of the grid:

<grid>
  <grid-item size="1/3">
    ...
  </grid-item>

  <grid-item size="2/3">
    ...
  </grid-item>
</grid>

Nest grids however you like, the gutter is always the same. There is no need to wrap nested grids with containers.

<grid>
  <grid-item size="2/3">
    <grid>
      <grid-item size="1/2">
        ...
      </grid-item>

      <grid-item size="1/2">
        ...
      </grid-item>
    </grid>
  </grid-item>

  <grid-item size="1/3">
    ...
  </grid-item>
</grid>

Horizontal alignment of grid items. This works simillar to justify-content attribute.

<grid horizontal="left">
  ...
</grid>
<grid horizontal="center">
  ...
</grid>
<grid horizontal="right">
  ...
</grid>
<grid horizontal="around">
  ...
</grid>
<grid horizontal="between">
  ...
</grid>

Vertical alignment of grid items. This works simillar to align-items attribute.

<grid vertical="top">
  ...
</grid>
<grid vertical="middle">
  ...
</grid>
<grid vertical="bottom">
  ...
</grid>

Remove gutter from grid items.

<grid flat>
  ...
</grid>

Align content of the first item to the left and content of the second item to the right.

<grid pair>
  ...
</grid>

Set the grid items direction. This works simillar to flex-direction attribute.

<grid direction="reverse">
  ...
</grid>
<grid direction="stack">
  ...
</grid>
<grid direction="stack-reverse">
  ...
</grid>

Set the grid items wrap. This works simillar to flex-wrap attribute.

<grid wrap="wrap">
  ...
</grid>
<grid wrap="wrap-reverse">
  ...
</grid>

Mix props however you want to.

<grid horizontal="right" vertical="bottom" direction="reverse" pair>
  ...
</grid>

Grid Item

Syntax:

<grid-item
  size="<number>/<number>"
  |grow="<number>"
  |shrink="<number>"
  [:rwd="{ breakpointName: size }"
  ]
></grid-item>

Use any size written in the fraction format. Grid item should be nested directly in the grid. Items fractions don't have to sum to 1. Denominator can't be equal 0!

<grid-item size="123/456">
  ...
</grid-item>

Fill the grid with a grid item by setting its size to 1/1:

<grid-item size="1/1">
  ...
</grid-item>

Hide the grid item by setting its size to 0/1:

<grid-item size="0/1">
  ...
</grid-item>

Use grow and shrink props instead of size. They work simillar to flex-grow and flex-shrink attributes. Never mix size, grow and shrink into a single item!

<grid-item grow="2">
  ...
</grid-item>
<grid-item shrink="0.5">
  ...
</grid-item>

Responsive Design

Responsive design is based on two options from settings: approach and breakpoints.

If you set approach to mobile-first breakpoints with a single value will respond to media queries using min-width attribute. If you use desktop-first instead, breakpoints will respond to max-width.

Breakpoints with two values respond to (min-width: <length>) and (max-width: <length>) query.

Following configuration:

Vue.use(VueFractionGrid, {
  approach: "desktop-first",
  breakpoints: {
    compact: "415px",
    tablet: "416px 1100px"
  }
});

Is translated to this declaration from CSS:

@media (max-width: 415px) {
  ...;
} /* compact */
@media (min-width: 416px) and (max-width: 1100px) {
  ...;
} /* tablet */

API

Change the direction of a grid for specific breakpoints.

<grid :rwd="{compact: 'reverse'}">
  ...
</grid>
<grid direction="stack" :rwd="{compact: 'stack-reverse'}">
  ...
</grid>

Change size of a grid item for specific breakpoints.

<grid-item size="3/4" :rwd="{compact: '0/1'}">
  ...
</grid-item>

Mix responsive design props for grid and items.

<grid :rwd="{compact: 'stack'}">
  <grid-item size="1/6" :rwd="{tablet: '0/1', compact: '1/1'}">
    ...
  </grid-item>
  <grid-item size="1/2" :rwd="{tablet: '1/2', compact: '0/1'}">
    ...
  </grid-item>
  <grid-item size="1/3" :rwd="{tablet: '1/2', compact: '1/1'}">
    ...
  </grid-item>
</grid>

Development

  1. Clone the repository:

    $ git clone [email protected]:brtjkzl/vue-fraction-grid.git
    
  2. Run scripts from package.json using npm run / yarn run in the main directory:

    demo   - Start demo page with implementation of all examples
    test   - Run tests using Jest
    lint   - Lint JS and CSS code of components, utils and installation
    docs   - Start docs locally
    deploy - Deploy docs to GitHub Pages
    dist   - Create an optimized bundle in UMD format
    

Code is open sourced on GitHub. Up to date changelog is available under the releases section.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].