You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pinwheel/templates/readme.md
+29-14Lines changed: 29 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,11 @@
1
-
Pinwheel’s [exporting](/help/pinwheel/exporting/) supports a wide range of common formats. If you need a format we don’t support, a custom template can be used.
1
+
Pinwheel’s [exporting](https://bjango.com/help/pinwheel/exporting/) supports a wide range of common formats. If you need a format we don’t support, a custom template can be used.
2
2
3
-
Custom templates use the [Stencil template language](https://stencil.fuller.li/en/latest/templates.html).
3
+
Custom templates use the [Stencil template language](https://stencil.fuller.li/en/latest/templates.html). Most of Pinwheel’s built-in exporting uses Stencil templates, and are available in our [Bjango DevKit GitHub repository](https://github.com/bjango/Bjango-DevKit/tree/main/pinwheel/templates/Pinwheel%20Built%20In%20Examples). Feel free to use them as the basis of your own templates, or to learn how templates work.
4
4
5
-
The data structure availble in templates is a list of `items` at the top level. There is also a `exportFileName` item that corresponds to the file name in the build task. You can iterate through all the items like this:
5
+
6
+
### Main structure
7
+
8
+
The data structure available in templates is a list of `items` at the top level. There is also a `exportFileName` item that corresponds to the file name in the build task. You can iterate through all the items like this:
6
9
7
10
```
8
11
{% for item in items %}
@@ -20,6 +23,9 @@ And, if you wanted to see if it is a number, you'd use:
20
23
{% if item.number %}
21
24
```
22
25
26
+
27
+
### Appearance, contrast, and color formatters
28
+
23
29
A `colorItem` has a `color` which can have `light`, `dark`, `highContrast` and `darkHighContrast` appearances. If a color has no appearances, then only the `light` value will be set. You can access it like this:
24
30
25
31
```
@@ -29,20 +35,20 @@ A `colorItem` has a `color` which can have `light`, `dark`, `highContrast` and `
29
35
The formatter above is a custom tag. There are lots of format options available for colors. They correspond to all the formats you can use in the Pinwheel color picker:
30
36
31
37
```
32
-
colorAsFloatRGBA,
38
+
colorAsFloatRGBA,
33
39
colorAsFloatHSVA,
34
-
colorAsCSSHexRGB,
35
-
colorAsCSSRgb,
36
-
colorAsCSSColor,
40
+
colorAsCSSHexRGB,
41
+
colorAsCSSRgb,
42
+
colorAsCSSColor,
37
43
colorAsCSSOklch,
38
-
colorAsHex,
39
-
colorAsHexRGBA,
44
+
colorAsHex,
45
+
colorAsHexRGBA,
40
46
colorAsHexARGB,
41
-
colorAsSwiftUIColor,
42
-
colorAsSwiftUIKitColor,
43
-
colorAsSwiftAppKitColor,
44
-
colorAsSwiftUIColorHSBA,
45
-
colorAsSwiftUIKitColorHSBA,
47
+
colorAsSwiftUIColor,
48
+
colorAsSwiftUIKitColor,
49
+
colorAsSwiftAppKitColor,
50
+
colorAsSwiftUIColorHSBA,
51
+
colorAsSwiftUIKitColorHSBA,
46
52
colorAsSwiftAppKitColorHSBA
47
53
```
48
54
@@ -55,6 +61,9 @@ There are 3 parameters to this formatter, the first two are required, the last i
55
61
2. The dark color you want to use
56
62
3. The CSS format you want these colors to be output in. This can be `cssHex` (eg: `#FFFFFF`), `cssRgb` (eg: `rgb(255, 255, 255)`), `cssColor` (eg: `color(srgb 1 1 1)`) or `cssOKLCH` (eg: `oklch(100.0% 0.0 89.9 / 1.0)`). If none is specified `cssColor` will be used.
57
63
64
+
65
+
### Code safe names
66
+
58
67
There is also a formatter for creating safe variable names in most programming languages (things like making sure it doesn't start with a number, removing spaces, etc):
59
68
```
60
69
codeSafeName
@@ -74,6 +83,9 @@ You can combine multiple formatters, for example say you wanted to create a Swif
74
83
let {%+ codeSafeName color.name +%} = {%+ colorAsSwiftUIColor color.light +%}
75
84
```
76
85
86
+
87
+
### Numbers, strings, and booleans
88
+
77
89
For `number`, `string` and `boolean` types you can access the `value` of each in a similar way:
78
90
79
91
```
@@ -97,6 +109,9 @@ This item is called Green.
97
109
This item is called Important.
98
110
```
99
111
112
+
113
+
### Full example
114
+
100
115
The full data structure is below for the technically minded:
0 commit comments