@julseb-lib/react 0.0.28 → 0.0.30

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.
@@ -7,7 +7,7 @@ import { Image } from "../../"
7
7
  import { appendStyles } from "../../lib-utils"
8
8
  import { LibIcon } from "../LibIcon"
9
9
  import type { LibComponentBase } from "../../types"
10
- import { StyledAvatar } from "./styles"
10
+ import { StyledAvatar, StyledFallback } from "./styles"
11
11
  import type { ILibAvatar } from "./types"
12
12
 
13
13
  export const AvatarFunction = forwardRef<
@@ -98,7 +98,22 @@ export const AvatarFunction = forwardRef<
98
98
  : undefined
99
99
  }
100
100
  fallback={
101
- typeof img === "object" ? img.fallback : undefined
101
+ typeof img === "object" ? (
102
+ // @ts-ignore
103
+ <StyledFallback
104
+ $backgroundColor={
105
+ img.fallbackBackgroundColor ??
106
+ backgroundColor
107
+ }
108
+ $fontColor={
109
+ img.fallbackFontColor ?? contentColor
110
+ }
111
+ $size={size}
112
+ $fontSize={img.fallbackFontSize ?? fontSize}
113
+ >
114
+ {img.fallback}
115
+ </StyledFallback>
116
+ ) : undefined
102
117
  }
103
118
  />
104
119
  )}
@@ -2,7 +2,14 @@
2
2
 
3
3
  import type { FC } from "react"
4
4
  import styled, { css } from "styled-components"
5
- import { setDefaultTheme, Badge, Mixins, FONT_WEIGHTS, SPACERS } from "../../"
5
+ import {
6
+ setDefaultTheme,
7
+ Badge,
8
+ Mixins,
9
+ FONT_WEIGHTS,
10
+ SPACERS,
11
+ stringifyPx,
12
+ } from "../../"
6
13
  import type {
7
14
  LibAllColors,
8
15
  ILibBorder,
@@ -85,6 +92,26 @@ const StyledBadge = styled(Badge)<{
85
92
  }
86
93
  ` as FC<any>
87
94
 
88
- setDefaultTheme([StyledAvatarContainer, StyledAvatar, StyledBadge])
95
+ const StyledFallback = styled.span<{
96
+ $size: number
97
+ $backgroundColor: LibAllColors
98
+ $fontColor: LibAllColors
99
+ $fontSize: LibFontSizes
100
+ }>`
101
+ width: ${({ $size }) => stringifyPx($size)};
102
+ height: ${({ $size }) => stringifyPx($size)};
103
+ font-weight: ${FONT_WEIGHTS.BLACK};
104
+ background-color: ${({ $backgroundColor, theme }) =>
105
+ Mixins.AllColors($backgroundColor, theme)};
106
+ color: ${({ $fontColor, theme }) => Mixins.AllColors($fontColor, theme)};
107
+ font-size: ${({ $fontSize }) => Mixins.FontSize($fontSize)};
108
+ `
109
+
110
+ setDefaultTheme([
111
+ StyledAvatarContainer,
112
+ StyledAvatar,
113
+ StyledBadge,
114
+ StyledFallback,
115
+ ])
89
116
 
90
- export { StyledAvatarContainer, StyledAvatar, StyledBadge }
117
+ export { StyledAvatarContainer, StyledAvatar, StyledBadge, StyledFallback }
@@ -25,6 +25,9 @@ interface AvatarWithImage extends ILibAvatarBase {
25
25
  src: string
26
26
  alt: string
27
27
  fallback?: string
28
+ fallbackFontSize?: LibFontSizes
29
+ fallbackFontColor?: LibAllColors
30
+ fallbackBackgroundColor?: LibAllColors
28
31
  }
29
32
  letter?: never
30
33
  fontSize?: never
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@julseb-lib/react",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "scripts": {