@rettangoli/ui 1.0.6 → 1.0.9
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/dist/rettangoli-iife-layout.min.js +49 -49
- package/dist/rettangoli-iife-ui.min.js +43 -43
- package/package.json +6 -10
- package/src/components/card/card.schema.yaml +15 -0
- package/src/components/card/card.store.js +87 -0
- package/src/components/card/card.view.yaml +18 -0
- package/src/primitives/view.js +41 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rettangoli/ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "A UI component library for building web interfaces.",
|
|
5
5
|
"main": "dist/rettangoli-esm.min.js",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"module": "./src/index.js",
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "
|
|
22
|
+
"url": "https://github.com/yuusoft-org/rettangoli",
|
|
23
|
+
"directory": "packages/rettangoli-ui"
|
|
23
24
|
},
|
|
24
25
|
"author": {
|
|
25
26
|
"name": "Luciano Hanyon Wu",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
"build": "rtgl fe build -o ./.generated/fe-entry.js && bun run esbuild.js && bun run esbuild-dev.js && npm run copy:css",
|
|
37
38
|
"prepack": "npm run build",
|
|
38
39
|
"vt:generate": "bun run build:dev && rtgl vt generate",
|
|
39
|
-
"vt:docker": "bun run build:dev && bash -lc 'IMAGE=\"han4wluc/rtgl:playwright-v1.57.0-rtgl-v1.0.
|
|
40
|
+
"vt:docker": "bun run build:dev && bash -lc 'IMAGE=\"han4wluc/rtgl:playwright-v1.57.0-rtgl-v1.0.5\"; docker pull \"$IMAGE\" >/dev/null 2>&1 || IMAGE=\"han4wluc/rtgl:playwright-v1.57.0-rtgl-v1.0.0-rc27\"; docker run --rm --user $(id -u):$(id -g) -v \"$PWD:/app\" -w /app \"$IMAGE\" rtgl vt screenshot'",
|
|
40
41
|
"vt:report": "bun run vt:docker && rtgl vt report",
|
|
41
42
|
"vt:accept": "rtgl vt accept",
|
|
42
43
|
"serve": "bunx serve .rettangoli/vt/_site"
|
|
@@ -61,12 +62,7 @@
|
|
|
61
62
|
},
|
|
62
63
|
"homepage": "https://github.com/yuusoft-org/rettangoli#readme",
|
|
63
64
|
"dependencies": {
|
|
64
|
-
"@
|
|
65
|
-
"
|
|
66
|
-
"commander": "^13.1.0",
|
|
67
|
-
"jempl": "1.0.0",
|
|
68
|
-
"js-yaml": "^4.1.0",
|
|
69
|
-
"liquidjs": "^10.21.0",
|
|
70
|
-
"snabbdom": "^3.6.2"
|
|
65
|
+
"@rettangoli/fe": "1.0.4",
|
|
66
|
+
"jempl": "1.0.1"
|
|
71
67
|
}
|
|
72
68
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const blacklistedProps = [
|
|
2
|
+
'id',
|
|
3
|
+
'class',
|
|
4
|
+
'style',
|
|
5
|
+
'slot',
|
|
6
|
+
'head',
|
|
7
|
+
'desc',
|
|
8
|
+
'size',
|
|
9
|
+
'd',
|
|
10
|
+
'ah',
|
|
11
|
+
'av',
|
|
12
|
+
'wrap',
|
|
13
|
+
'noWrap',
|
|
14
|
+
'g',
|
|
15
|
+
'gh',
|
|
16
|
+
'gv',
|
|
17
|
+
'p',
|
|
18
|
+
'pt',
|
|
19
|
+
'pr',
|
|
20
|
+
'pb',
|
|
21
|
+
'pl',
|
|
22
|
+
'pv',
|
|
23
|
+
'ph',
|
|
24
|
+
'bw',
|
|
25
|
+
'bwt',
|
|
26
|
+
'bwr',
|
|
27
|
+
'bwb',
|
|
28
|
+
'bwl',
|
|
29
|
+
'bc',
|
|
30
|
+
'br',
|
|
31
|
+
'shadow',
|
|
32
|
+
'bgc',
|
|
33
|
+
'href',
|
|
34
|
+
'newTab',
|
|
35
|
+
'rel',
|
|
36
|
+
'cur',
|
|
37
|
+
'sv',
|
|
38
|
+
'sh',
|
|
39
|
+
'overflow',
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const sizePresets = {
|
|
43
|
+
sm: {
|
|
44
|
+
cardAttrString: 'p=md sm-p=sm g=md sm-g=sm',
|
|
45
|
+
headerAttrString: 'g=xs',
|
|
46
|
+
headingSize: 'lg',
|
|
47
|
+
subheadingSize: 'sm',
|
|
48
|
+
},
|
|
49
|
+
md: {
|
|
50
|
+
cardAttrString: 'p=lg md-p=md sm-p=md g=lg md-g=md sm-g=md',
|
|
51
|
+
headerAttrString: 'g=sm',
|
|
52
|
+
headingSize: 'h4',
|
|
53
|
+
subheadingSize: 'sm',
|
|
54
|
+
},
|
|
55
|
+
lg: {
|
|
56
|
+
cardAttrString: 'p=xl lg-p=lg md-p=md sm-p=md g=lg md-g=md sm-g=md',
|
|
57
|
+
headerAttrString: 'g=sm',
|
|
58
|
+
headingSize: 'h3',
|
|
59
|
+
subheadingSize: 'md',
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const stringifyProps = (props = {}) => {
|
|
64
|
+
return Object.entries(props)
|
|
65
|
+
.filter(([key]) => !blacklistedProps.includes(key))
|
|
66
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
67
|
+
.join(' ');
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const createInitialState = () => Object.freeze({});
|
|
71
|
+
|
|
72
|
+
export const selectViewData = ({ props = {} }) => {
|
|
73
|
+
const size = sizePresets[props.size] ? props.size : 'md';
|
|
74
|
+
const preset = sizePresets[size];
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
containerAttrString: stringifyProps(props),
|
|
78
|
+
cardAttrString: preset.cardAttrString,
|
|
79
|
+
headerAttrString: preset.headerAttrString,
|
|
80
|
+
headingSize: preset.headingSize,
|
|
81
|
+
subheadingSize: preset.subheadingSize,
|
|
82
|
+
head: props.head || '',
|
|
83
|
+
desc: props.desc || '',
|
|
84
|
+
hasHeader: !!(props.head || props.desc),
|
|
85
|
+
size,
|
|
86
|
+
};
|
|
87
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
styles:
|
|
2
|
+
:host:
|
|
3
|
+
display: block
|
|
4
|
+
slot:
|
|
5
|
+
display: block
|
|
6
|
+
min-width: 0
|
|
7
|
+
.rtgl-card-body:
|
|
8
|
+
min-width: 0
|
|
9
|
+
template:
|
|
10
|
+
- 'rtgl-view class="rtgl-card" d=v w=f bgc=bg bw=xs bc=bo br=xl shadow=sm ${cardAttrString} ${containerAttrString}':
|
|
11
|
+
- $if hasHeader:
|
|
12
|
+
- 'rtgl-view class="rtgl-card-header" d=v w=f ${headerAttrString}':
|
|
13
|
+
- $if head:
|
|
14
|
+
- rtgl-text class="rtgl-card-heading" s=${headingSize} w=f: ${head}
|
|
15
|
+
- $if desc:
|
|
16
|
+
- rtgl-text class="rtgl-card-desc" s=${subheadingSize} c=mu-fg w=f: ${desc}
|
|
17
|
+
- div class=rtgl-card-body:
|
|
18
|
+
- slot: null
|
package/src/primitives/view.js
CHANGED
|
@@ -19,6 +19,15 @@ import stylesGenerator from "../styles/viewStyles.js";
|
|
|
19
19
|
import marginStyles from "../styles/marginStyles.js";
|
|
20
20
|
import anchorStyles from "../styles/anchorStyles.js";
|
|
21
21
|
|
|
22
|
+
const normalizeRawCssValue = (value) => {
|
|
23
|
+
if (value === undefined || value === null) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const normalizedValue = `${value}`.trim();
|
|
28
|
+
return normalizedValue.length > 0 ? normalizedValue : null;
|
|
29
|
+
};
|
|
30
|
+
|
|
22
31
|
// Internal implementation without uhtml
|
|
23
32
|
class RettangoliViewElement extends HTMLElement {
|
|
24
33
|
static styleSheet = null;
|
|
@@ -80,6 +89,10 @@ class RettangoliViewElement extends HTMLElement {
|
|
|
80
89
|
"w",
|
|
81
90
|
"h",
|
|
82
91
|
"ar",
|
|
92
|
+
"bgi",
|
|
93
|
+
"bgs",
|
|
94
|
+
"bgp",
|
|
95
|
+
"bgr",
|
|
83
96
|
"hide",
|
|
84
97
|
"show",
|
|
85
98
|
"sh",
|
|
@@ -141,6 +154,18 @@ class RettangoliViewElement extends HTMLElement {
|
|
|
141
154
|
const aspectRatio = normalizeAspectRatio(
|
|
142
155
|
this.getAttribute(addSizePrefix("ar")),
|
|
143
156
|
);
|
|
157
|
+
const backgroundImage = normalizeRawCssValue(
|
|
158
|
+
this.getAttribute(addSizePrefix("bgi")),
|
|
159
|
+
);
|
|
160
|
+
const backgroundSize = normalizeRawCssValue(
|
|
161
|
+
this.getAttribute(addSizePrefix("bgs")),
|
|
162
|
+
);
|
|
163
|
+
const backgroundPosition = normalizeRawCssValue(
|
|
164
|
+
this.getAttribute(addSizePrefix("bgp")),
|
|
165
|
+
);
|
|
166
|
+
const backgroundRepeat = normalizeRawCssValue(
|
|
167
|
+
this.getAttribute(addSizePrefix("bgr")),
|
|
168
|
+
);
|
|
144
169
|
|
|
145
170
|
if (zIndex !== null) {
|
|
146
171
|
this._styles[size]["z-index"] = zIndex;
|
|
@@ -154,6 +179,22 @@ class RettangoliViewElement extends HTMLElement {
|
|
|
154
179
|
this._styles[size]["aspect-ratio"] = aspectRatio;
|
|
155
180
|
}
|
|
156
181
|
|
|
182
|
+
if (backgroundImage !== null) {
|
|
183
|
+
this._styles[size]["background-image"] = backgroundImage;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (backgroundSize !== null) {
|
|
187
|
+
this._styles[size]["background-size"] = backgroundSize;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (backgroundPosition !== null) {
|
|
191
|
+
this._styles[size]["background-position"] = backgroundPosition;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (backgroundRepeat !== null) {
|
|
195
|
+
this._styles[size]["background-repeat"] = backgroundRepeat;
|
|
196
|
+
}
|
|
197
|
+
|
|
157
198
|
applyDimensionToStyleBucket({
|
|
158
199
|
styleBucket: this._styles[size],
|
|
159
200
|
axis: "width",
|