Skip to content

Commit 2b8753f

Browse files
committed
Introduce glimmer-local-class-transform package
1 parent d0b8742 commit 2b8753f

File tree

11 files changed

+877
-0
lines changed

11 files changed

+877
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"plugins": ["prettier"],
3+
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
4+
"env": {
5+
"node": true
6+
},
7+
"parserOptions": {
8+
"ecmaVersion": "latest",
9+
"sourceType": "module"
10+
}
11+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"printWidth": 100
4+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `glimmer-local-class-transform`
2+
3+
Fill me out later.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "glimmer-local-class-transform",
3+
"version": "1.0.0-alpha.0",
4+
"description": "Support for `local-class` attributes in Glimmer templates",
5+
"license": "MIT",
6+
"author": "Dan Freeman",
7+
"homepage": "https://github.com/salsify/ember-css-modules/tree/master/packages/glimmer-local-class-transform",
8+
"repository": {
9+
"type": "git",
10+
"url": "git+ssh://[email protected]/salsify/ember-css-modules.git",
11+
"directory": "packages/glimmer-local-class-transform"
12+
},
13+
"type": "module",
14+
"exports": {
15+
".": "./dist/transform.js",
16+
"./-runtime": "./dist/runtime.js"
17+
},
18+
"scripts": {
19+
"prepare": "tsc --project tsconfig.build.json",
20+
"test": "vitest run"
21+
},
22+
"files": [
23+
"README.md",
24+
"dist/**/!(*.test.*)"
25+
],
26+
"devDependencies": {
27+
"@glimmer/syntax": "^0.84.3",
28+
"babel-plugin-ember-template-compilation": "~2.3.0",
29+
"eslint": "^8.22.0",
30+
"prettier": "^3.2.5",
31+
"typescript": "^5.4.5",
32+
"vitest": "^1.6.0"
33+
},
34+
"volta": {
35+
"extends": "../../package.json"
36+
}
37+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { describe, test, expect } from 'vitest';
2+
import { join, classNames } from './runtime.js';
3+
4+
describe('Runtime helpers', () => {
5+
test('classNames', () => {
6+
expect(classNames({}, 'foo')).toBe('foo');
7+
expect(classNames({ foo: 'bar' }, 'foo')).toBe('bar');
8+
expect(classNames({ foo: 'bar' }, ' foo baz ')).toBe('bar baz');
9+
});
10+
11+
test('join', () => {
12+
expect(join()).toBe('');
13+
expect(join('foo')).toBe('foo');
14+
expect(join('foo', 'bar')).toBe('foobar');
15+
});
16+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export function classNames(mapping: Record<string, string>, classes: string): string {
2+
return classes
3+
.trim()
4+
.split(/\s+/)
5+
.map((className) => mapping[className] ?? className)
6+
.join(' ');
7+
}
8+
9+
export function join(...parts: Array<string>): string {
10+
return parts.join('');
11+
}

0 commit comments

Comments
 (0)