unit.gl 0.0.40 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/css/unit.gl.css +54 -42
- package/css/unit.gl.min.css +1 -1
- package/package.json +2 -22
- package/scss/_reset.scss +20 -12
- package/scss/classes/_guide.scss +35 -40
- package/scss/classes/_guides.scss +141 -0
- package/scss/classes/_index.scss +3 -5
- package/scss/classes/_ratio.scss +3 -5
- package/scss/dev/_banner.scss +4 -7
- package/scss/dev/_index.scss +7 -0
- package/scss/functions/_color.scss +8 -11
- package/scss/functions/_index.scss +18 -11
- package/scss/functions/_layer.scss +6 -10
- package/scss/functions/_ratio.scss +13 -16
- package/scss/functions/_scale.scss +20 -18
- package/scss/functions/_sequence.scss +64 -72
- package/scss/functions/_view.scss +6 -9
- package/scss/functions/math/_arithmetic.scss +21 -30
- package/scss/functions/math/_index.scss +4 -7
- package/scss/functions/unit/_index.scss +8 -7
- package/scss/functions/unit/_unit_conversion.scss +42 -29
- package/scss/functions/unit/_unit_functions.scss +55 -43
- package/scss/index.scss +0 -1
- package/scss/maps/_color.scss +14 -14
- package/scss/maps/_index.scss +26 -0
- package/scss/mixins/_device.scss +9 -10
- package/scss/mixins/_display.scss +52 -57
- package/scss/mixins/_guide.scss +59 -81
- package/scss/mixins/_helper.scss +74 -92
- package/scss/mixins/_index.scss +12 -14
- package/scss/mixins/_paper.scss +10 -11
- package/scss/mixins/_ratio.scss +172 -76
- package/scss/mixins/_unit.scss +33 -23
- package/scss/mixins/_view.scss +47 -54
- package/scss/{_global.scss → tags/_global.scss} +12 -11
- package/scss/tags/_index.scss +5 -6
- package/scss/tags/_unit.scss +4 -11
- package/scss/variables/_color.scss +18 -20
- package/scss/variables/_device.scss +179 -73
- package/scss/variables/_index.scss +21 -22
- package/scss/variables/_layer.scss +26 -35
- package/scss/variables/_paper.scss +1022 -241
- package/scss/variables/_ratio.scss +148 -90
- package/scss/variables/_scale.scss +141 -115
- package/scss/variables/_unit.scss +20 -35
- package/scss/variables/_view.scss +54 -57
- package/ts/AspectRatio.ts +27 -6
- package/ts/Border.ts +35 -4
- package/ts/BoxModel.ts +32 -4
- package/ts/FlexContainer.ts +36 -9
- package/ts/Grid.ts +28 -3
- package/ts/GridContainer.ts +29 -3
- package/ts/Layout.ts +37 -7
- package/ts/Position.ts +29 -4
- package/ts/Rectangle.ts +26 -3
- package/ts/ResponsiveImage.ts +22 -3
- package/ts/ResponsiveScale.ts +25 -2
- package/ts/Size.ts +25 -3
- package/ts/Spacing.ts +45 -7
- package/ts/Transform.ts +37 -4
- package/ts/Typography.ts +40 -6
- package/ts/Unit.ts +34 -10
- package/ts/Viewport.ts +31 -3
- package/ts/index.ts +1 -16
- package/scss/utilities/_guides.scss +0 -103
- package/scss/utilities/_index.scss +0 -6
package/ts/Rectangle.ts
CHANGED
|
@@ -1,15 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import Position from "./Position";
|
|
6
|
+
import Size from "./Size";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Classes
|
|
11
|
+
// ============================================================================
|
|
12
|
+
|
|
13
|
+
export default class Rectangle {
|
|
14
|
+
|
|
15
|
+
// Parameters
|
|
16
|
+
// ========================================================================
|
|
17
|
+
|
|
2
18
|
position: Position;
|
|
3
19
|
size: Size;
|
|
4
20
|
|
|
21
|
+
// Constructor
|
|
22
|
+
// ========================================================================
|
|
23
|
+
|
|
5
24
|
constructor(position: Position, size: Size) {
|
|
6
25
|
if (position.x.unit !== size.width.unit || position.y.unit !== size.height.unit) {
|
|
7
|
-
throw new Error(
|
|
26
|
+
throw new Error("Position and Size units must match");
|
|
8
27
|
}
|
|
9
28
|
this.position = position;
|
|
10
29
|
this.size = size;
|
|
11
30
|
}
|
|
12
31
|
|
|
32
|
+
|
|
33
|
+
// Methods
|
|
34
|
+
// ========================================================================
|
|
35
|
+
|
|
13
36
|
move(newPosition: Position): Rectangle {
|
|
14
37
|
return new Rectangle(newPosition, this.size);
|
|
15
38
|
}
|
|
@@ -25,4 +48,4 @@ class Rectangle {
|
|
|
25
48
|
toString(): string {
|
|
26
49
|
return `Rectangle: Position(${this.position.toString()}), Size(${this.size.toString()})`;
|
|
27
50
|
}
|
|
28
|
-
}
|
|
51
|
+
}
|
package/ts/ResponsiveImage.ts
CHANGED
|
@@ -1,18 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// Classes
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
export default class ResponsiveImage {
|
|
11
|
+
|
|
12
|
+
// Parameters
|
|
13
|
+
// ========================================================================
|
|
14
|
+
|
|
2
15
|
sources: Map<number, string>; // Map of breakpoint to image URL
|
|
3
16
|
altText: string;
|
|
4
17
|
|
|
18
|
+
// Constructor
|
|
19
|
+
// ========================================================================
|
|
20
|
+
|
|
5
21
|
constructor(altText: string) {
|
|
6
22
|
this.sources = new Map<number, string>();
|
|
7
23
|
this.altText = altText;
|
|
8
24
|
}
|
|
9
25
|
|
|
26
|
+
// Methods
|
|
27
|
+
// ========================================================================
|
|
28
|
+
|
|
10
29
|
addSource(breakpoint: number, url: string): void {
|
|
11
30
|
this.sources.set(breakpoint, url);
|
|
12
31
|
}
|
|
13
32
|
|
|
14
33
|
getSource(viewportWidth: number): string {
|
|
15
|
-
let selectedSource =
|
|
34
|
+
let selectedSource = "";
|
|
16
35
|
this.sources.forEach((url, breakpoint) => {
|
|
17
36
|
if (viewportWidth >= breakpoint) {
|
|
18
37
|
selectedSource = url;
|
|
@@ -25,4 +44,4 @@ class ResponsiveImage {
|
|
|
25
44
|
const source = this.getSource(viewportWidth);
|
|
26
45
|
return `<img src="${source}" alt="${this.altText}" />`;
|
|
27
46
|
}
|
|
28
|
-
}
|
|
47
|
+
}
|
package/ts/ResponsiveScale.ts
CHANGED
|
@@ -1,14 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import Unit from "./Unit";
|
|
6
|
+
import Viewport from "./Viewport";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Classes
|
|
11
|
+
// ============================================================================
|
|
12
|
+
|
|
13
|
+
export default class ResponsiveScale {
|
|
14
|
+
|
|
15
|
+
// Parameters
|
|
16
|
+
// ========================================================================
|
|
17
|
+
|
|
2
18
|
viewport: Viewport;
|
|
3
19
|
baseSize: Unit;
|
|
4
20
|
scaleFactor: number;
|
|
5
21
|
|
|
22
|
+
// Constructor
|
|
23
|
+
// ========================================================================
|
|
24
|
+
|
|
6
25
|
constructor(viewport: Viewport, baseSize: Unit, scaleFactor: number) {
|
|
7
26
|
this.viewport = viewport;
|
|
8
27
|
this.baseSize = baseSize;
|
|
9
28
|
this.scaleFactor = scaleFactor;
|
|
10
29
|
}
|
|
11
30
|
|
|
31
|
+
|
|
32
|
+
// Methods
|
|
33
|
+
// ========================================================================
|
|
34
|
+
|
|
12
35
|
calculateResponsiveSize(): Unit {
|
|
13
36
|
const ratio = this.viewport.width.value / 1920; // Assuming 1920px is the base
|
|
14
37
|
const scaledValue = this.baseSize.value * Math.pow(this.scaleFactor, ratio);
|
|
@@ -18,4 +41,4 @@ class ResponsiveScale {
|
|
|
18
41
|
toString(): string {
|
|
19
42
|
return `ResponsiveScale: Base(${this.baseSize.toString()}) ScaleFactor(${this.scaleFactor}) Viewport(${this.viewport.toString()})`;
|
|
20
43
|
}
|
|
21
|
-
}
|
|
44
|
+
}
|
package/ts/Size.ts
CHANGED
|
@@ -1,15 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import Unit from "./Unit";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Classes
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
export default class Size {
|
|
13
|
+
|
|
14
|
+
// Parameters
|
|
15
|
+
// ========================================================================
|
|
16
|
+
|
|
2
17
|
width: Unit;
|
|
3
18
|
height: Unit;
|
|
4
19
|
|
|
20
|
+
// Constructor
|
|
21
|
+
// ========================================================================
|
|
22
|
+
|
|
5
23
|
constructor(width: Unit, height: Unit) {
|
|
6
24
|
if (width.unit !== height.unit) {
|
|
7
|
-
throw new Error(
|
|
25
|
+
throw new Error("Width and height must have the same unit");
|
|
8
26
|
}
|
|
9
27
|
this.width = width;
|
|
10
28
|
this.height = height;
|
|
11
29
|
}
|
|
12
30
|
|
|
31
|
+
// Methods
|
|
32
|
+
// ========================================================================
|
|
33
|
+
|
|
13
34
|
add(other: Size): Size {
|
|
14
35
|
return new Size(this.width.add(other.width), this.height.add(other.height));
|
|
15
36
|
}
|
|
@@ -29,4 +50,5 @@ class Size {
|
|
|
29
50
|
toString(): string {
|
|
30
51
|
return `Size: ${this.width.toString()} x ${this.height.toString()}`;
|
|
31
52
|
}
|
|
32
|
-
|
|
53
|
+
|
|
54
|
+
}
|
package/ts/Spacing.ts
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import { default as Unit, default as UnitType } from "./Unit";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Classes
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
export default class Spacing {
|
|
13
|
+
|
|
14
|
+
// Parameters
|
|
15
|
+
// ========================================================================
|
|
16
|
+
|
|
2
17
|
top: Unit;
|
|
3
18
|
right: Unit;
|
|
4
19
|
bottom: Unit;
|
|
5
20
|
left: Unit;
|
|
6
21
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
22
|
+
// Constructor
|
|
23
|
+
// ========================================================================
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
top: Unit,
|
|
27
|
+
right: Unit,
|
|
28
|
+
bottom: Unit,
|
|
29
|
+
left: Unit
|
|
30
|
+
) {
|
|
31
|
+
if (
|
|
32
|
+
top.unit !== right.unit || top.unit !== bottom.unit || top.unit !== left.unit
|
|
33
|
+
) {
|
|
34
|
+
throw new Error("All sides must have the same unit");
|
|
10
35
|
}
|
|
11
36
|
this.top = top;
|
|
12
37
|
this.right = right;
|
|
@@ -14,6 +39,9 @@ class Spacing {
|
|
|
14
39
|
this.left = left;
|
|
15
40
|
}
|
|
16
41
|
|
|
42
|
+
// Methods
|
|
43
|
+
// ========================================================================
|
|
44
|
+
|
|
17
45
|
add(other: Spacing): Spacing {
|
|
18
46
|
return new Spacing(
|
|
19
47
|
this.top.add(other.top),
|
|
@@ -56,13 +84,23 @@ class Spacing {
|
|
|
56
84
|
}
|
|
57
85
|
|
|
58
86
|
class Margin extends Spacing {
|
|
59
|
-
constructor(
|
|
87
|
+
constructor(
|
|
88
|
+
top: Unit,
|
|
89
|
+
right: Unit,
|
|
90
|
+
bottom: Unit,
|
|
91
|
+
left: Unit,
|
|
92
|
+
) {
|
|
60
93
|
super(top, right, bottom, left);
|
|
61
94
|
}
|
|
62
95
|
}
|
|
63
96
|
|
|
64
97
|
class Padding extends Spacing {
|
|
65
|
-
constructor(
|
|
98
|
+
constructor(
|
|
99
|
+
top: Unit,
|
|
100
|
+
right: Unit,
|
|
101
|
+
bottom: Unit,
|
|
102
|
+
left: Unit,
|
|
103
|
+
) {
|
|
66
104
|
super(top, right, bottom, left);
|
|
67
105
|
}
|
|
68
|
-
}
|
|
106
|
+
}
|
package/ts/Transform.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import Unit from "./Unit";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Types
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
type AngleUnit = "deg" | "rad";
|
|
13
|
+
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Classes
|
|
16
|
+
// ============================================================================
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
export default class Transform {
|
|
20
|
+
|
|
21
|
+
// Parameters
|
|
22
|
+
// ========================================================================
|
|
2
23
|
|
|
3
|
-
class Transform {
|
|
4
24
|
translateX: Unit;
|
|
5
25
|
translateY: Unit;
|
|
6
26
|
rotate: number;
|
|
@@ -8,7 +28,17 @@ class Transform {
|
|
|
8
28
|
scaleX: number;
|
|
9
29
|
scaleY: number;
|
|
10
30
|
|
|
11
|
-
|
|
31
|
+
// Constructor
|
|
32
|
+
// ========================================================================
|
|
33
|
+
|
|
34
|
+
constructor(
|
|
35
|
+
translateX: Unit,
|
|
36
|
+
translateY: Unit,
|
|
37
|
+
rotate: number,
|
|
38
|
+
rotateUnit: AngleUnit,
|
|
39
|
+
scaleX: number,
|
|
40
|
+
scaleY: number
|
|
41
|
+
) {
|
|
12
42
|
this.translateX = translateX;
|
|
13
43
|
this.translateY = translateY;
|
|
14
44
|
this.rotate = rotate;
|
|
@@ -17,6 +47,9 @@ class Transform {
|
|
|
17
47
|
this.scaleY = scaleY;
|
|
18
48
|
}
|
|
19
49
|
|
|
50
|
+
// Methods
|
|
51
|
+
// ========================================================================
|
|
52
|
+
|
|
20
53
|
setTranslation(translateX: Unit, translateY: Unit): void {
|
|
21
54
|
this.translateX = translateX;
|
|
22
55
|
this.translateY = translateY;
|
|
@@ -35,4 +68,4 @@ class Transform {
|
|
|
35
68
|
toString(): string {
|
|
36
69
|
return `Transform: translate(${this.translateX.toString()}, ${this.translateY.toString()}) rotate(${this.rotate}${this.rotateUnit}) scale(${this.scaleX}, ${this.scaleY})`;
|
|
37
70
|
}
|
|
38
|
-
}
|
|
71
|
+
}
|
package/ts/Typography.ts
CHANGED
|
@@ -1,13 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import Unit from "./Unit";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Types
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
type FontWeight = "normal" | "bold" | number;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Classes
|
|
17
|
+
// ============================================================================
|
|
18
|
+
|
|
19
|
+
export default class Typography {
|
|
20
|
+
|
|
21
|
+
// Parameters
|
|
22
|
+
// ========================================================================
|
|
2
23
|
|
|
3
|
-
class Typography {
|
|
4
24
|
fontSize: Unit;
|
|
5
25
|
fontWeight: FontWeight;
|
|
6
26
|
lineHeight: Unit;
|
|
7
27
|
letterSpacing: Unit;
|
|
8
|
-
textAlign:
|
|
28
|
+
textAlign: "left" | "right" | "center" | "justify";
|
|
29
|
+
|
|
30
|
+
// Constructor
|
|
31
|
+
// ========================================================================
|
|
9
32
|
|
|
10
|
-
constructor(
|
|
33
|
+
constructor(
|
|
34
|
+
fontSize: Unit,
|
|
35
|
+
fontWeight: FontWeight = "normal",
|
|
36
|
+
lineHeight: Unit,
|
|
37
|
+
letterSpacing: Unit,
|
|
38
|
+
textAlign: "left" | "right" | "center" | "justify" = "left"
|
|
39
|
+
) {
|
|
11
40
|
this.fontSize = fontSize;
|
|
12
41
|
this.fontWeight = fontWeight;
|
|
13
42
|
this.lineHeight = lineHeight;
|
|
@@ -15,6 +44,10 @@ class Typography {
|
|
|
15
44
|
this.textAlign = textAlign;
|
|
16
45
|
}
|
|
17
46
|
|
|
47
|
+
|
|
48
|
+
// Methods
|
|
49
|
+
// ========================================================================
|
|
50
|
+
|
|
18
51
|
setFontSize(fontSize: Unit): void {
|
|
19
52
|
this.fontSize = fontSize;
|
|
20
53
|
}
|
|
@@ -31,11 +64,12 @@ class Typography {
|
|
|
31
64
|
this.letterSpacing = letterSpacing;
|
|
32
65
|
}
|
|
33
66
|
|
|
34
|
-
setTextAlign(textAlign:
|
|
67
|
+
setTextAlign(textAlign: "left" | "right" | "center" | "justify"): void {
|
|
35
68
|
this.textAlign = textAlign;
|
|
36
69
|
}
|
|
37
70
|
|
|
38
71
|
toString(): string {
|
|
39
72
|
return `Typography: font-size ${this.fontSize.toString()}, weight ${this.fontWeight}, line-height ${this.lineHeight.toString()}, letter-spacing ${this.letterSpacing.toString()}, text-align ${this.textAlign}`;
|
|
40
73
|
}
|
|
41
|
-
|
|
74
|
+
|
|
75
|
+
}
|
package/ts/Unit.ts
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// Types
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
type UnitType = "px" | "em" | "%" | "rem" | "mm" | "cm" | "in";
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Classes
|
|
15
|
+
// ============================================================================
|
|
16
|
+
|
|
17
|
+
export default class Unit {
|
|
18
|
+
|
|
19
|
+
// Parameters
|
|
20
|
+
// ========================================================================
|
|
2
21
|
|
|
3
|
-
class Unit {
|
|
4
22
|
value: number;
|
|
5
23
|
unit: UnitType;
|
|
6
24
|
|
|
25
|
+
// Constructor
|
|
26
|
+
// ========================================================================
|
|
27
|
+
|
|
7
28
|
constructor(value: number, unit: UnitType) {
|
|
8
29
|
this.value = value;
|
|
9
30
|
this.unit = unit;
|
|
10
31
|
}
|
|
11
32
|
|
|
33
|
+
// Methods
|
|
34
|
+
// ========================================================================
|
|
35
|
+
|
|
12
36
|
add(other: Unit): Unit {
|
|
13
37
|
if (this.unit !== other.unit) {
|
|
14
38
|
throw new Error(`Cannot add units of different types: ${this.unit} and ${other.unit}`);
|
|
@@ -34,13 +58,13 @@ class Unit {
|
|
|
34
58
|
convert(toUnit: UnitType): Unit {
|
|
35
59
|
// Example conversion: assumes 1in = 96px, 1cm = 37.7953px, etc.
|
|
36
60
|
const conversionRates: { [key in UnitType]?: number } = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
61
|
+
"px": 1,
|
|
62
|
+
"em": 16,
|
|
63
|
+
"rem": 16,
|
|
64
|
+
"in": 96,
|
|
65
|
+
"cm": 37.7953,
|
|
66
|
+
"mm": 3.77953,
|
|
67
|
+
"%": 1 // Conversion for percentages might be contextual
|
|
44
68
|
};
|
|
45
69
|
|
|
46
70
|
if (!conversionRates[this.unit] || !conversionRates[toUnit]) {
|
|
@@ -54,4 +78,4 @@ class Unit {
|
|
|
54
78
|
toString(): string {
|
|
55
79
|
return `${this.value}${this.unit}`;
|
|
56
80
|
}
|
|
57
|
-
}
|
|
81
|
+
}
|
package/ts/Viewport.ts
CHANGED
|
@@ -1,14 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import Unit from "./Unit";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Classes
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
export default class Viewport {
|
|
13
|
+
|
|
14
|
+
// Parameters
|
|
15
|
+
// ========================================================================
|
|
16
|
+
|
|
2
17
|
width: Unit;
|
|
3
18
|
height: Unit;
|
|
4
19
|
pixelRatio: number;
|
|
5
20
|
|
|
6
|
-
|
|
21
|
+
|
|
22
|
+
// Constructor
|
|
23
|
+
// ========================================================================
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
width: Unit,
|
|
27
|
+
height: Unit,
|
|
28
|
+
pixelRatio: number = 1,
|
|
29
|
+
) {
|
|
7
30
|
this.width = width;
|
|
8
31
|
this.height = height;
|
|
9
32
|
this.pixelRatio = pixelRatio;
|
|
10
33
|
}
|
|
11
34
|
|
|
35
|
+
|
|
36
|
+
// Methods
|
|
37
|
+
// ========================================================================
|
|
38
|
+
|
|
12
39
|
resize(newWidth: Unit, newHeight: Unit): void {
|
|
13
40
|
this.width = newWidth;
|
|
14
41
|
this.height = newHeight;
|
|
@@ -21,4 +48,5 @@ class Viewport {
|
|
|
21
48
|
toString(): string {
|
|
22
49
|
return `Viewport: ${this.width.toString()} x ${this.height.toString()} @ ${this.pixelRatio}x pixel ratio`;
|
|
23
50
|
}
|
|
24
|
-
|
|
51
|
+
|
|
52
|
+
}
|
package/ts/index.ts
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export {};
|
|
1
|
+
export { };
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
@use "../dev" as *;
|
|
2
|
-
@use "../variables" as *;
|
|
3
|
-
@use "../mixins" as *;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// ============================================================================
|
|
7
|
-
// Utilities | Guides
|
|
8
|
-
// ============================================================================
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.guide { @include guide; }
|
|
12
|
-
|
|
13
|
-
@mixin guide_graph {
|
|
14
|
-
@include guide;
|
|
15
|
-
background-size: 4*$q 4*$q;
|
|
16
|
-
background-image:
|
|
17
|
-
repeating-linear-gradient(rgb(66, 61, 61) 0 1px, transparent 1px 100%),
|
|
18
|
-
repeating-linear-gradient(90deg,rgb(66, 61, 61) 0 1px, transparent 1px 100%);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.guide_graph { @include guide_graph; }
|
|
22
|
-
|
|
23
|
-
@mixin guide_baseline {
|
|
24
|
-
@include guide;
|
|
25
|
-
// background: repeating-linear-gradient(#e66465, #e66465 20px, #9198e5 20px, #9198e5 25px);
|
|
26
|
-
// background: repeating-linear-gradient(transparent, transparent 20px, transparent 20px, transparent 25px);
|
|
27
|
-
// background-repeat: repeat-y;
|
|
28
|
-
background-repeat: repeat;
|
|
29
|
-
|
|
30
|
-
background-size: map-get($baseline, 4) map-get($baseline, 4);
|
|
31
|
-
@include guide;
|
|
32
|
-
background-image:
|
|
33
|
-
repeating-linear-gradient(cyan 0 1px, transparent 1px 100%);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.guide_baseline { @include guide_baseline; }
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.baseline-grid {
|
|
40
|
-
@include guide;
|
|
41
|
-
|
|
42
|
-
background-image:
|
|
43
|
-
// -webkit-linear-gradient(0deg, rgba(200,0,0,.2) 40px, transparent 40px),
|
|
44
|
-
-webkit-linear-gradient(top, rgba(0,0,0,0) 95%, rgba(56,255,255,.8) 100%);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
background-image:
|
|
48
|
-
// -moz-linear-gradient(0deg, rgba(200,0,0,.2) 40px, transparent 40px),
|
|
49
|
-
-moz-linear-gradient(top, rgba(0,0,0,0) 95%, rgba(56,255,255,.8) 100%);
|
|
50
|
-
background-image:
|
|
51
|
-
// -o-linear-gradient(0deg, rgba(200,0,0,.2) 40px, transparent 40px),
|
|
52
|
-
-o-linear-gradient(top, rgba(0,0,0,0) 95%, rgba(56,255,255,.8) 100%);
|
|
53
|
-
|
|
54
|
-
background-size: 100% 100%, 100% 100%;
|
|
55
|
-
// background-size: 60px 100%, 100% 22px;
|
|
56
|
-
// background-position: 10px 0px;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// .guide_graph {
|
|
62
|
-
// @include guide;
|
|
63
|
-
// background-image:
|
|
64
|
-
// repeating-linear-gradient(#ccc 0 1px, transparent 1px 100%),
|
|
65
|
-
// repeating-linear-gradient(90deg, #ccc 0 1px, transparent 1px 100%);
|
|
66
|
-
// }
|
|
67
|
-
|
|
68
|
-
// .guide_baseline {
|
|
69
|
-
// @include guide;
|
|
70
|
-
// background-image:
|
|
71
|
-
// repeating-linear-gradient(cyan 0 2px, transparent 2px 100%);
|
|
72
|
-
// }
|
|
73
|
-
|
|
74
|
-
.page {
|
|
75
|
-
border: $q*2 solid red;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
$body-width: 960px;
|
|
80
|
-
$baseline: 22px;
|
|
81
|
-
@mixin baseline-grid {
|
|
82
|
-
$columns: 16;
|
|
83
|
-
$column-color: rgba(200,0,0,.2);
|
|
84
|
-
$baseline-color: rgba(56,255,255,.8);
|
|
85
|
-
|
|
86
|
-
// These are all automatically calculated
|
|
87
|
-
$gutter-width: 20px; // Change if you like
|
|
88
|
-
$gutters: ($columns - 1);
|
|
89
|
-
$column-width: calc($body-width / $columns);
|
|
90
|
-
|
|
91
|
-
background-image: -webkit-linear-gradient(0deg, $column-color $column-width, transparent $gutter-width),
|
|
92
|
-
-webkit-linear-gradient(top, rgba(0,0,0,0) 95%, $baseline-color 100%);
|
|
93
|
-
background-image: -moz-linear-gradient(0deg, $column-color $column-width, transparent $gutter-width),
|
|
94
|
-
-moz-linear-gradient(top, rgba(0,0,0,0) 95%, $baseline-color 100%);
|
|
95
|
-
background-image: -o-linear-gradient(0deg, $column-color $column-width, transparent $gutter-width),
|
|
96
|
-
-o-linear-gradient(top, rgba(0,0,0,0) 95%, $baseline-color 100%);
|
|
97
|
-
background-size: ($column-width + $gutter-width) 100%, 100% $baseline;
|
|
98
|
-
background-position: 10px 0px; // Use to offset and center your grid
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Example call
|
|
102
|
-
.baseline-grid {
|
|
103
|
-
}
|