Skip to content

Commit 819d1b9

Browse files
v0.97
Let's say that everything works - for now. Added changing label and delete button color depending on grid-item background, improved readme, change order of main buttons
1 parent 434bf0c commit 819d1b9

File tree

8 files changed

+152
-39
lines changed

8 files changed

+152
-39
lines changed

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ Temporary Items
4949
# Node Modules
5050
node_modules/
5151

52-
# Finished (dist) code
53-
dist/
54-
5552
# Form files
5653
formularz.php
5754
phpmailer/

README.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
# CSS Grid Playground
22

3-
It's a little web app that I've made while I was learning CSS Grid and bored at work. I thought that it would be nice to have something interactive to try and see what Grid can reeally do, so here it is - Grid Playground.
3+
It's a little web app that I've made while I was learning CSS Grid and bored at work. I thought that it would be nice to have something interactive to try and see what Grid can really do, so here it is - Grid Playground.
44

55
Right now you can:
66
- add or delete grid items,
77
- change the number of rows and column,
88
- change grid container width and height,
99
- change the column and row gap,
1010
- change grid-auto-flow.
11+
- edit every item properties.
1112

1213
But there will be more options in the next releases.
1314

14-
If you need help, you can clikc the "Feeling Lost?" button which will open a modal box with all the basic grid properties used in this app.
15+
If you need help, you can click the "Nees help?" button which will open a modal box with all the basic grid properties used in this app.
1516

1617
DICSLAIMER: There are no official definitions here - use MDN to see those.
1718

19+
Cool features:
20+
- Each item has random generated background-color,
21+
- Each item labels and button font color is generated using HSP algorithm for brightness,
22+
- It's a PWA so it almost as good as native app,
23+
- There are some cool links at the bottom if you want to really master Grid,
24+
- Maybe it's not perfect, but it works!
25+
1826
Made entirely with HTML, CSS (Sass) and ES6 JavaScript.
1927

20-
Live - https://michalgrochowski.github.io/grid-playground/app/
28+
Live - https://michalgrochowski.github.io/grid-playground/dist
2129

2230
License: MIT

app/css/main.css

+26-6
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,20 @@
4444
display: grid;
4545
width: 90%;
4646
height: 90%;
47-
grid-template-columns: repeat(2, 1fr);
47+
grid-template-columns: repeat(3, 1fr);
4848
grid-template-rows: repeat(3, 1fr);
4949
grid-column-gap: 10px;
5050
grid-row-gap: 10px;
5151
grid-auto-flow: dense;
5252
-webkit-transition: 0.5s all;
5353
transition: 0.5s all;
5454
position: relative; }
55+
@media screen and (max-width: 800px) {
56+
.grid-container {
57+
grid-template-columns: repeat(2, 1fr);
58+
grid-template-rows: repeat(3, 1fr);
59+
grid-column-gap: 5px;
60+
grid-row-gap: 5px; } }
5561

5662
.grid-item {
5763
-webkit-transition: 0.5s all;
@@ -77,7 +83,10 @@
7783
right: 0.5rem; }
7884

7985
.grid-item__options {
80-
padding: 1rem; }
86+
padding: 3rem 1rem 1rem 1rem; }
87+
@media screen and (max-width: 800px) {
88+
.grid-item__options {
89+
padding-top: 4rem; } }
8190

8291
.grid-item__label {
8392
display: block;
@@ -95,6 +104,9 @@
95104
margin: 0 auto;
96105
border-radius: 1.5rem;
97106
border: 1px solid #000000; }
107+
@media screen and (max-width: 800px) {
108+
.grid-item__input {
109+
width: 80%; } }
98110

99111
.grid-options {
100112
position: relative;
@@ -161,8 +173,8 @@
161173
padding: 0 2rem 0 0; }
162174
.grid-options__button--help {
163175
padding: 0 1rem 0 0; }
164-
.grid-options__button--accept {
165-
font-size: 2rem; }
176+
.grid-options__button--options {
177+
padding: 0 1rem 0 0; }
166178
@media screen and (max-width: 800px) {
167179
.grid-options__button {
168180
margin: 1rem 0; } }
@@ -204,12 +216,15 @@
204216
.grid-options__close-modal {
205217
cursor: pointer;
206218
position: absolute;
207-
top: 2rem;
208-
right: 2rem;
219+
top: 4rem;
220+
right: 1rem;
209221
background: none;
210222
border: none;
211223
font-size: 2rem;
212224
color: #333333; }
225+
@media screen and (max-width: 800px) {
226+
.grid-options__close-modal {
227+
top: 1rem; } }
213228

214229
.grid-options__title {
215230
font-size: 2rem;
@@ -235,6 +250,8 @@
235250
.grid-options__paragraph--last {
236251
padding-top: 1rem;
237252
padding-bottom: 2rem; }
253+
.grid-options__paragraph--italic {
254+
font-style: italic; }
238255

239256
.grid-options__code {
240257
display: inline;
@@ -300,6 +317,9 @@
300317
flex-direction: column;
301318
padding-bottom: 3rem;
302319
margin-top: 6rem; }
320+
@media screen and (max-width: 800px) {
321+
.bonus-materials {
322+
margin-top: 16rem; } }
303323

304324
.bonus-materials__title {
305325
-ms-flex-preferred-size: 100%;

app/index.html

+25-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="pl">
2+
<html lang="en">
33
<head>
44
<meta charset="UTF-8"/>
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
@@ -71,27 +71,30 @@ <h2 class="section__title">Here is your grid:</h2>
7171
<div id="helpModal" class="grid-options__help-box">
7272
<article class="grid-options__article">
7373
<button id="closeModal" class="grid-options__close-modal">Close <span class="icon-cancel"></span></button>
74-
<h3 class="grid-options__title">Here are the basic CSS Grid properties used in this app:</h3>
74+
<h3 class="grid-options__title">Here are the basic CSS Grid properties:</h3>
75+
<p class="grid-options__paragraph grid-options__paragraph--italic">Not all of them are used in this app or are used in a different way - you can find all the details below</p>
76+
<p class="grid-options__paragraph">To use CSS Grid, first you have to add <code class="grid-options__code">"display: grid"</code> to your container. You can also set it to <code class="grid-options__code">"inline-grid"</code>. There is one more option, <code class="grid-options__code">"display: subgrid"</code> - useful if the elements parent has <code class="grid-options__code">"display: grid"</code> and you want your element and its content to be laid out according to the grid model.</p>
7577
<p class="grid-options__subtitle">Grid options:</p>
76-
<p class="grid-options__paragraph"><strong>width and height</strong> - pretty self explanatory, it's height and width of the grid container.</p>
78+
<p class="grid-options__paragraph"><strong>width and height</strong> - pretty self explanatory, it's the height and width of the grid container.</p>
7779
<p class="grid-options__paragraph"><strong>columns and rows</strong> - full property names are <code class="grid-options__code">"grid-template-columns"</code> and <code class="grid-options__code">"grid-template-rows"</code>. They specify how many columns and rows the grid will have. You can put there any value in px, %, rem, em, vh, vw or fr. Shorthand property is <code class="grid-options__code">"grid-template"</code>. Here we are using evenly sized columns and rows with <code class="grid-options__code">"repeat(number of columns/rows, size of column/row)"</code> option, but in your own grid you can use named areas or different values for each column/row, for example: <br>
78-
<code class="grid-options__code">"grid-template-columns: [first] 40px 1fr 20% [last];".</code><br></p>
80+
<code class="grid-options__code">"grid-template-columns: [first] 40px 1fr 20% [last];".</code><br>
81+
Yes, you can name very column and every row of your grid - pretty neat!</p>
7982
<p class="grid-options__paragraph"><strong>column gap and row gap</strong> - full property names are <code class="grid-options__code">"grid-column-gap"</code> and <code class="grid-options__code">"grid-row-gap"</code>. They specify the size of the gutters between columns and rows. You can put there any value in px, %, rem, em, vh, vw or fr. Shorthand property is <code class="grid-options__code">"grid-gap"</code>.</p>
80-
<p class="grid-options__paragraph"><strong>grid-auto-flow</strong> - Grid has preety great auto-placement algorithm, and <code class="grid-options__code">"grid-auto-flow"</code> property defines how should it act. If you set it to <code class="grid-options__code">"column"</code> it will place new grid items in available columns or create a new one and place it there. If you set it to <code class="grid-options__code">"row"</code> it will place new grid items in available rows or create a new one and place it there. Last option, <code class="grid-options__code">"dense"</code>, will try to fit any new items in available spots, also changing the order of grid items, so be careful with that.</p>
83+
<p class="grid-options__paragraph"><strong>grid-auto-flow</strong> - Grid has pretty great auto-placement algorithm, and <code class="grid-options__code">"grid-auto-flow"</code> property defines how should it act. If you set it to <code class="grid-options__code">"column"</code> it will place new grid items in available columns or create a new one and place it there. If you set it to <code class="grid-options__code">"row"</code> it will place new grid items in available rows or create a new one and place it there. Last option, <code class="grid-options__code">"dense"</code>, will try to fit any new items in available spotsand may also change the order of your grid items, so be careful with that.</p>
8184
<p class="grid-options__subtitle">Grid item options:</p>
82-
<p class="grid-options__paragraph"><strong>grid-column-start</strong> - specifies in which column the item will start. Given number refers to the start of the column. Only integers are allowed.</p>
83-
<p class="grid-options__paragraph"><strong>grid-column-end</strong> - specifies in which column the item will end. Given number refers to the start of the column, so for example if you want an item to span over columns 1-4, you have to put 5 in there. Only integers are allowed.</p>
84-
<p class="grid-options__paragraph"><strong>grid-row-start</strong> - specifies in which row the item will start. Given number refers to the start of the row. Only integers are allowed.</p>
85-
<p class="grid-options__paragraph"><strong>grid-row-end</strong> - specifies in which row the item will end. Only integers are allowed. Given number refers to the start of the row, so for example if you want an item to span over rows 1-3, you have to put 4 in there.</p>
85+
<p class="grid-options__paragraph"><strong>grid-column-start</strong> - specifies in which column the item will start. Given number refers to the start of the column. You can use integers to indicate specific column number, named area if you have one or <code class="grid-options__code">"span integer"</code> to tell the item to span over given number of columns.</p>
86+
<p class="grid-options__paragraph"><strong>grid-column-end</strong> - specifies in which column the item will end. Given number refers to the start of the column, so for example if you want an item to span over columns 1-3, you have to put 4 in there. You can use integers to indicate specific column number, named area if you have one or <code class="grid-options__code">"span integer"</code> to tell the item to span over given number of columns.</p>
87+
<p class="grid-options__paragraph"><strong>grid-row-start</strong> - specifies in which row the item will start. Given number refers to the start of the row. You can use integers to indicate specific row number, named area if you have one or <code class="grid-options__code">"span integer"</code> to tell the item to span over given number of rows.</p>
88+
<p class="grid-options__paragraph"><strong>grid-row-end</strong> - specifies in which row the item will end. Given number refers to the start of the row, so for example if you want an item to span over rows 1-3, you have to put 4 in there. You can use integers to indicate specific row number, named area if you have one or <code class="grid-options__code">"span integer"</code> to tell the item to span over given number of rows.</p>
8689
<p class="grid-options__subtitle">Other options:</p>
87-
<p class="grid-options__paragraph">CSS Grid offers a lot of more options than shown in this playground. Options like <code class="grid-options__code">"align-items"</code>, <code class="grid-options__code">"justify-items"</code>, <code class="grid-options__code">"align-content"</code> and <code class="grid-options__code">"justify-content"</code> works pretty much the same as in Flexbox, so if you know that you should also be able to use it in your grid. There is also the <code class="grid-options__code">"grid"</code> property, in which you specify all of the above. If you ask me, it makes the code a lot less readable, but feel free to use it.</p>
88-
<p class="grid-options__paragraph grid-options__paragraph--last">Grid items also have some more properties, like <code class="grid-options__code">"grid-area"</code> in which you tell the item which named areas of your grid should it take, and of course <code class="grid-options__code">"align-self"</code> and <code class="grid-options__code">"justify-self"</code>. You can also use short-hand properties <code class="grid-options__code">"grid-column"</code> and <code class="grid-options__code">"grid-row"</code> to specify both the start and the end of your item.</p>
90+
<p class="grid-options__paragraph">CSS Grid offers a lot of more options than shown in this app. Options like <code class="grid-options__code">"align-items"</code>, <code class="grid-options__code">"justify-items"</code>, <code class="grid-options__code">"align-content"</code> and <code class="grid-options__code">"justify-content"</code> works pretty much the same as in Flexbox, so if you know how to use them you are good to go. There is also the <code class="grid-options__code">"grid"</code> property, in which you specify all of the above properties. It makes the code a lot less readable in my opinion, but feel free to use it.</p>
91+
<p class="grid-options__paragraph grid-options__paragraph--last">Grid items also have some more properties, like <code class="grid-options__code">"grid-area"</code> that tells the item which named areas of your grid should it take or specify both columns and rows start and end, also there are of course <code class="grid-options__code">"align-self"</code> and <code class="grid-options__code">"justify-self"</code> - again, works the same way as with Flex items. You can also use short-hand properties <code class="grid-options__code">"grid-column"</code> and <code class="grid-options__code">"grid-row"</code> to specify both the start and the end of your item.</p>
8992
</article>
9093
</div>
9194
<div class="grid-options__controls">
9295
<button id="addGridItem" class="grid-options__button grid-options__button--add"><span class="icon-plus"></span> Add item</button>
93-
<button id="optionsButton" class="grid-options__button"><span class="icon-cog"></span> Grid options</button>
9496
<button id="showHelp" class="grid-options__button grid-options__button--help"><span class="icon-help-circled"></span> Need help?</button>
97+
<button id="optionsButton" class="grid-options__button grid-options__button--options"><span class="icon-cog"></span> Grid options</button>
9598
</div>
9699
<div id="options-box" class="grid-options">
97100
<form class="options-form">
@@ -102,7 +105,7 @@ <h3 class="grid-options__title">Here are the basic CSS Grid properties used in t
102105
<label class="options-form__label" for="gridHeight">height (px, rem, vh vw or %):</label>
103106
<input id="gridHeight" class="options-form__input" type="text" value="90%">
104107
<label class="options-form__label" for="gridColumns">columns (number):</label>
105-
<input id="gridColumns" class="options-form__input" type="text" value="2">
108+
<input id="gridColumns" class="options-form__input" type="text" value="3">
106109
<label class="options-form__label" for="gridRows">rows (number):</label>
107110
<input id="gridRows" class="options-form__input" type="text" value="3">
108111
<label class="options-form__label" for="gridColumnGap">column gap (px, rem, vh vw or %):</label>
@@ -262,20 +265,27 @@ <h3 class="grid-options__title">Here are the basic CSS Grid properties used in t
262265
<section class="bonus-materials">
263266
<h2 class="bonus-materials__title">Additional resources</h2>
264267
<p class="bonus-materials__description">Because CSS Grid is much more robust than shown in this app, I recommend looking at additional resources listed below:</p>
265-
266268
<a class="bonus-materials__link" href="https://cssgrid.io/" rel="noopener" target="_blank" title="">Wes Bos CSS Grid Course (Free!)</a>
267269
<a class="bonus-materials__link" href="https://css-tricks.com/snippets/css/complete-guide-grid/" rel="noopener" target="_blank" title="">CSS Tricks - A Complete Guide to Grid</a>
268270
<a class="bonus-materials__link" href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout" rel="noopener" target="_blank" title="">MDN - CSS Grid Layout</a>
269271
<a class="bonus-materials__link" href="https://www.youtube.com/watch?v=7kVeCqQCxlk" rel="noopener" target="_blank" title="">[VIDEO] CSS Grid Changes EVERYTHING - Morten Rand-Hendriksen</a>
272+
<a class="bonus-materials__link" href="https://github.com/rachelandrew/gridbugs" rel="noopener" target="_blank" title="">Nice list of known Grid bugs in various browsers.</a>
270273
</section>
271274
<footer id="footer" class="footer">
272275
<p class="footer__text">Built by Michał Grochowski @ <a class="footer__link" href="https://dobrywebdev.pl" rel="noopener" target="_blank">dobrywebdev.pl</a></p>
273276
</footer>
274277
</main>
275-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
276278
<!-- Add new JS files here so gulp-useref can bundle them in one file -->
277279
<!--build:js js/main.min.js -->
278280
<script src="js/main.js"></script>
279281
<!-- endbuild -->
282+
<script async>
283+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
284+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
285+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
286+
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
287+
ga('create', 'UA-87019136-2', 'auto');
288+
ga('send', 'pageview');
289+
</script>
280290
</body>
281291
</html>

0 commit comments

Comments
 (0)