Giter Club home page Giter Club logo

layoutit-grid's Introduction

Layoutit Grid

CSS Grids layouts made easy!

Layoutit grid is a CSS Grid layout generator. Quickly design web pages layouts with our clean editor, and get HTML and CSS code to quickstart your next project.

Read about the process of Open Sourcing Layoutit Grid, and why we are using Vue 3 and Vite ❤️

Use the tool

Go to https://grid.layoutit.com/ and start playing 🎯

This App is not currently intended to be used as a library, but may in the future. The package in npm is just a placeholder to help discovering the github repository at this point.

Why we built a Generator

Generators can be a stepping stone when you are learning new concepts. Layoutit Grid helps you experience the power of CSS Grid by materializing your designs in a few clicks along with the code to make it happen. This gives you the early wins that you need to push forward with the learning process. For some of us, generators permanently remain in our toolboxes. Not because we do not know how to craft the layouts by hand, but because having the visual feedback loop help us to quickly convert our ideas into code. So we keep playing with them.

Read more about learning CSS Grid visually with a generator here

Run it locally

These instructions will get you a copy of the project up and running on your local machine for development

Clone the repo

Use ssh

git clone [email protected]:Leniolabs/layoutit-grid.git

Or https

git clone https://github.com/leniolabs/layoutit-grid.git

Run it

  1. Install pnpm (https://pnpm.io/installation)
  2. In the repo folder run
pnpm install
pnpm start

Your dev server will start and be running at

  > Local:    http://localhost:3000/

Commands

Command Description
pnpm install Install the dependencies
pnpm start Run the project (in dev mode)
pnpm run build Build for deployment

Contributing

Ideas, pull requests and bug reports are welcome.

Libs and Tools used

  • Vue 3 Vue.js - The Progressive JavaScript Framework.
  • Vueuse Collection of essential Vue Composition Utilities
  • Vite Next generation frontend tooling. It's fast!
  • vite-plugin-pwa Zero-config PWA for Vite
  • vite-plugin-components On demand components auto importing for Vite

Mentions



Creators

Layoutit grid is crafted with love by Leniolabs and a growing community of contributors. We build digital experiences with your ideas. Get in touch!

layoutit-grid's People

Contributors

abeledovictor avatar acapeletto-lenio avatar agustin-capeletto-lenio avatar alexrobaina avatar apresmoi avatar centrodph avatar dgiulian avatar erickgomez28 avatar estudiobold avatar gemanepa avatar gm1357 avatar james-cabell-lenio avatar jojohomefries avatar josebanega26 avatar jzcodeveloper avatar keilerdelgado avatar leandroercoli avatar mangeloni30 avatar mariana-beldi-lenio avatar mhechavarria avatar patak-dev avatar rhythm1920 avatar skevprog avatar userquin avatar valenfv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

layoutit-grid's Issues

Refactor grid lines into a GridTrack component

@dannynpham pushed a fix for #11, making the grid default to 1px gap in case there is a gap of zero. This works but there will be small diffs with the real grid the user will generate. This issue tracks a longer term solution by refactoring the GridEditor.

We can move the grid lines out of the GridCell component into a new GridTrack component and render them after the GridCells in the GridEditor (one per column plus one per row using grid-area for placement). The LineName and TrackSize components can go in the new GridTrack component. With this, the outlines will always be above the grid cells background.

Spaces in grid names

If you add a space to a grid area name the class it generates has a space in it which is invalid css.

i/e if I name my area "foo bar" it generates the css...

.foo bar { grid-area: foo bar; }

...which is obiously invalid for this because "bar" would be an element seelctor!

Maybe kebab-case the inputs?

Edit: It seems you already kebab-case the grid-area name inside the grid-template-areas it's just missing from the generated CSS.

Generate `grid-template` syntax for better readability

At the moment it produces code like this:

.grid {
  display: grid;
  grid-template-columns: 1fr 2fr 3fr;
  grid-template-rows: 100px 200px 300px;
  grid-template-areas:
    "a a b"
    "a a c"
    "d d e";
}

However it is much easier to read if the code is formatted like this in grid-template:

.grid {
  display: grid;
  grid-template:
    "a   a   b" 100px
    "a   a   c" 200px
    "d   d   e" 300px /
     1fr 2fr 3fr;
}

Note the additional spaces that you need to add to line up the column widths with the start of the area name.

Also, if a row is auto it doesn’t need a row height specified.

.grid {
  display: grid;
  grid-template:
    "sidebar-L main   sidebar-R" 
    "sidebar-L footer sidebar-R" /
     1fr       4fr    1fr;
}

By moving all the values into the 1 rule you can easily see what value is associated with what column/row as long as the formatting is done right. Making sure the column values line up with the start of all the column names is vital for readability.

Allow moving/extending grid areas

Hello,
first of all, thank you for this wonderful tool !

The only thing I am missing is the ability to move or extend already defined grid areas.

When one grid area is saved, there is no way (at least I found none) to make it start at another row/column, or to make it span a different number of rows/columns.

Thanks in advance for taking this into consideration

[Feature Request] Import Previously Generated Grids

Had a Windows update during my layoutit grid making and lost all the grid elements I had designated. It would be amazing to me and my future work if I was able to import previously generated layoutit grids

Review area name validation

We are converting to valid a valid css name when generating the code or showing the area name in the editor.
Now that we are also converting to a valid name on user input and not accepting spaces anymore, we could remove refactor the state to trust that it will always be a valid name and avoid having to convert everywhere. It would also be good to add dashes when the user press the space key (in the Code inputs and in the Area Selection name input).

Improve mobile UX to open and close sidebars

There should be at least two buttons, one for the Props sidebar and one for the Code and clear hints of how they work. Maybe we need a small header in mobile instead of showing the grid covering the whole screen.

Allow selection area to go over other areas

CSS Grid allows areas to go over each other, using grid-area and line numbers instead of grid-template-areas. The app is correctly detecting this case and the code works fine. But when the cells are being selected to define an area (see SelectionArea.vue), the selection doesn't expand if you are in a cell that already has another area. With the current approach to get the cell from the current pointer position, we need to add a pointer-events:none to at all Areas that are not the one where the selection is being dragged (probably also needs it in the internal GridCells of that areas). See https://github.com/Leniolabs/layoutit-grid/blob/main/src/components/grid/AreaSelection.vue#L91

Another option is to think of another way to get the current GridCell from the pointer position that doesn't interact with elements above the target cells.

Reset button

Would be great to have a reset button, whenever I am done with a big grid it's a pain to have to manually clear it all to start a fresh

Add keyboard shortcuts for main features (undo, redo, delete area)

We should add keyboard shortcuts for the main actions:
Cmd+z : undo
Cmd+y | Cmd+Shift+z : redo
Cmd+s : Get Permalink
Cmd+q : reset

When selecting grid cells for a new area (AreaSelection.vue)
Esc: closes selection, or cancels area edition

When area is active
delete : removes the area (or the subgrid if there is one)
c: add column (in the future it can mean, add it where I have the mouse)
r: add row
g: add subgrid in the area

Grid lines should not overflow main grid container while dragging

Grid lines are overflowing the main grid container when dragging in non full width grids.

To reproduce, create a grid that doesn't fill the 100% of the width of the application (don't use fr units). Lines with class dragging should not overflow the container.

Screen Shot 2020-10-02 at 9 13 31 AM

Publish to npmjs

Can you please publish to npmjs, so we can just add it to dependency managment?

paste in existing grid-template-areas "header header header", etc to generate IE 10 / IE 11 legacy grid specs

It would be extremely helpful if you had an additional textbox where I could paste in the code for grid-template-areas and have it output the correct IE 10 / IE 11 CSS for -ms-grid-row, -ms-grid-row-span, -ms-grid-column, -ms-grid-column-span, etc for grid-template-areas.

Creating the grid is easy enough visually in grid-template-areas - but trying to make it work in IE 10 / 11 is mind numbing.

Properly setup eslint and prettier with vite

We lost this configuration when we migrated to Vite from vue-cli.

This was the old package.json bits related to this

  "devDependencies": {
    "@vue/cli-plugin-eslint": "^3.8.0",
    "@vue/eslint-config-prettier": "^4.0.1",
    "lint-staged": "^9.0.0",
  },
  "gitHooks": {
    "pre-commit": "lint-staged"
  },
  "lint-staged": {
    "*.js": [
      "vue-cli-service lint",
      "git add"
    ],
    "*.vue": [
      "vue-cli-service lint",
      "git add"
    ]
  }

Looks like we now would have to do something like this though:

https://simohamed.tech/blog/vue3-lint/
https://www.simonwuyts.com/articles/vue-3-a-modern-setup-that-will-save-you-time/

api-save- recovery

hi, how to save and recovery data by api? (use json)
for example:
saveDesign(data){
....
}
recovery(data){

}

can you give me some cases ,Thanks!

New Logo

Layoutit Grid got the logo from the original Layoutit

image

We need a new modern logo to represent this app

Uncaught ReferenceError: ref is not defined

I get this error when I try to load the component

import { createApp } from 'vue'
import LayoutEditor from 'layoutit-grid/src/components/LayoutEditor'
// ...
createApp(LayoutEditor).mount("#apppp")

image

Seems like the function is in vue/compat but my browser cannot resolve it.

I am using Laravel mix for the webpack configuration.

I tried to resovle vue to vue-compat, but not sure if that did work correctly:

mix.webpackConfig({
    resolve: {
        alias: {
            vue: '@vue/compat'
        }
    }
});

Support exporting to CodeSandbox

We can use CodeSandbox Define API to create vanilla sandboxes:

https://codesandbox.io/docs/api#define-api

I think that people will prefer one of the options (Codepen, CodeSanbox, later other options?), and only use that one when using the app. There should be a way to select this preference and save it in local storage. Only one Export button will be shown in this way avoiding cluttering the UI

Import existing grid

Allow to import existing html/css into the grid, this way can modify a previous created(with the app or manually) grid.

An optional awesome feature can be maintain the not grid related props (like background, padding) of imported css and attrs (id, class, data-...) in html.

Highlight tracks on hover

We could have a currentHover ref in the same way that we have a currentFocus ref in store.js to track focus of track and line names focus, so we can highlight those tracks in the sidebar, code editor and inline inputs in the GridEditor.

  • When hovering in a track size/unit in the sidebar, then highlight that track (and its size) in the GridEditor and in the Code Editor
  • When hovering in a track size in the GridEditor, then highlight that track size/unit in the sidebar and in the Code Editor
  • When hovering in a track size in the Code Editor, then highlight that track size/unit in the sidebar and the track (and its size) in the GridEditor.
  • When hovering in a GridCell, highlight both the column and row tracks for that cell (and their sizes in the sidebar, GridEditor and Code Editor)

We probably need to use a lighter color for hover than the active color that is used for focus (or maybe just another color, we can play with that later)

Important: When we are currently focused in a track size (currentFocus is of type track), we may need to ignore the hovering queues if they are confusing what is actually active. An example is to focus on a track size in the code editor, edit it and press Tab to go to the next. The mouse is still on the previous one, so the hover queue will actually be unhelpful there. I think this is the only place where this is an issue, so maybe we just need to avoid setting currentHover in CssCodeTrackSize if currentFocus is on one of them (for this bit, we may need to extra metadata to the currentFocus).

Add keyboard shortcuts to grid

For navigation on the main grid or in the subgrid of a selected area:
Arrow right: move the hover to the right cell
Arrow left: move the hover to the left cell
Arrow down: move the hover to down cell
Arrow up: move the hover to up cell

In addition to its current functionality:
Esc: cancels the edit column or row name separator
c: add a column where I have the hover
r: add a row where I have the hover

New Actions:
Espace: select an area to edit or select an empty area to create
Shift + c: remove the column from the current hover cell
Shift + r: remove the row from the current hover cell
Shift + g: clean the area if it has a subgrid
Ctrl + c: copy the generated ccs code

This can be other PR:
Shift + arrow right: select column separator right
Shift + arrow left: select column separator left
Shift + arrow down: select row separator down
Shift + arrow up: select row separator up

When the row or column separator is select:
Espace: edit separator name
Arrow right: add width to the column left and remove width to the column right
Arrow left: add width to the column right and remove width to the column left
Arrow down: add height to the row up and remove height to the column down
Arrow up: add height to the row down and remove height to the column up

Selecting "auto" leads to wrong css

Hello,
Selecting "auto" as the value of a column/row generates incorrect css: 1auto instead of auto.

Steps to reproduce:

Generated css:

.grid-container {
  display: grid;
  grid-template-columns: 1auto 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 0px 0px;
  grid-template-areas:
    ". . . ."
    ". . . ."
    ". . . .";
}

Expected css:

.grid-container {
  display: grid;
  grid-template-columns: auto 1fr 1fr 1fr; // difference is here
  grid-template-rows: 1fr 1fr 1fr;
  gap: 0px 0px;
  grid-template-areas:
    ". . . ."
    ". . . ."
    ". . . .";
}

Improve Grid Placement pickers

See #91 (comment)

  • change color on hover to darker blue once an item is selected, so the user knows it can click on the selected one to go back to initial
  • don't close the options when going back to initial. The options should collapse by clicking on the title (collapsing with local state).

Maintain track size when changing unit

When you change a unit, the size is updated to 1fr, 300px, 10%, 4em. We should try to compute a new value for the track size that gives the same approximate size, but with the new unit. It doesn't need to be exact.

Unexpected behavior when using tabs

when filling sizes and magnitudes I would like to navigate through them using tab and shift + tab. Today, when pressing these keys, the behavior is somewhat unexpected.

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.