nemcss 0.2.1 → 0.5.0

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 CHANGED
@@ -31,6 +31,7 @@ Run `nemcss init` to scaffold a `nemcss.config.json` and example token files, th
31
31
  | `nemcss init` | Scaffold `nemcss.config.json` and example token files in the current directory |
32
32
  | `nemcss build -i <input> -o <output>` | One-shot build: scan content files and write CSS |
33
33
  | `nemcss watch -i <input> -o <output>` | Watch mode: rebuild on token, content, or config changes |
34
+ | `nemcss schema` | Print the JSON schema for `nemcss.config.json` to stdout |
34
35
 
35
36
  ## Configuration
36
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nemcss",
3
- "version": "0.2.1",
3
+ "version": "0.5.0",
4
4
  "description": "Command-line interface for nemcss, a design-token-driven CSS utility generator",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -27,10 +27,10 @@
27
27
  "schemas"
28
28
  ],
29
29
  "optionalDependencies": {
30
- "@nemcss/cli-darwin-arm64": "0.2.1",
31
- "@nemcss/cli-darwin-x64": "0.2.1",
32
- "@nemcss/cli-linux-x64": "0.2.1",
33
- "@nemcss/cli-linux-arm64": "0.2.1",
34
- "@nemcss/cli-win32-x64": "0.2.1"
30
+ "@nemcss/cli-darwin-arm64": "0.5.0",
31
+ "@nemcss/cli-darwin-x64": "0.5.0",
32
+ "@nemcss/cli-linux-x64": "0.5.0",
33
+ "@nemcss/cli-linux-arm64": "0.5.0",
34
+ "@nemcss/cli-win32-x64": "0.5.0"
35
35
  }
36
36
  }
@@ -1,138 +1,134 @@
1
1
  {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "title": "NemCSS Configuration",
4
- "description": "Configuration file for the NemCSS utility CSS generator",
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "NemCssConfig",
4
+ "description": "NemCssConfig represents the configuration of the NemCSS util.\nIt contains the paths to the content files and the design tokens, as well as the theme configuration.",
5
5
  "type": "object",
6
6
  "properties": {
7
7
  "content": {
8
+ "description": "Vector of glob patterns to determine which content files to target.\nContent files will be used to determine which CSS classes to generate.",
8
9
  "type": "array",
9
- "items": { "type": "string" },
10
- "description": "Glob patterns for content files to scan for used classes",
11
- "examples": [["src/**/*.html", "src/**/*.tsx"]]
10
+ "items": {
11
+ "type": "string"
12
+ }
12
13
  },
13
- "tokensDir": {
14
- "type": "string",
15
- "default": "design-tokens",
16
- "description": "Directory containing design token JSON files"
14
+ "semantic": {
15
+ "description": "Semantic tokens",
16
+ "anyOf": [
17
+ {
18
+ "$ref": "#/$defs/SemanticConfig"
19
+ },
20
+ {
21
+ "type": "null"
22
+ }
23
+ ]
17
24
  },
18
25
  "theme": {
19
- "type": "object",
20
- "description": "Primitive design token sources. Each key is a token group name.",
21
- "defaultSnippets": [
26
+ "description": "Theme configuration.",
27
+ "anyOf": [
22
28
  {
23
- "label": "Token group",
24
- "description": "Add a token group, e.g colors or spacings",
25
- "body": {
26
- "${1:groupName}": {
27
- "source": "${2:design-tokens/tokens.json}",
28
- "prefix": "${3:prefix}"
29
- }
30
- }
29
+ "$ref": "#/$defs/ThemeConfig"
30
+ },
31
+ {
32
+ "type": "null"
31
33
  }
32
- ],
34
+ ]
35
+ },
36
+ "tokensDir": {
37
+ "description": "Path to directory containing the design tokens.",
38
+ "type": "string",
39
+ "default": "design-tokens"
40
+ }
41
+ },
42
+ "additionalProperties": false,
43
+ "required": [
44
+ "content"
45
+ ],
46
+ "$defs": {
47
+ "SemanticConfig": {
48
+ "description": "The semantic config enables the creation of groups of semantic tokens (e.g. for \"text\",\n\"background\") with their own configuration (e.g. the CSS property they target and the tokens\nthey use)",
49
+ "type": "object",
33
50
  "additionalProperties": {
34
- "type": "object",
35
- "required": ["source"],
36
- "defaultSnippets": [
37
- {
38
- "label": "Token group config",
39
- "body": {
40
- "source": "${1:design-tokens/tokens.json}",
41
- "prefix": "${2:prefix}"
42
- }
43
- }
44
- ],
45
- "properties": {
46
- "source": {
47
- "type": "string",
48
- "description": "Path to the token JSON file, relative to nemcss.config.json"
49
- },
50
- "prefix": {
51
- "type": "string",
52
- "description": "CSS custom property prefix for this token group"
53
- },
54
- "utilities": {
55
- "type": "array",
56
- "description": "Utility classes to generate for every token in this group",
57
- "items": {
58
- "type": "object",
59
- "required": ["prefix", "property"],
60
- "defaultSnippets": [
61
- {
62
- "label": "Utility",
63
- "body": {
64
- "prefix": "${1:p}",
65
- "property": "${2:padding}"
66
- }
67
- }
68
- ],
69
- "properties": {
70
- "prefix": {
71
- "type": "string",
72
- "description": "CSS class prefix for this utility",
73
- "minLength": 1
74
- },
75
- "property": {
76
- "type": "string",
77
- "description": "CSS property to set",
78
- "minLength": 1
79
- }
80
- },
81
- "additionalProperties": false
82
- }
83
- }
84
- },
85
- "additionalProperties": false
51
+ "$ref": "#/$defs/SemanticGroupConfig"
86
52
  }
87
53
  },
88
- "semantic": {
54
+ "SemanticGroupConfig": {
55
+ "description": "A single semantic token config",
89
56
  "type": "object",
90
- "description": "Semantic token groups. Each key becomes both a CSS custom property prefix and a utility class prefix.",
91
- "defaultSnippets": [
92
- {
93
- "label": "Semantic group",
94
- "description": "Add a semantic group, e.g text, bg or border",
95
- "body": {
96
- "${1:groupName}": {
97
- "property": "${2:color}",
98
- "tokens": {
99
- "${3:tokenName}": "{${4:colors}.${5:variant}}"
100
- }
101
- }
57
+ "properties": {
58
+ "property": {
59
+ "description": "CSS property this group targets (e.g. \"color\", \"background-color\")",
60
+ "type": "string",
61
+ "minLength": 1
62
+ },
63
+ "tokens": {
64
+ "description": "Mapping between a semantic name and an existing design token value\ne.g. \"primary\" -> \"{colors.blue-800}\"",
65
+ "type": "object",
66
+ "additionalProperties": {
67
+ "type": "string"
102
68
  }
103
69
  }
104
- ],
70
+ },
71
+ "required": [
72
+ "property",
73
+ "tokens"
74
+ ]
75
+ },
76
+ "ThemeConfig": {
77
+ "description": "ThemeConfig represents the configuration of the theme.\nIt contains the design tokens configuration per token type.",
78
+ "type": "object",
105
79
  "additionalProperties": {
106
- "type": "object",
107
- "required": ["property", "tokens"],
108
- "defaultSnippets": [
109
- {
110
- "label": "Semantic group config",
111
- "body": {
112
- "property": "${1:color}",
113
- "tokens": {
114
- "${2:tokenName}": "{${3:colors}.${4:variant}}"
115
- }
116
- }
117
- }
118
- ],
119
- "properties": {
120
- "property": {
121
- "type": "string",
122
- "description": "CSS property for this utility group",
123
- "minLength": 1
124
- },
125
- "tokens": {
126
- "type": "object",
127
- "description": "Semantic name to primitive token reference. Each entry generates a CSS custom property and a utility class.",
128
- "additionalProperties": {
129
- "type": "string",
130
- "pattern": "^\\{[^.{}]+\\.[^.{}]+\\}$"
131
- }
80
+ "$ref": "#/$defs/TokenConfig"
81
+ }
82
+ },
83
+ "TokenConfig": {
84
+ "description": "TokenConfig represents the configuration of a single design token.\nYou can override the default configuration by specifying the source, prefix, and utilities.\n\n# Examples\n\nIn your `nemcss.config.json`:\n\n```json\n{\n \"theme\": {\n \"colors\": {\n \"source\": \"design-tokens/colors.json\",\n \"prefix\": \"color\",\n \"utilities\": [\n {\n \"prefix\": \"highlight\",\n \"property\": \"background-color\"\n }\n ]\n }\n\n }\n}\n```\n\nWith a token variant \"primary\" in colors.json, this generates:\n- CSS custom property: `--color-primary`\n- Utility class: `.highlight-primary { background-color: var(--color-primary); }`",
85
+ "type": "object",
86
+ "properties": {
87
+ "prefix": {
88
+ "description": "The token prefix is used to generate the custom properties for the given token.\nFor example, if prefix is \"color\", the token prefix will be \"color-\".\nIf the color tokens include a \"primary\" variant, the custom property generated will be\n\"--color-primary\".",
89
+ "type": [
90
+ "string",
91
+ "null"
92
+ ]
93
+ },
94
+ "source": {
95
+ "description": "Path to the tokens file.\nIt will make it possible to override the default configuration for a given token.",
96
+ "type": "string"
97
+ },
98
+ "utilities": {
99
+ "description": "Utilities are used to generate utility classes for the given token.",
100
+ "type": [
101
+ "array",
102
+ "null"
103
+ ],
104
+ "items": {
105
+ "$ref": "#/$defs/TokenUtilityConfig"
132
106
  }
107
+ }
108
+ },
109
+ "required": [
110
+ "source"
111
+ ]
112
+ },
113
+ "TokenUtilityConfig": {
114
+ "description": "TokenUtilityConfig represents the configuration of a utility class for a given token.",
115
+ "type": "object",
116
+ "properties": {
117
+ "prefix": {
118
+ "description": "The prefix that will be used to generate the utility class.\nFor example, if the prefix is \"bg\", the utility class will be \"bg-[TOKEN VARIANT]\".",
119
+ "type": "string",
120
+ "minLength": 1
133
121
  },
134
- "additionalProperties": false
135
- }
122
+ "property": {
123
+ "description": "The CSS property that will use the design token value.",
124
+ "type": "string",
125
+ "minLength": 1
126
+ }
127
+ },
128
+ "required": [
129
+ "prefix",
130
+ "property"
131
+ ]
136
132
  }
137
133
  }
138
134
  }