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.
Files changed (28) hide show
  1. package/README.md +2 -2
  2. package/example/app.js +1 -8
  3. package/example/app.json +2 -1
  4. package/example/pages/home/testfont/testfont.js +60 -0
  5. package/example/pages/home/testfont/testfont.json +6 -0
  6. package/example/pages/home/testfont/testfont.wxml +29 -0
  7. package/example/pages/home/testfont/testfont.wxss +3 -0
  8. package/miniprogram_dist/components/card-layout/elements/icon-element/index.js +2 -2
  9. package/miniprogram_dist/components/card-layout/elements/icon-element/index.wxml +1 -1
  10. package/miniprogram_dist/components/card-layout/elements/icon-font.wxss +8 -4
  11. package/miniprogram_dist/components/card-layout/icon-map.js +1 -0
  12. package/miniprogram_dist/components/card-layout/index.js +142 -16
  13. package/miniprogram_dist/components/card-layout/index.wxml +46 -22
  14. package/miniprogram_dist/components/card-layout/index.wxss +83 -1
  15. package/miniprogram_dist/vendor/km-card-layout-core/index.js +2 -1
  16. package/miniprogram_dist/vendor/km-card-layout-core/ops/changeBackground.js +55 -50
  17. package/package.json +1 -1
  18. package/src/components/card-layout/elements/icon-element/index.ts +2 -2
  19. package/src/components/card-layout/elements/icon-element/index.wxml +1 -1
  20. package/src/components/card-layout/elements/icon-font.wxss +8 -4
  21. package/src/components/card-layout/icon-map.ts +1 -0
  22. package/src/components/card-layout/index.ts +160 -18
  23. package/src/components/card-layout/index.wxml +46 -22
  24. package/src/components/card-layout/index.wxss +83 -1
  25. package/src/vendor/km-card-layout-core/index.ts +1 -1
  26. package/src/vendor/km-card-layout-core/interface/elements.ts +1 -1
  27. package/src/vendor/km-card-layout-core/ops/changeBackground.ts +57 -51
  28. 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: 'PingFang SC', 'Microsoft Yahei', sans-serif;
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,
@@ -35,7 +35,7 @@ export interface TextIconConfig {
35
35
  enable?: boolean;
36
36
  style?: 'fill' | 'dot' | 'line' | 'text';
37
37
  // 控制图标属性区域是否显示(用户端)
38
- visible:boolean;
38
+ visible ?:boolean;
39
39
  }
40
40
 
41
41
  export interface TextElement extends CardElementBase {
@@ -10,69 +10,75 @@ const toNameArray = (name?: string | string[]) => {
10
10
  .filter(Boolean);
11
11
  };
12
12
 
13
- export function backgroundChange(
14
- bg: TemplateBackground,
15
- layout: CardLayoutSchema
16
- ): CardLayoutSchema {
13
+ export function applySpecialColor (
14
+ el: CardElement,
15
+ bg: TemplateBackground
16
+ ): CardElement {
17
17
  const extras = bg.fontColorExtra || [];
18
- const iconSpecialColor =
19
- extras.find(sc => toNameArray(sc.name).some(n => n === 'icon'))?.color;
20
-
21
- const applySpecialColor = (el: CardElement): CardElement => {
22
- const keys: string[] = [];
23
- if (el.binding) keys.push(String(el.binding));
24
- if (el.id) keys.push(String(el.id));
25
- if (el.type === 'icon') keys.push('icon');
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
- const matched = extras.find(sc =>
29
- toNameArray(sc.name).some(n => keys.some(k => k?.startsWith(n)))
30
- );
27
+ const matched = extras.find(sc =>
28
+ toNameArray(sc.name).some(n => keys.some(k => k?.startsWith(n)))
29
+ );
31
30
 
32
- const baseStyle = { ...(el.style || {}) };
33
- let nextEl: CardElement = el;
31
+ const baseStyle = { ...(el.style || {}) };
32
+ let nextEl: CardElement = el;
34
33
 
35
- if (matched) {
36
- if (el.type === 'custom') {
37
- nextEl = { ...el, style: { ...baseStyle, backgroundColor: matched.color } };
38
- } else {
39
- nextEl = { ...el, style: { ...baseStyle, color: matched.color } };
40
- }
34
+ if (matched) {
35
+ if (el.type === 'custom') {
36
+ nextEl = {
37
+ ...el,
38
+ style: { ...baseStyle, backgroundColor: matched.color },
39
+ };
41
40
  } else {
42
- const nextStyle = { ...baseStyle };
43
- let changed = false;
44
- if (el.type === 'custom') {
45
- if ('backgroundColor' in nextStyle) {
46
- delete nextStyle.backgroundColor;
47
- changed = true;
48
- }
49
- if ('background' in nextStyle) {
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 (changed) {
59
- nextEl = { ...el, style: nextStyle };
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
- if (nextEl.type === 'text' && (nextEl as any).icon) {
64
- const nextIcon = { ...(nextEl as any).icon };
65
- if (iconSpecialColor) {
66
- nextIcon.color = iconSpecialColor;
67
- } else if ('color' in nextIcon) {
68
- delete nextIcon.color;
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
- return nextEl;
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'