forked from 1000ch/grd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
153 lines (134 loc) · 5.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<title>Grd - A CSS grid framework using Flexbox</title>
<link rel="stylesheet" href="https://1000ch.github.io/gh-pages.css/gh-pages.css">
<link rel="stylesheet" href="grd.min.css">
<!-- Place this tag in your head or just before your close body tag. -->
<script defer src="https://buttons.github.io/buttons.js"></script>
<script defer src="https://unpkg.com/github-corner"></script>
<script type="module">
import XMarked from 'https://unpkg.com/x-marked';
customElements.define('x-marked', XMarked);
document.addEventListener('DOMContentLoaded', () => {
const grid = document.querySelector('#grid');
const align = document.querySelector('#align-items');
const justify = document.querySelector('#justify-content');
function onGridChange() {
grid.className = `Grid ${align.value} ${justify.value}`;
}
align.addEventListener('change', onGridChange);
justify.addEventListener('change', onGridChange);
const template = document.querySelector('#template-cell');
const addCell = document.querySelector('#add');
const removeCell = document.querySelector('#remove');
addCell.addEventListener('click', () => {
const cell = document.importNode(template.content, true);
const select = cell.querySelector('select');
grid.appendChild(cell);
select.addEventListener('change', () => {
select.parentNode.className = `Cell ${select.value}`;
});
});
removeCell.addEventListener('click', () => {
if (grid.children.length) {
grid.children[grid.children.length - 1].remove();
}
});
addCell.click();
addCell.click();
});
window.addEventListener('load', () => {
const xmarked = document.querySelector('x-marked');
const div = document.querySelector('div');
const h2 = xmarked.shadowRoot.querySelector('h2');
xmarked.shadowRoot.querySelector('div').insertBefore(div, h2);
});
</script>
</head>
<body>
<div>
<!-- Place this tag where you want the button to render. -->
<a class="github-button" href="https://github.com/1000ch/grd" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star 1000ch/grd on GitHub">Star</a>
<!-- Place this tag where you want the button to render. -->
<a class="github-button" href="https://github.com/1000ch" data-size="large" data-show-count="true" aria-label="Follow @1000ch on GitHub">Follow @1000ch</a>
</div>
<github-corner>
<a href="https://github.com/1000ch/grd">GitHub</a>
</github-corner>
<x-marked highlight class="container">
# grd ![""](https://badge-size.herokuapp.com/1000ch/grd/main/grd.min.css.svg?compression=gzip)
![""](./logo.png)
A CSS grid framework using Flexbox.
- **Simple**: Provides just 2 base classes `Grid` and `Cell` and some modifiers.
- **Light-weight**: Only 321 bytes (Gzipped).
- **Flexible**: Easy to use Flexbox features.
[Flexible Box Layout Module](http://caniuse.com/#search=flex) and [`calc()` as CSS unit value](http://caniuse.com/#search=calc) used in Grd are available on modern browsers (Chrome, Firefox, Safari, Opera, Edge and IE11).
If you want to use Grd with Sass, you can choose [grd-sass](https://github.com/1000ch/grd-sass) as Sass port.
## Install
```bash
npm install grd
```
## Usage
```html
<div class="Grid">
<div class="Cell -3of12">3of12</div>
<div class="Cell -9of12">9of12</div>
</div>
```
## License
[MIT](https://1000ch.mit-license.org) © [Shogo Sensui](https://github.com/1000ch)
</x-marked>
<div class="container">
<h2>Demo</h2>
<div style="margin-bottom: 16px;">
<div class="Grid <select id="align-items">
<option value="" selected>-</option>
<option value="-top">-top</option>
<option value="-middle">-middle</option>
<option value="-bottom">-bottom</option>
<option value="-stretch">-stretch</option>
<option value="-baseline">-baseline</option>
</select>
<select id="justify-content">
<option value="" selected>-</option>
<option value="-left">-left</option>
<option value="-center">-center</option>
<option value="-right">-right</option>
<option value="-between">-between</option>
<option value="-around">-around</option>
</select>">
</div>
<div class="Grid" id="grid" style="min-height: 240px;"></div>
<div style="margin-top: 16px;">
</div>
<button id="add" class="btn" type="button">Add a cell</button>
<button id="remove" class="btn" type="button">Remove a cell</button>
</div>
<template id="template-cell">
<div class="Cell" style="padding: 16px; border: 1px dashed #999;">
<div class="Cell <select class="select-sm">
<option value="" selected>-</option>
<option value="-fill">-fill</option>
<option value="-1of12">-1of12</option>
<option value="-2of12">-2of12</option>
<option value="-3of12">-3of12</option>
<option value="-4of12">-4of12</option>
<option value="-5of12">-5of12</option>
<option value="-6of12">-6of12</option>
<option value="-7of12">-7of12</option>
<option value="-8of12">-8of12</option>
<option value="-9of12">-9of12</option>
<option value="-10of12">-10of12</option>
<option value="-11of12">-11of12</option>
<option value="-12of12">-12of12</option>
</select>">
<p contenteditable="true">(click to edit)</p>
</div>
</div>
</template>
</div>
</body>
</html>