GithubHelp home page GithubHelp logo

sdras / cssgridgenerator Goto Github PK

View Code? Open in Web Editor NEW
5.0K 5.0K 536.0 3.5 MB

๐Ÿงฎ Generate basic CSS Grid code to make dynamic layouts!

Home Page: https://cssgrid-generator.netlify.com/

License: MIT License

JavaScript 15.65% HTML 3.81% Vue 75.01% SCSS 5.53%
css-grid generated-code generated-layout grid grid-layout grid-system netlify vue

cssgridgenerator's Introduction

CSS Grid Generator

CSS Grid Generator

This project is a way for people to use CSS Grid features quickly to create dynamic layouts.

You can set the numbers, and units of your columns and rows, and I'll generate a CSS grid for you! Drag within the boxes to create divs placed within the grid.

I noticed a lot of people weren't using Grid because they felt it was too complicated and they couldn't understand it. Grid is capable of so much, and this small generator only touches on a fraction of the features. The purpose of this is so people get up and running quickly, and create more interesting layouts.

Once you work with this a bit, I suggest checking out resources by Rachel Andrew, Jen Simmons, and Dave Geddes to dive deeper. There is also a CSS Grid Guide on CSS-Tricks, and a fun little game called Grid Garden to help you learn more!

This project is open to contributions!

Project setup

yarn install

Compiles and hot-reloads for development

yarn run serve

Compiles and minifies for production

yarn run build

Run your tests

yarn run test

Lints and fixes files

yarn run lint

Customize configuration

See Configuration Reference.

cssgridgenerator's People

Contributors

acjbizar avatar afuno avatar ajerez avatar chrisdemars avatar dasdaniel avatar dependabot[bot] avatar equinusocio avatar guastallaigor avatar hasanuzzamanbe avatar infasyskey avatar natec425 avatar pacosegovia avatar pnevares avatar rykilleen avatar sawalhah avatar sdras avatar stefanmkodo avatar sunpietro avatar teal18aa9f avatar terabytetiger avatar trickstival avatar veronq avatar wlvstv avatar ysfscream avatar yubathom avatar zackkrida 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  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

cssgridgenerator's Issues

divs overlaying each other

why is it allowed for divs to overlay one over another?
this must be some kind of bug.
it's absurd that one can layer divs on top of each other.

Missing curly brackets on parent div

There is a missing curly bracket after the parent div

.parent {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr 1fr;
grid-column-gap: 0px;
grid-row-gap: 0px; // Missing "}" here
.div1 { grid-area: 1 / 1 / 5 / 3; }
.div2 { grid-area: 1 / 3 / 3 / 5; }
.div3 { grid-area: 3 / 3 / 5 / 5; }

} // was not accepted by CSS file

Usability the cards

I first opened the grid generator and it took me a long time to see the close div button (x), my suggestion is to increase the close button, i can make the change if for necessary

Set browserslist correctly

A correct browserslist must be defined in order to let PostCSS (already running with Vue CLI) prefix the code. I have a PR ready, i can suggest browsers version where the grid module is natively supported:

[
  "last 2 Chrome versions",
  "last 2 Firefox versions",
  "last 2 Safari versions",
  "last 2 Edge versions"
]

Then remove prefixed code around the repo.

Allow "auto" values for rows/columns

It would be nice to support auto, as well as max-content and min-content for row and column sizes.

I imagine adding tests for them here would work:

/fr/.test(unit) ||
/px/.test(unit) ||
/%/.test(unit) ||
/em/.test(unit) ||
/rem/.test(unit) ||
/vw/.test(unit) ||
/vh/.test(unit) ||
/vmin/.test(unit);

But I'm not sure how to visualise that on the grid (since the rows/columns have no content to size by). Maybe just default to a ~2rem height/width? We can probably assume the user knows what they're doing if they've typed min-content in.

I've never written any Vue before but happy to learn to try and PR if you think this would be worthwhile.

IE Implementation?

Firstly this is an amazing tool, thank you so much for making it :)

This is more of a feature request, and I appreciate that using the IE syntax for grid isn't always the best way to go / a viable solution. However, may be nice to have the option to generate the code for this, as sometimes autoprefixer doesn't quite do the job. Maybe this would be off by default and be an option that could be toggled on?

Add "clear" button?

First of all, this is a pretty awesome way to visualize the grid. Thanks! ๐Ÿ™Œ

Since the divs you make aren't editable (or at least I couldn't figure out a way to edit the divs), it might be nice to add a "Clear" button that will remove any of the added divs so you can start over. Of course, you can refresh the page I guess, but that also resets your columns/rows layout.

Thanks for the hard work!

Problems with single column

When set column quantity to 1 (+ 5 rows by default). The grid shows on preview 1 row with 5 columns, instead of 1 column and 5 rows. The code in the "Your Grid Code" is correct.
In Dev Tools you can see grid-template-columns: repeat(5, 1fr);, must be grid-template-columns: 1fr;

Dragging bottom to top and right to left doesn't have the same behavior as dragging top to bottom and left to right

In this screenshot, .div1 was created by clicking the top left cell and dragging to the bottom left cell, .div2 was created by clicking the bottom left cell and dragging to the bottom right cell. .div3 and .div4 were created by dragging around the right and top edges in the same manner. I would have expected .div3 and .div4 to create "complete" rows and columns like .div1 and .div2 are.
Screen Shot 2019-05-28 at 12 37 11 PM

Thanks for your hard work on this and everything you do!

accessible modal notes

would be good to close modal on pressing escape or clicking outside.

next level would be to trap focus in the modal. copy to clipboard button also doesnt seem to be tabbable.

:) (just practicing what ive learned about a11y, i'm not at all an expert)

Bad experience on dragging

When you drag the mouse , where you want to put the div, it only works once, then you have to click out of the box to create another a large div

braces for the first css selectors

The braces for the first selector in the created CSS code creates the closing braces at the end of the file instead of closing that first selector

HTML code?

Why isn't there available option to get HTML code as well, with CSS one?

Consider using grid-template-areas

Hey Sarah, thank you so much for an impressive and really useful project like this!

Have you considered using grid-template-areas for simpler layouts which may make output code more readable, e. g.

.parent {
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: 70px 1fr 140px;
  grid-column-gap: 10px;
  grid-row-gap: 0px;
  grid-template-areas: "div1 div1"
                       "div4 div2"
                       "div4 div3";
}

.div1 { grid-area: div1; }
.div2 { grid-area: div2; }
.div3 { grid-area: div3; }
.div4 { grid-area: div4; }

Versus:

.parent {
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: 70px 1fr 140px;
  grid-column-gap: 10px;
  grid-row-gap: 0px;
}

.div1 { grid-area: 1 / 1 / 2 / 3; }
.div2 { grid-area: 2 / 2 / 3 / 3; }
.div3 { grid-area: 3 / 2 / 4 / 3; }
.div4 { grid-area: 2 / 1 / 4 / 2; }

This isn't an option for layouts that have overlapping areas, however.

Output CSS + HTML in "Your Grid Code" window

Would it be possible to get the html markup as well as the css code when you click on the button for Please may I have some code ?

Basically, make the html markup available as well so that its very simple to copy paste into a file and preview it

Thanks for the great website. This is really helping me to get started with CSS grids ๐Ÿ‘

Preview of selected area while dragging

Hi,

I was thinking of a feature where you could see the area you're selecting while dragging the mouse across. Currently, the selected area gets visible only when you release the mouse button.

Thoughts ?? ๐Ÿค” ๐Ÿ˜„

Nested Grids?

This is really a feature request. I love the simplicity of your tool, for quick and dirty grid configuration I love it! It has some quirks, most of which I think already have issues, but overall it is really nice how simple and easy it is to use.

I am wondering, though...could this be extended, without losing the simple design...to support nested grid layouts?

Output Parent names

just a little feature to add
it would be great if I could name my parent and children elements so I wouldn't have to edit the grid output each time I copy and paste it :)

Clicking "Reset Grid" appears to disable the click & drag motion

Thanks for this awesome site! Dropping this here to start my own investigation and I figure someone else may beat me to the fix, which is fine.

Reproduction

  • Open the site (in my case, in Chrome)
  • Click and drag to create a div
  • Click "Reset Grid" button
  • Attempt to drag over another region to start again

Expected behavior: Drawing still works
Actual behavior: Don't seem to be able to click & drag anywhere anymore

Note: the behavior also happens if I click the x on the div prior to resetting the grid. Anytime the button is clicked, it appears the click/drag functionality stops working as well.

No errors in the console or anything that points to an obvious culprit (for me at least).

Screen Capture

2019-06-08_CSSGridGenerator_ResetIssue

Stacking lots of divs makes text hard to read

Annotation 2019-05-28 083453

I don't know why I just kept clicking but it doesn't really get weird until 21. When the columns, rows, and gaps are maxed out it is more apparent. I was able to reproduce this on Chrome, Edge, and Firefox.

Thank you for making this, it's super cool!

Add Media Queries

It would be nice to set breakpoints, freeze the col and rows and drag the divs around for responsive implementation.

CSS output modes

  • Add plain CSS output mode by default for those not using SCSS/Sass
  • Add newline format option. (Pasting into VSCode on Windows is double-spaced)

make it possible to undo/unselect divs?

accidental clicks can cause creation of extra divs we didnt mean to make.

the simple form of this is a "undo" mechanism. probably a vuex thing? idk

the bigger form of this is a click/touch mechanism or logic to know we want to delete stuff

the "galaxy brain" form of this is direct manipulation of the generated code to delete/edit stuff directly, and see the result visualized. altho arguably you could already do that in browser css tools ๐Ÿคท๐Ÿผโ€โ™‚๏ธ

Donโ€™t show CSS unit error if value is 0

Repro step:

Enter 0 without a unit as one of the values.

Expected behavior:

Should render correctly without errors because 0 without a unit is a valid CSS value.

Actual behavior:

Following error message is displayed: "Must use real CSS units, goofball".

SCSS mode

Hello,

Very nice tool for people like me that are new to grid system.

However, I have a small suggestion. I use SCSS as a standard processor for my css. When I do something like this :

.div1 { grid-area: 2 / 3 / 4 / 5; }

It calculate the values. To force SCSS to just consider this as a string, I have to do :

.div1 { grid-area: {#"2 / 3 / 4 / 5"}; }

Like this, it works well.

Would ie be possible to add a small option in your tool : "display code as SCSS" and add that syntax to be able to do a quick copy / paste without adding manually this syntax when you use SCSS processor ?

Thank you

Error while building the application on a windows machine

Hi,

After running npm install, I ran npm run serve and getting this error in my terminal.Also, I am running this application on windows 10 machine -

cssgridgenerator-master\node_modules\open\index.js:11
const wslToWindowsPath = async path => {
^^^^
SyntaxError: Unexpected identifier
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (C:\Users\vn50afl\Desktop\cssgridgenerator-master\cssgridgenerator-master\node_modules@vue\cli-shared-utils\lib\openBrowser.js:9:14)
at Module._compile (module.js:570:32)

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.