Skip to content

Commit 337f469

Browse files
committed
Added row layout
1 parent 53f3391 commit 337f469

File tree

7 files changed

+141
-26
lines changed

7 files changed

+141
-26
lines changed

src/component/badge/BadgeElement.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11

2-
import { LitElement, html, css } from 'lit';
2+
import { LitElement, html, css, customElement } from 'lit';
33

44
/**
5-
* A badge element
5+
* A badge element class that can be used to display a badge with text or icon.
6+
* For example:
7+
*
8+
* ```html
9+
* <wc-badge backgroundColor="primary" transform="uppercase">New</wc-badge>
10+
* <wc-badge backgroundColor="primary"><wc-icon name="circle"></wc-icon></wc-badge>
11+
* ```
612
*/
713
export class BadgeElement extends LitElement {
14+
static localName = 'wc-badge';
15+
816
constructor() {
917
super();
1018
// Default properties
@@ -99,6 +107,3 @@ export class BadgeElement extends LitElement {
99107
}
100108
}
101109

102-
customElements.define('wc-badge', BadgeElement);
103-
104-

src/component/layout/RowElement.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
import { LitElement, html, css } from 'lit';
3+
4+
/**
5+
* A row element which allows you to create a row with cells, either populating
6+
* the row elements left to right or right to left.
7+
*
8+
* @class
9+
*
10+
* Example:
11+
*
12+
* ```html
13+
* <wc-row ltr>
14+
* <wc-row-6>
15+
* <!-- content goes here -->
16+
* </wc-row-6>
17+
* </wc-row>
18+
* ```
19+
*/
20+
export class RowElement extends LitElement {
21+
static localName = 'wc-row';
22+
23+
constructor() {
24+
super();
25+
}
26+
static get styles() {
27+
return css``;
28+
}
29+
render() {
30+
return html`
31+
<div class="row"><slot></slot></div>
32+
`;
33+
}
34+
}

src/component/spacer/SpacerElement.js src/component/layout/SpacerElement.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,29 @@ import { LitElement, html, css } from 'lit';
55
* A vertical spacer element
66
*/
77
export class SpacerElement extends LitElement {
8+
static localName = 'wc-spacer';
9+
810
constructor() {
911
super();
1012

1113
// Default properties
12-
this.y = 1;
14+
this.v = 1;
1315
}
1416
static get properties() {
1517
return {
1618
/**
17-
* Y space (0-6)
18-
* @type {Number}
19+
* Vertical spacer: 0, 1, 2, 3, 4, 5, 6 which defaults to 1 space element
20+
*
21+
* @type Number
22+
* @memberof SpacerElement
23+
*
24+
* Example:
25+
*
26+
* ```html
27+
* <wc-spacer v="3"></wc-spacer>
28+
* ```
1929
*/
20-
y: { type: Number },
30+
v: { type: Number },
2131
};
2232
}
2333

@@ -48,9 +58,7 @@ export class SpacerElement extends LitElement {
4858
}
4959
render() {
5060
return html`
51-
<div class="m-${this.y}"></div>
61+
<div class="m-${this.v}"></div>
5262
`;
5363
}
5464
}
55-
56-
customElements.define('wc-spacer', SpacerElement);
File renamed without changes.

src/index.html

+70
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,76 @@ <h1>Form</h1>
123123
</div>
124124
<hr>
125125

126+
127+
<div class="container">
128+
<h1>Row Layout</h1>
129+
130+
<h3>Two Columns</h3>
131+
<wc-row> <!-- 1, 2, 3, 4, 6, 9 and 12 are defined -->
132+
<wc-row-6>
133+
Left Hand Side
134+
</wc-row-6>
135+
<wc-row-6>
136+
Right Hand Side
137+
</wc-row-6>
138+
</wc-row>
139+
<hr/>
140+
141+
<h3>Three Columns</h3>
142+
<wc-row> <!-- 1, 2, 3, 4, 6, 9 and 12 are defined -->
143+
<wc-row-4>
144+
Left
145+
</wc-row-4>
146+
<wc-row-4>
147+
Middle
148+
</wc-row-4>
149+
<wc-row-4>
150+
Right
151+
</wc-row-4>
152+
</wc-row>
153+
<hr/>
154+
155+
<h2>Four Columns</h2>
156+
<wc-row> <!-- 1, 2, 3, 4, 6, 9 and 12 are defined -->
157+
<wc-row-3>
158+
Col 1
159+
</wc-row-3>
160+
<wc-row-3>
161+
Col 2
162+
</wc-row-3>
163+
<wc-row-3>
164+
Col 3
165+
</wc-row-3>
166+
<wc-row-3>
167+
Col 4
168+
</wc-row-3>
169+
</wc-row>
170+
<hr/>
171+
172+
<h2>Six Columns</h2>
173+
<wc-row> <!-- 1, 2, 3, 4, 6, 9 and 12 are defined -->
174+
<wc-row-2>
175+
Col 1
176+
</wc-row-2>
177+
<wc-row-2>
178+
Col 2
179+
</wc-row-2>
180+
<wc-row-2>
181+
Col 3
182+
</wc-row-2>
183+
<wc-row-3>
184+
Col 4
185+
</wc-row-2>
186+
<wc-row-3>
187+
Col 5
188+
</wc-row-2>
189+
<wc-row-3>
190+
Col 6
191+
</wc-row-2>
192+
</wc-row>
193+
<hr/>
194+
195+
</div>
126196
</body>
127197

128198
</html>

src/index.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import './component/button/CloseButtonElement';
1414
import './component/badge/BadgeElement';
1515
import './component/badge/BadgeGroupElement';
1616

17+
customElements.define(BadgeElement.localName, BadgeElement); // wc-badge
18+
19+
1720
// Icons
1821
import './component/icon/IconElement';
1922

@@ -30,13 +33,19 @@ import './component/form/FormElement';
3033
import './component/form/FormTextElement';
3134
import './component/form/FormDateElement';
3235

33-
// Scaffold Elements
34-
import './component/spacer/SpacerElement';
36+
// Layout Elements
37+
import './component/layout/SpacerElement.js';
38+
import './component/layout/RowElement.js';
39+
40+
customElements.define(SpacerElement.localName, SpacerElement); // wc-spacer
41+
customElements.define(RowElement.localName, RowElement); // wc-row
3542

3643
// CSS
3744
import './css/core.css';
3845
import './css/document.css';
3946

4047
// Other
4148
import './esbuild.js';
42-
import './test.js';
49+
import './test.js';import { BadgeElement } from './component/badge/BadgeElement';
50+
import { SpacerElement } from './component/layout/SpacerElement.js';
51+

src/test.js

-11
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
// Core
44
import Provider from './core/Provider';
55
import Event from './core/Event';
6-
import { Model } from './core/Model';
7-
8-
// Create a model
9-
10-
class MyModel extends Model {
11-
12-
}
136

147
// Test
158
window.addEventListener('load', () => {
@@ -76,8 +69,4 @@ window.addEventListener('load', () => {
7669
}
7770
});
7871
});
79-
80-
// Print out model
81-
var model = new MyModel({ name: "John Doe", age: 21});
82-
console.log("" + model);
8372
});

0 commit comments

Comments
 (0)