@budibase/bbui 2.6.19-alpha.26 → 2.6.19-alpha.28

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/bbui",
3
3
  "description": "A UI solution used in the different Budibase projects.",
4
- "version": "2.6.19-alpha.26",
4
+ "version": "2.6.19-alpha.28",
5
5
  "license": "MPL-2.0",
6
6
  "svelte": "src/index.js",
7
7
  "module": "dist/bbui.es.js",
@@ -38,8 +38,8 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@adobe/spectrum-css-workflow-icons": "1.2.1",
41
- "@budibase/shared-core": "2.6.19-alpha.26",
42
- "@budibase/string-templates": "2.6.19-alpha.26",
41
+ "@budibase/shared-core": "2.6.19-alpha.28",
42
+ "@budibase/string-templates": "2.6.19-alpha.28",
43
43
  "@spectrum-css/accordion": "3.0.24",
44
44
  "@spectrum-css/actionbutton": "1.0.1",
45
45
  "@spectrum-css/actiongroup": "1.0.1",
@@ -104,5 +104,5 @@
104
104
  }
105
105
  }
106
106
  },
107
- "gitHead": "dbeebc571d598a9a6696dbc15e9b1e38e66a80a3"
107
+ "gitHead": "11c9bcc5f5b0a6c900474ab3f90371767132bd35"
108
108
  }
@@ -13,10 +13,12 @@
13
13
  export let url = ""
14
14
  export let disabled = false
15
15
  export let initials = "JD"
16
+ export let color = null
16
17
 
17
18
  const DefaultColor = "#3aab87"
18
19
 
19
- $: color = getColor(initials)
20
+ $: avatarColor = color || getColor(initials)
21
+ $: style = getStyle(size, avatarColor)
20
22
 
21
23
  const getColor = initials => {
22
24
  if (!initials?.length) {
@@ -26,6 +28,12 @@
26
28
  const hue = ((code % 26) / 26) * 360
27
29
  return `hsl(${hue}, 50%, 50%)`
28
30
  }
31
+
32
+ const getStyle = (sizeKey, color) => {
33
+ const size = `var(${sizes.get(sizeKey)})`
34
+ const fontSize = `calc(${size} / 2)`
35
+ return `width:${size}; height:${size}; font-size:${fontSize}; background:${color};`
36
+ }
29
37
  </script>
30
38
 
31
39
  {#if url}
@@ -37,13 +45,7 @@
37
45
  style="width: var({sizes.get(size)}); height: var({sizes.get(size)});"
38
46
  />
39
47
  {:else}
40
- <div
41
- class="spectrum-Avatar"
42
- class:is-disabled={disabled}
43
- style="width: var({sizes.get(size)}); height: var({sizes.get(
44
- size
45
- )}); font-size: calc(var({sizes.get(size)}) / 2); background: {color};"
46
- >
48
+ <div class="spectrum-Avatar" class:is-disabled={disabled} {style}>
47
49
  {initials || ""}
48
50
  </div>
49
51
  {/if}