Convert Figma logo to code with AI

hootsuite logogrid

Drag and drop library for two-dimensional, resizable and responsive lists

3,572
280
3,572
46

Top Related Projects

11,942

📝 the simplest and smallest WYSIWYG text editor for web, with no dependencies

43,060

Quill is a modern WYSIWYG editor built for compatibility and extensibility

14,837

The world's #1 JavaScript library for rich text editing. Available for React, Vue and Angular

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.

Medium.com WYSIWYG editor clone. Uses contenteditable API to implement a rich text solution.

18,951

A rich text editor for everyday writing

Quick Overview

Grid is a lightweight, responsive CSS grid system developed by Hootsuite. It provides a flexible and customizable layout framework for building responsive web designs using a 12-column grid system. Grid is designed to be simple, efficient, and easy to integrate into existing projects.

Pros

  • Lightweight and minimal, with a small file size
  • Highly customizable through Sass variables
  • Responsive design out of the box
  • Easy to integrate with existing projects

Cons

  • Limited documentation and examples
  • Not actively maintained (last commit was in 2017)
  • Lacks advanced features found in more modern CSS grid systems
  • May require additional effort to achieve complex layouts

Code Examples

  1. Basic grid layout:
<div class="grid">
  <div class="grid__col grid__col--1-of-2">
    Column 1
  </div>
  <div class="grid__col grid__col--1-of-2">
    Column 2
  </div>
</div>
  1. Responsive grid with different column sizes:
<div class="grid">
  <div class="grid__col grid__col--1-of-3 grid__col--m-1-of-2 grid__col--s-1-of-1">
    Column 1
  </div>
  <div class="grid__col grid__col--1-of-3 grid__col--m-1-of-2 grid__col--s-1-of-1">
    Column 2
  </div>
  <div class="grid__col grid__col--1-of-3 grid__col--m-1-of-1 grid__col--s-1-of-1">
    Column 3
  </div>
</div>
  1. Nested grid:
<div class="grid">
  <div class="grid__col grid__col--1-of-2">
    <div class="grid">
      <div class="grid__col grid__col--1-of-2">
        Nested Column 1
      </div>
      <div class="grid__col grid__col--1-of-2">
        Nested Column 2
      </div>
    </div>
  </div>
  <div class="grid__col grid__col--1-of-2">
    Column 2
  </div>
</div>

Getting Started

  1. Install Grid using npm:
npm install @hootsuite/grid
  1. Import the Grid CSS file in your project:
<link rel="stylesheet" href="node_modules/@hootsuite/grid/dist/grid.min.css">
  1. Use Grid classes in your HTML:
<div class="grid">
  <div class="grid__col grid__col--1-of-3">
    Column 1
  </div>
  <div class="grid__col grid__col--1-of-3">
    Column 2
  </div>
  <div class="grid__col grid__col--1-of-3">
    Column 3
  </div>
</div>

Competitor Comparisons

11,942

📝 the simplest and smallest WYSIWYG text editor for web, with no dependencies

Pros of Pell

  • Lightweight and minimalistic WYSIWYG editor (< 1.5kb gzipped)
  • No dependencies, making it easy to integrate into projects
  • Simple API and customizable interface

Cons of Pell

  • Limited features compared to more robust editors
  • May require additional development for advanced functionality
  • Less active community and fewer updates

Code Comparison

Pell initialization:

const editor = pell.init({
  element: document.getElementById('editor'),
  onChange: html => {
    // Handle content changes
  }
})

Grid initialization:

const grid = new Grid({
  container: document.getElementById('grid-container'),
  items: [
    { content: 'Item 1' },
    { content: 'Item 2' }
  ]
})

Key Differences

  • Pell focuses on text editing, while Grid is for layout management
  • Pell is a standalone editor, Grid is part of a larger UI framework
  • Pell has a simpler API, Grid offers more complex layout options

Use Cases

  • Pell: Lightweight text editing in web applications
  • Grid: Creating responsive grid layouts for content organization

Community and Maintenance

  • Pell: Less frequent updates, smaller community
  • Grid: More active development, part of Hootsuite's ecosystem
43,060

Quill is a modern WYSIWYG editor built for compatibility and extensibility

Pros of Quill

  • More active development with recent updates and contributions
  • Larger community with more stars, forks, and contributors
  • Extensive documentation and examples available

Cons of Quill

  • Steeper learning curve due to more complex architecture
  • Larger file size and potentially higher resource usage
  • May be overkill for simpler projects or use cases

Code Comparison

Quill:

var quill = new Quill('#editor', {
  modules: { toolbar: true },
  theme: 'snow'
});

Grid:

var grid = new Grid('#container', {
  columns: 3,
  gutter: 10
});

Summary

Quill is a feature-rich text editor with a larger community and more active development. It offers extensive customization options but may have a steeper learning curve. Grid, on the other hand, is a simpler layout library focused on creating responsive grid layouts. It's more lightweight and easier to implement for basic grid needs.

The code comparison shows that Quill requires more configuration for its text editing functionality, while Grid has a straightforward setup for creating grid layouts. Choose Quill for advanced text editing capabilities, and Grid for simple, responsive layouts.

14,837

The world's #1 JavaScript library for rich text editing. Available for React, Vue and Angular

Pros of TinyMCE

  • More comprehensive and feature-rich WYSIWYG editor
  • Extensive plugin ecosystem and customization options
  • Larger community and better documentation

Cons of TinyMCE

  • Heavier and potentially slower than Grid
  • Steeper learning curve for implementation and customization
  • May be overkill for simpler content editing needs

Code Comparison

TinyMCE initialization:

tinymce.init({
  selector: 'textarea',
  plugins: 'link image code',
  toolbar: 'undo redo | bold italic | alignleft aligncenter alignright | code'
});

Grid initialization:

var grid = new Grid({
  element: '#grid-container',
  columns: 3,
  gutter: 10
});

While both repositories serve different purposes, this comparison highlights the differences in complexity and focus. TinyMCE is a full-featured text editor, while Grid is a lightweight layout tool. The code snippets demonstrate the initialization process for each, with TinyMCE requiring more configuration options due to its broader feature set.

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.

Pros of CKEditor 5

  • More comprehensive and feature-rich text editing solution
  • Extensive documentation and community support
  • Modular architecture allowing for customization and plugin development

Cons of CKEditor 5

  • Larger file size and potentially higher resource usage
  • Steeper learning curve for implementation and customization
  • May be overkill for simple grid-based layouts or content organization

Code Comparison

CKEditor 5 (JavaScript):

import ClassicEditor from '@ckeditor/ckeditor5-build-classic';

ClassicEditor
    .create(document.querySelector('#editor'))
    .then(editor => {
        console.log('Editor was initialized', editor);
    })
    .catch(error => {
        console.error(error);
    });

Grid (HTML/CSS):

<div class="grid">
    <div class="grid-item">Item 1</div>
    <div class="grid-item">Item 2</div>
    <div class="grid-item">Item 3</div>
</div>
.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

While CKEditor 5 focuses on rich text editing functionality, Grid provides a simpler solution for creating responsive grid layouts. CKEditor 5 is better suited for content creation and editing, while Grid is more appropriate for organizing and displaying content in a structured manner.

Medium.com WYSIWYG editor clone. Uses contenteditable API to implement a rich text solution.

Pros of medium-editor

  • More actively maintained with recent updates and contributions
  • Broader functionality as a full-featured WYSIWYG editor
  • Extensive documentation and examples for easy implementation

Cons of medium-editor

  • Larger file size and potentially heavier performance impact
  • Steeper learning curve due to more complex API and options
  • May include unnecessary features for simple editing tasks

Code Comparison

medium-editor:

var editor = new MediumEditor('.editable', {
    toolbar: {
        buttons: ['bold', 'italic', 'underline', 'anchor', 'h2', 'h3', 'quote']
    },
    placeholder: {
        text: 'Type your text'
    }
});

grid:

$('.grid').grid({
    itemSelector: '.grid-item',
    columnWidth: 200,
    gutter: 10
});

The code snippets highlight the different purposes of these libraries. medium-editor focuses on creating rich text editors, while grid is designed for layout management and organizing elements in a grid structure. medium-editor offers more customization options for text editing, whereas grid provides a simpler API for arranging elements in a responsive grid layout.

18,951

A rich text editor for everyday writing

Pros of Trix

  • More actively maintained with recent updates and releases
  • Extensive documentation and examples for easier integration
  • Broader feature set for rich text editing, including file attachments

Cons of Trix

  • Larger file size and potentially heavier performance impact
  • More complex setup and configuration required
  • Less customizable appearance out of the box

Code Comparison

Trix initialization:

<trix-editor class="trix-content" input="x"></trix-editor>
<input id="x" type="hidden" name="content">

Grid initialization:

$('.grid').grid({
  srcNode: '.grid-item',
  margin: 10,
  width: 250,
  maxWidth: 250,
  animate: true,
  animationOptions: {
    speed: 200,
    duration: 300
  }
});

While both projects serve different purposes (Trix for rich text editing and Grid for layout management), the code snippets demonstrate the initialization process for each. Trix uses a custom HTML element and a hidden input, while Grid is typically initialized on existing DOM elements using jQuery.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

DEPRECATED

This project is no longer maintained, please consider using react-grid-layout instead.

GridList Build Status

Drag and drop library for a two-dimensional resizable and responsive list of items

Demo: http://hootsuite.github.io/grid/

The GridList library is split into two roles:

  1. An agnostic GridList class that manages the two-dimensional positions from a list of items within a virtual matrix.
  2. A jQuery plugin built on top of the GridList class that translates the generic items positions into responsive DOM elements with drag and drop capabilities.

GridList class

Jump to:

API

new GridList(items, options)

var myGrid = new GridList(items, {
  direction: 'horizontal',
  lanes: 3
});

The first constructor parameter is an array of items to populate the grid with.

Supported options:

  • direction - Can be 'horizontal' or 'vertical'. Defaults to 'horizontal'. This sets how the grid can expand e.g. for 'horizontal' the grid will stretch towards the right to accommodate all the items. For 'vertical', it will stretch towards the bottom.
  • lanes - Number of fixed rows or columns, depending on the direction.

generateGrid()

myGrid.generateGrid();

Build the grid structure from scratch, using the positions of the given items. If items lack positional attributes (x and y), they will be misplaced, possibly overlapping. If you want to build a grid around a list of items that only have their size attributes defined (w and h), and rely on the library to position them two-dimensionally, use resizeGrid.

resizeGrid(lanes)

myGrid.resizeGrid(4);

(Re)generate positions for the items inside a grid instance for a given number of rows/columns. This method has two major use-cases:

  1. Items are being represented two-dimensionally for the first time.
  2. Items already have 2d positions but need to be represented on a different grid size, maintaining as much as possible of their previous order.

Positions inside the grid are generated left-to-right, top-to-bottom. So when looking for a new position inside the grid the topmost row from the leftmost column is chosen.

moveItemToPosition(item, position)

// Move item from [0, 0] to [1, 1]
var carefreeItem = myGrid.grid[0][0];
myGrid.moveItemToPosition(carefreeItem, [1, 1]);

Here are things that happen when moving an item inside the grid:

  1. The item's previous position is cleared inside the 2d grid,
  2. The position inside the item object is updated,
  3. The item's new position is marked inside the 2d grid and
  4. Collisions are handled if the moved item overlaps with other item(s) from the grid.

Collisions can be solved in two ways. First, an attempt to resolve them locally is made, meaning that the moved item tries to swap position with the overlapped item(s). This is the preferred fair trade. If this doesn't work out and after swapping we still have collisions inside the grid, the entire grid will be regenerated, starting with the moved item fixed in its new position. In the latter case, all the items around and to the right of the moved item might have their position slightly altered.

resizeItem(item, size)

// Resize item from position [0, 0] to span over 3 columns
var growthItem = myGrid.grid[0, 0];

myGrid.resizeItem(growthItem, {w: 3});
console.log(growthItem.w); // will output "3"

myGrid.resizing(growthItem, {h: 2});
console.log(growthItem.h); // will output "2"

Resizing an item is very similar to moving its position, in the sense that grid cells will be repopulated and collisions will be handled afterwards. See moveItemToPosition.

Primitives

Item

The item is the building block of GridList, and is a plain JavaScript object. The primary function of the GridList is to position such items two-dimentionally. Which brings us to the composition of an item: w and h for size, x and y for position. E.g.

{w: 3, h: 1, x: 0, y: 1}

Note that x and y (column and row) are abstract coords inside the grid, they are integer values starting from 0. Naturally, w and h (width and height) also take up space in the same coordinate system, which reveals the smallest unit of a grid: the cell. You could say, for example, that the featured item above takes up three grid cells.

gridList.items

A GridList instance works around an array of items. The items array is the first parameter of the class constructor and is always visible under the .items property. Here's a list of items for a grid with three 1x1 items on a column with three rows:

[{w: 1, h: 1, x: 0, y: 0},
 {w: 1, h: 1, x: 0, y: 1},
 {w: 1, h: 1, x: 0, y: 2}]

gridList.grid

Seeing how JavaScript doesn't support multidimensional arrays, the 2d grid inside GridList is represented by an array for columns, with each array entry containing another array with cells for each row. The cell is simply a pointer to an item that occupies it, or a null reference if no item is sitting on that cell's position. Note that more cells can point to the same item reference, because items occupy w * h cells. Here's a grid pseudo-representation:

col1col2col3col4
12
1344
144

Having the grid in a two-dimensional data structure, we can fetch item references directly by targeting any of the cells they cover inside the grid. E.g.

myGrid.grid[1][0] // reference to item #2
myGrid.grid[1][1] // reference to item #3
myGrid.grid[2][1] // reference to item #4
myGrid.grid[3][2] // still reference to item #4

PS. This grid would be generated by these items:

[{w: 1, h: 3, x: 0, y: 0},
 {w: 1, h: 1, x: 1, y: 0},
 {w: 1, h: 1, x: 1, y: 1},
 {w: 2, h: 2, x: 2, y: 1}]

$.fn.gridList

$('.my-list').gridList({
  direction: 'horizontal',
  lanes: 3
});

The jQuery plugin has two main functions:

  • Render the GridList on top of a list of DOM elements. The list items are expected to have data-w and data-h attributes, and optionally data-x and data-y (if their positions have been previously generated and persisted)
  • Drag and drop capabilities

The function takes an optional argument with options that will be passed to the draggables when constructing them.

$('.my-list').gridList({lanes: 3}, {handle: '.title'});

See jQuery UI Draggable API for details on all the available options.

The rendered list is responsive to its parent container, meaning that the width and height of the items are calculated based on the container height divided by the number of grid rows.

FAQ: Why not gridster?

  • Their README reads Ducksboard is no longer active in their development. There are a few notable forks but it's hard to assert their reliability.
  • gridster works vertically while our solution works both vertically and horizontally.
  • Our lib contains over 5 times fewer code.
  • gridster collisions are very basic, we pushed towards better UX and found alternative ways for dealing with collisions.
  • We wanted out-of-the-box responsiveness, and the entire grid system was build fluid, relative to any parent container.
  • We needed the grid logic to be a DOM-less lib outside the jQuery plugin. This allows us to compute grid positions on the server-side and run kick-ass fast tests with Node.
  • Another more particular thing we needed was widgets that had height=0, which means they stretch on however many rows a grid has. We show timelines like this. It also works for width=0.

Please check demo page or code directly for investigating these assumptions.