km-card-layout-component-miniprogram 0.1.39 → 0.1.42
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 +2 -2
- package/example/app.js +1 -8
- package/example/app.json +2 -1
- package/example/pages/home/testfont/testfont.js +60 -0
- package/example/pages/home/testfont/testfont.json +6 -0
- package/example/pages/home/testfont/testfont.wxml +29 -0
- package/example/pages/home/testfont/testfont.wxss +3 -0
- package/miniprogram_dist/components/card-layout/elements/icon-element/index.js +2 -2
- package/miniprogram_dist/components/card-layout/elements/icon-element/index.wxml +1 -1
- package/miniprogram_dist/components/card-layout/elements/icon-font.wxss +8 -4
- package/miniprogram_dist/components/card-layout/icon-map.js +1 -0
- package/miniprogram_dist/components/card-layout/index.js +142 -16
- package/miniprogram_dist/components/card-layout/index.wxml +46 -22
- package/miniprogram_dist/components/card-layout/index.wxss +83 -1
- package/miniprogram_dist/vendor/km-card-layout-core/index.js +2 -1
- package/miniprogram_dist/vendor/km-card-layout-core/ops/changeBackground.js +55 -50
- package/package.json +1 -1
- package/src/components/card-layout/elements/icon-element/index.ts +2 -2
- package/src/components/card-layout/elements/icon-element/index.wxml +1 -1
- package/src/components/card-layout/elements/icon-font.wxss +8 -4
- package/src/components/card-layout/icon-map.ts +1 -0
- package/src/components/card-layout/index.ts +160 -18
- package/src/components/card-layout/index.wxml +46 -22
- package/src/components/card-layout/index.wxss +83 -1
- package/src/vendor/km-card-layout-core/index.ts +1 -1
- package/src/vendor/km-card-layout-core/interface/elements.ts +1 -1
- package/src/vendor/km-card-layout-core/ops/changeBackground.ts +57 -51
- package/src/vendor/km-card-layout-core/types.d.ts +4 -1
|
@@ -2,10 +2,66 @@
|
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
position: relative;
|
|
5
|
+
perspective: 1200rpx;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
.km-card-layout__item {
|
|
8
9
|
width: 100%;
|
|
10
|
+
position: relative;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.layout-canvas-container {
|
|
14
|
+
position: fixed;
|
|
15
|
+
left: -10000rpx;
|
|
16
|
+
top: 0;
|
|
17
|
+
opacity: 0;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
z-index: -1;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.km-card-layout__flip {
|
|
23
|
+
position: relative;
|
|
24
|
+
-webkit-transform-style: preserve-3d;
|
|
25
|
+
transform-style: preserve-3d;
|
|
26
|
+
transition: transform 420ms ease;
|
|
27
|
+
transform-origin: center;
|
|
28
|
+
will-change: transform;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.km-card-layout__flip.is-flipped {
|
|
32
|
+
transform: rotateY(180deg);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.km-card-layout__flip:not(.is-switching) .km-card-layout__face--back {
|
|
36
|
+
visibility: hidden;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.km-card-layout__flip.is-flipped:not(.is-switching) .km-card-layout__face--front {
|
|
40
|
+
visibility: hidden;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.km-card-layout__flip.is-flipped:not(.is-switching) .km-card-layout__face--back {
|
|
44
|
+
visibility: visible;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.km-card-layout__face {
|
|
48
|
+
position: absolute;
|
|
49
|
+
left: 0;
|
|
50
|
+
top: 0;
|
|
51
|
+
width: 100%;
|
|
52
|
+
height: 100%;
|
|
53
|
+
-webkit-backface-visibility: hidden;
|
|
54
|
+
backface-visibility: hidden;
|
|
55
|
+
-webkit-transform-style: preserve-3d;
|
|
56
|
+
transform-style: preserve-3d;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.km-card-layout__face--back {
|
|
60
|
+
transform: rotateY(180deg);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.km-card-layout__single {
|
|
64
|
+
position: relative;
|
|
9
65
|
}
|
|
10
66
|
|
|
11
67
|
.km-card {
|
|
@@ -13,8 +69,10 @@
|
|
|
13
69
|
overflow: hidden;
|
|
14
70
|
box-sizing: border-box;
|
|
15
71
|
color: inherit;
|
|
16
|
-
font-family:
|
|
72
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
17
73
|
background: transparent;
|
|
74
|
+
-webkit-backface-visibility: hidden;
|
|
75
|
+
backface-visibility: hidden;
|
|
18
76
|
}
|
|
19
77
|
|
|
20
78
|
.km-card__bg {
|
|
@@ -25,3 +83,27 @@
|
|
|
25
83
|
height: 100%;
|
|
26
84
|
object-fit: cover;
|
|
27
85
|
}
|
|
86
|
+
|
|
87
|
+
.km-card-layout__toggle {
|
|
88
|
+
position: absolute;
|
|
89
|
+
top: 48rpx;
|
|
90
|
+
right: 20rpx;
|
|
91
|
+
z-index: 20;
|
|
92
|
+
padding: 8rpx 16rpx;
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
gap: 4rpx;
|
|
96
|
+
border-radius: 30px;
|
|
97
|
+
border: 0.5px solid #FFF;
|
|
98
|
+
color: #fff;
|
|
99
|
+
background: rgba(85, 85, 85, 0.30);
|
|
100
|
+
backdrop-filter: blur(4px);
|
|
101
|
+
-webkit-backdrop-filter: blur(4rpx);
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.km-card-layout__toggle-text {
|
|
106
|
+
color: #ffffff;
|
|
107
|
+
font-size: 24rpx;
|
|
108
|
+
line-height: 1;
|
|
109
|
+
}
|
|
@@ -15,7 +15,7 @@ export {
|
|
|
15
15
|
} from './layout';
|
|
16
16
|
export { resolveBindingValue } from './data';
|
|
17
17
|
export { stripLayoutBindings, applyItemCollectBindings } from './bindings';
|
|
18
|
-
export { backgroundChange } from './ops/changeBackground';
|
|
18
|
+
export { backgroundChange, applySpecialColor } from './ops/changeBackground';
|
|
19
19
|
export {
|
|
20
20
|
buildWrapperStyle,
|
|
21
21
|
buildCardStyle,
|
|
@@ -10,69 +10,75 @@ const toNameArray = (name?: string | string[]) => {
|
|
|
10
10
|
.filter(Boolean);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
):
|
|
13
|
+
export function applySpecialColor (
|
|
14
|
+
el: CardElement,
|
|
15
|
+
bg: TemplateBackground
|
|
16
|
+
): CardElement {
|
|
17
17
|
const extras = bg.fontColorExtra || [];
|
|
18
|
-
const iconSpecialColor =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (el.type === 'custom') keys.push('decor');
|
|
18
|
+
const iconSpecialColor = extras.find(sc =>
|
|
19
|
+
toNameArray(sc.name).some(n => n === 'icon')
|
|
20
|
+
)?.color;
|
|
21
|
+
const keys: string[] = [];
|
|
22
|
+
if (el.binding) keys.push(String(el.binding));
|
|
23
|
+
if (el.id) keys.push(String(el.id));
|
|
24
|
+
if (el.type === 'icon') keys.push('icon');
|
|
25
|
+
if (el.type === 'custom') keys.push('decor');
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const matched = extras.find(sc =>
|
|
28
|
+
toNameArray(sc.name).some(n => keys.some(k => k?.startsWith(n)))
|
|
29
|
+
);
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const baseStyle = { ...(el.style || {}) };
|
|
32
|
+
let nextEl: CardElement = el;
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
34
|
+
if (matched) {
|
|
35
|
+
if (el.type === 'custom') {
|
|
36
|
+
nextEl = {
|
|
37
|
+
...el,
|
|
38
|
+
style: { ...baseStyle, backgroundColor: matched.color },
|
|
39
|
+
};
|
|
41
40
|
} else {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
delete nextStyle.background;
|
|
51
|
-
changed = true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if ('color' in nextStyle) {
|
|
55
|
-
delete nextStyle.color;
|
|
41
|
+
nextEl = { ...el, style: { ...baseStyle, color: matched.color } };
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
const nextStyle = { ...baseStyle };
|
|
45
|
+
let changed = false;
|
|
46
|
+
if (el.type === 'custom') {
|
|
47
|
+
if ('backgroundColor' in nextStyle) {
|
|
48
|
+
delete nextStyle.backgroundColor;
|
|
56
49
|
changed = true;
|
|
57
50
|
}
|
|
58
|
-
if (
|
|
59
|
-
|
|
51
|
+
if ('background' in nextStyle) {
|
|
52
|
+
delete nextStyle.background;
|
|
53
|
+
changed = true;
|
|
60
54
|
}
|
|
61
55
|
}
|
|
56
|
+
if ('color' in nextStyle) {
|
|
57
|
+
delete nextStyle.color;
|
|
58
|
+
changed = true;
|
|
59
|
+
}
|
|
60
|
+
if (changed) {
|
|
61
|
+
nextEl = { ...el, style: nextStyle };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
nextEl = { ...(nextEl as any), icon: nextIcon } as CardElement;
|
|
65
|
+
if (nextEl.type === 'text' ) {
|
|
66
|
+
const nextIcon = (nextEl as any).icon ? { ...(nextEl as any).icon } :{};
|
|
67
|
+
if (iconSpecialColor) {
|
|
68
|
+
nextIcon.color = iconSpecialColor;
|
|
69
|
+
} else if ('color' in nextIcon) {
|
|
70
|
+
delete nextIcon.color;
|
|
71
71
|
}
|
|
72
|
+
nextEl = { ...(nextEl as any), icon: nextIcon } as CardElement;
|
|
73
|
+
}
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
return nextEl;
|
|
76
|
+
};
|
|
75
77
|
|
|
78
|
+
export function backgroundChange(
|
|
79
|
+
bg: TemplateBackground,
|
|
80
|
+
layout: CardLayoutSchema
|
|
81
|
+
): CardLayoutSchema {
|
|
76
82
|
const traverse = (children: CardElement[] = []): CardElement[] =>
|
|
77
83
|
children.map(el => {
|
|
78
84
|
if (!el) return el;
|
|
@@ -82,7 +88,7 @@ export function backgroundChange(
|
|
|
82
88
|
children: traverse(el.children || []),
|
|
83
89
|
};
|
|
84
90
|
}
|
|
85
|
-
return applySpecialColor(el);
|
|
91
|
+
return applySpecialColor(el, bg);
|
|
86
92
|
});
|
|
87
93
|
|
|
88
94
|
const nextChildren = traverse(layout.children || []);
|
|
@@ -72,7 +72,10 @@ export function backgroundChange(
|
|
|
72
72
|
bg: TemplateBackground,
|
|
73
73
|
layout: CardLayoutSchema
|
|
74
74
|
): CardLayoutSchema;
|
|
75
|
-
|
|
75
|
+
export function applySpecialColor (
|
|
76
|
+
el: CardElement,
|
|
77
|
+
bg: TemplateBackground
|
|
78
|
+
): CardElement;
|
|
76
79
|
export function buildWrapperStyle(
|
|
77
80
|
el: CardElement,
|
|
78
81
|
unit?: 'px' | 'rpx'
|