Skip to content

Commit b4a6a3e

Browse files
committed
moved toClass shorthash dep to utils package
1 parent 4ee891f commit b4a6a3e

File tree

6 files changed

+23
-10
lines changed

6 files changed

+23
-10
lines changed

packages/heml-parse/package-lock.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/heml-parse/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"html-tags": "^2.0.0",
2828
"lodash": "^4.17.4",
2929
"postcss": "^6.0.14",
30-
"postcss-safe-parser": "^3.0.1",
31-
"shorthash": "0.0.2"
30+
"postcss-safe-parser": "^3.0.1"
3231
}
3332
}

packages/heml-utils/package-lock.json

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/heml-utils/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"dependencies": {
2424
"@heml/render": "^1.0.2-0",
2525
"css-groups": "^0.1.1",
26-
"lodash": "^4.17.4"
26+
"lodash": "^4.17.4",
27+
"shorthash": "0.0.2"
2728
}
2829
}

packages/heml-utils/src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ import createElement from './createElement'
44
import HEMLError from './HEMLError'
55
import transforms from './transforms'
66
import condition from './condition'
7+
import toClass from './toClass'
78

8-
module.exports = { createElement, renderElement, HEMLError, cssGroups, transforms, condition }
9+
module.exports = { createElement, renderElement, HEMLError, cssGroups, transforms, condition, toClass }

packages/heml-utils/src/toClass.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { unique } from 'shorthash'
2+
3+
/**
4+
* generates a consistent short class-safe hash from a longer string
5+
* @param {String} str the string used in the hash function
6+
* @return {String} the class
7+
*/
8+
export default function toClass(s) {
9+
return `c${unique(s)}`
10+
}

0 commit comments

Comments
 (0)