Skip to content

Commit 8d6418a

Browse files
authored
v0.5.0
1 parent b842928 commit 8d6418a

File tree

9 files changed

+138
-3
lines changed

9 files changed

+138
-3
lines changed

dist/assembler.cjs.js

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

dist/assembler.es.js

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

dist/assembler.js

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

dist/assembler.min.js

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@asmcss/assembler",
3-
"version": "0.4.1",
3+
"version": "0.5.0",
44
"main": "dist/assembler.cjs.js",
55
"module": "dist/assembler.es.js",
66
"browser": "dist/assembler.js",

src/helpers.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
import {PROPERTY_LIST, PROPERTY_VARIANTS} from "./list";
18+
1719
export type UserSettings = {
1820
enabled: boolean,
1921
generate: boolean,
@@ -26,7 +28,8 @@ export type UserSettings = {
2628
states: string[],
2729
scopes: string[],
2830
xStyleAttribute: string,
29-
selectorAttribute: string
31+
selectorAttribute: string,
32+
registeredProperties: {name: string, aliases: string[]}[],
3033
};
3134
type StyleType = string|{[key: string]: string};
3235
const regex = /([a-z0-9]|(?=[A-Z]))([A-Z])/g;
@@ -44,6 +47,7 @@ export function getUserSettings(dataset: {[key: string]: string}): UserSettings
4447
const cache = dataset.cache === undefined ? null : dataset.cache;
4548
const cacheKey = dataset.cacheKey === undefined ? "assembler-css-cache" : dataset.cacheKey;
4649
const dataScopes = dataset.scopes === undefined ? [] : getStringItemList(dataset.scopes);
50+
const registeredProperties = dataset.registerProperties === undefined ? [] : getRegisteredProperties(dataset.registerProperties);
4751
const scopes = ["", "text-clip", "selection", "placeholder", "before", "after", "first-letter", "first-line",
4852
"l1", "l2", "marker-l1", "marker", "sibling", "child", "even", "odd", "first", "last", "dark", "light",
4953
"landscape", "portrait", "motion-reduce", "motion-safe"];
@@ -55,6 +59,16 @@ export function getUserSettings(dataset: {[key: string]: string}): UserSettings
5559
}
5660
}
5761

62+
for (let i = 0, l = registeredProperties.length; i < l; i++) {
63+
const prop = registeredProperties[i];
64+
if (PROPERTY_LIST.indexOf(prop.name) === -1) {
65+
PROPERTY_LIST.push(prop.name);
66+
if (prop.aliases.length > 0) {
67+
PROPERTY_VARIANTS[prop.name] = prop.aliases;
68+
}
69+
}
70+
}
71+
5872
// Consider all bp
5973
let breakpoints = ['xs', 'sm', 'md', 'lg', 'xl'];
6074

@@ -99,6 +113,7 @@ export function getUserSettings(dataset: {[key: string]: string}): UserSettings
99113
media: {xs, sm, md, lg, xl},
100114
xStyleAttribute,
101115
selectorAttribute,
116+
registeredProperties
102117
};
103118
}
104119

@@ -135,6 +150,23 @@ function getStringItemList(value: string, unique: boolean = true): string[] {
135150
return unique ? items.filter(uniqueItems) : items;
136151
}
137152

153+
function getRegisteredProperties(value: string): {name: string, aliases:string[]}[] {
154+
return value
155+
.split(';')
156+
.map(v => v.trim())
157+
.filter(v => v !== '')
158+
.map(v => {
159+
const index = v.indexOf(':');
160+
if (index < 0) {
161+
return {name: v, aliases: []};
162+
}
163+
return {
164+
name: v.substr(0, index),
165+
aliases: v.substr(index + 1).split(',').map(v => v.trim()).filter(v => v !== '')
166+
}
167+
});
168+
}
169+
138170
export function trim(value: string): string {
139171
return value.trim();
140172
}

src/list.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const PROPERTY_LIST = [
6868
"border-top-right-radius",
6969
"border-width",
7070
"bottom",
71+
"box-orient",
7172
"box-shadow",
7273
"box-sizing",
7374
"clear",
@@ -115,6 +116,7 @@ export const PROPERTY_LIST = [
115116
"justify-self",
116117
"left",
117118
"letter-spacing",
119+
"line-clamp",
118120
"line-height",
119121
"list-style-position",
120122
"list-style-type",
@@ -182,7 +184,9 @@ export const PROPERTY_VARIANTS = {
182184
"appearance": ["-webkit-appearance", "-moz-appearance"],
183185
"background-clip": ["-webkit-background-clip", "-moz-background-clip"],
184186
"backdrop-filter": ["-webkit-backdrop-filter"],
187+
"box-orient": ["-webkit-box-orient"],
185188
"column-gap": ["-moz-column-gap"],
189+
"line-clamp": ["-webkit-line-clamp"],
186190
"user-select": ["-webkit-user-select", "-moz-user-select"],
187191
"text-fill-color": ["-webkit-text-fill-color", "-moz-text-fill-color"]
188192
};

types/helpers.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export declare type UserSettings = {
1717
scopes: string[];
1818
xStyleAttribute: string;
1919
selectorAttribute: string;
20+
registeredProperties: {
21+
name: string;
22+
aliases: string[];
23+
}[];
2024
};
2125
declare type StyleType = string | {
2226
[key: string]: string;

types/list.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ export declare const PROPERTY_VARIANTS: {
44
appearance: string[];
55
"background-clip": string[];
66
"backdrop-filter": string[];
7+
"box-orient": string[];
78
"column-gap": string[];
9+
"line-clamp": string[];
810
"user-select": string[];
911
"text-fill-color": string[];
1012
};

0 commit comments

Comments
 (0)