@grucloud/bau-ui 0.53.0 → 0.54.0

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 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 { span, img } = bau.tags;
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,15 @@ 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
+ }
34
45
  `;
35
46
  return function Avatar(...args) {
36
47
  let [
@@ -40,27 +51,44 @@ export default function (context, options = {}) {
40
51
  color = options.color ?? "neutral",
41
52
  width = 40,
42
53
  height = 40,
54
+ alt,
43
55
  ...props
44
56
  },
45
57
  ...children
46
58
  ] = toPropsAndChildren(args);
47
- return span(
59
+ const Skeleton = skeleton(context, {
60
+ class: classNames(
61
+ css`
62
+ position: absolute;
63
+ top: 0;
64
+ left: 0;
65
+ height: ${height}px;
66
+ width: ${width}px;
67
+ `,
68
+ options?.class,
69
+ props.class
70
+ ),
71
+ });
72
+
73
+ return div(
48
74
  { class: classNames(className, options?.class, props.class) },
49
- () => (loadingState.val ? "Loading..." : ""),
50
- () => errorState.val && "Error",
75
+ () => loadingState.val && Skeleton(),
76
+ () => errorState.val && alt,
51
77
  img({
52
78
  width,
53
79
  height,
54
80
  onload,
55
81
  onerror,
56
- class: classNames(
57
- color,
58
- variant,
59
- size,
60
- className,
61
- options?.class,
62
- props.class
63
- ),
82
+ class: () =>
83
+ classNames(
84
+ !errorState.val && !loadingState.val && "visible",
85
+ color,
86
+ variant,
87
+ size,
88
+ className,
89
+ options?.class,
90
+ props.class
91
+ ),
64
92
  ...props,
65
93
  })
66
94
  );
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.53.0",
4
+ "version": "0.54.0",
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.53.0",
24
- "@grucloud/bau-css": "^0.53.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": "eff9bcd249b99fb9c1ebc5d5be88edfc3c712fa6"
29
+ "gitHead": "9b8e31ede97bea288f6018f8bd5e03247906e405"
30
30
  }
@@ -3,7 +3,7 @@ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
3
3
 
4
4
  export default function (context, options = {}) {
5
5
  const { bau, css, keyframes } = context;
6
- const { div } = bau.tags;
6
+ const { span } = bau.tags;
7
7
 
8
8
  const opacityKeyFrame = keyframes`
9
9
  0% {
@@ -46,7 +46,7 @@ export default function (context, options = {}) {
46
46
  },
47
47
  ...children
48
48
  ] = toPropsAndChildren(args);
49
- return div(
49
+ return span(
50
50
  {
51
51
  ...props,
52
52
  class: classNames(