@grucloud/bau-ui 0.53.0 → 0.54.1
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/avatar/avatar.js +45 -13
- package/package.json +4 -4
package/avatar/avatar.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
2
2
|
import classNames from "@grucloud/bau-css/classNames.js";
|
|
3
|
+
import skeleton from "../skeleton";
|
|
3
4
|
|
|
4
5
|
export default function (context, options = {}) {
|
|
5
6
|
const { bau, css } = context;
|
|
6
|
-
const {
|
|
7
|
+
const { div, img } = bau.tags;
|
|
7
8
|
|
|
8
9
|
const loadingState = bau.state(true);
|
|
9
10
|
const errorState = bau.state(false);
|
|
@@ -16,9 +17,10 @@ export default function (context, options = {}) {
|
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
const className = css`
|
|
19
|
-
display: flex;
|
|
20
|
+
display: inline-flex;
|
|
20
21
|
justify-content: center;
|
|
21
22
|
align-items: center;
|
|
23
|
+
position: relative;
|
|
22
24
|
&.sm {
|
|
23
25
|
width: 20px;
|
|
24
26
|
height: 20px;
|
|
@@ -31,6 +33,18 @@ export default function (context, options = {}) {
|
|
|
31
33
|
width: 60px;
|
|
32
34
|
height: 60px;
|
|
33
35
|
}
|
|
36
|
+
& img {
|
|
37
|
+
visibility: hidden;
|
|
38
|
+
opacity: 0;
|
|
39
|
+
transition: opacity var(--transition-slow) ease-in;
|
|
40
|
+
}
|
|
41
|
+
& .visible {
|
|
42
|
+
visibility: visible;
|
|
43
|
+
opacity: 1;
|
|
44
|
+
}
|
|
45
|
+
& .hide {
|
|
46
|
+
display: none;
|
|
47
|
+
}
|
|
34
48
|
`;
|
|
35
49
|
return function Avatar(...args) {
|
|
36
50
|
let [
|
|
@@ -40,27 +54,45 @@ export default function (context, options = {}) {
|
|
|
40
54
|
color = options.color ?? "neutral",
|
|
41
55
|
width = 40,
|
|
42
56
|
height = 40,
|
|
57
|
+
alt,
|
|
43
58
|
...props
|
|
44
59
|
},
|
|
45
60
|
...children
|
|
46
61
|
] = toPropsAndChildren(args);
|
|
47
|
-
|
|
62
|
+
const Skeleton = skeleton(context, {
|
|
63
|
+
class: classNames(
|
|
64
|
+
css`
|
|
65
|
+
position: absolute;
|
|
66
|
+
top: 0;
|
|
67
|
+
left: 0;
|
|
68
|
+
height: ${height}px;
|
|
69
|
+
width: ${width}px;
|
|
70
|
+
`,
|
|
71
|
+
options?.class,
|
|
72
|
+
props.class
|
|
73
|
+
),
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return div(
|
|
48
77
|
{ class: classNames(className, options?.class, props.class) },
|
|
49
|
-
() =>
|
|
50
|
-
() => errorState.val &&
|
|
78
|
+
() => loadingState.val && Skeleton(),
|
|
79
|
+
() => errorState.val && alt,
|
|
51
80
|
img({
|
|
52
81
|
width,
|
|
53
82
|
height,
|
|
54
83
|
onload,
|
|
55
84
|
onerror,
|
|
56
|
-
class:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
85
|
+
class: () =>
|
|
86
|
+
classNames(
|
|
87
|
+
!loadingState.val && "visible",
|
|
88
|
+
errorState.val && "hide",
|
|
89
|
+
color,
|
|
90
|
+
variant,
|
|
91
|
+
size,
|
|
92
|
+
className,
|
|
93
|
+
options?.class,
|
|
94
|
+
props.class
|
|
95
|
+
),
|
|
64
96
|
...props,
|
|
65
97
|
})
|
|
66
98
|
);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grucloud/bau-ui",
|
|
3
3
|
"description": "Components library built with Bau",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.54.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BSD",
|
|
7
7
|
"keywords": [
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"directory": "bau-ui"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@grucloud/bau": "^0.
|
|
24
|
-
"@grucloud/bau-css": "^0.
|
|
23
|
+
"@grucloud/bau": "^0.54.0",
|
|
24
|
+
"@grucloud/bau-css": "^0.54.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"typedoc": "0.24.8"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "db51837dc43765621754ba2f8bc16b7c47dd2c7f"
|
|
30
30
|
}
|