@julseb-lib/react 0.0.26 → 0.0.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/dist/index.cjs.js +103 -88
- package/dist/index.es.js +39 -11
- package/dist/index.umd.js +50 -35
- package/dist/lib/components/Avatar/AvatarFunction.tsx +8 -0
- package/dist/lib/components/Avatar/styles.tsx +3 -0
- package/dist/lib/components/Avatar/types.ts +11 -1
- package/dist/lib/components/Image/ImageFunction.tsx +7 -0
- package/dist/lib/components/Image/styles.tsx +25 -1
- package/dist/lib/components/Image/types.ts +7 -0
- package/package.json +1 -1
|
@@ -28,6 +28,7 @@ export const AvatarFunction = forwardRef<
|
|
|
28
28
|
| "icon"
|
|
29
29
|
| "iconSize"
|
|
30
30
|
| "iconBaseUrl"
|
|
31
|
+
| "fontSize"
|
|
31
32
|
> &
|
|
32
33
|
LibComponentBase<HTMLSpanElement> & {
|
|
33
34
|
hasBadge?: boolean
|
|
@@ -50,6 +51,7 @@ export const AvatarFunction = forwardRef<
|
|
|
50
51
|
icon,
|
|
51
52
|
iconSize,
|
|
52
53
|
iconBaseUrl,
|
|
54
|
+
fontSize = "body",
|
|
53
55
|
...rest
|
|
54
56
|
},
|
|
55
57
|
ref
|
|
@@ -78,6 +80,7 @@ export const AvatarFunction = forwardRef<
|
|
|
78
80
|
$borderRadius={borderRadius}
|
|
79
81
|
$size={size}
|
|
80
82
|
$contentColor={contentColor}
|
|
83
|
+
$fontSize={fontSize}
|
|
81
84
|
{...rest}
|
|
82
85
|
>
|
|
83
86
|
{img && (
|
|
@@ -89,6 +92,11 @@ export const AvatarFunction = forwardRef<
|
|
|
89
92
|
width="100%"
|
|
90
93
|
height="100%"
|
|
91
94
|
fit="cover"
|
|
95
|
+
imgFallback={
|
|
96
|
+
typeof img === "object"
|
|
97
|
+
? { text: img.fallback || "", fontSize }
|
|
98
|
+
: undefined
|
|
99
|
+
}
|
|
92
100
|
fallback={
|
|
93
101
|
typeof img === "object" ? img.fallback : undefined
|
|
94
102
|
}
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
ILibRadius,
|
|
10
10
|
LibSpacers,
|
|
11
11
|
ILibOutline,
|
|
12
|
+
LibFontSizes,
|
|
12
13
|
} from "../../types"
|
|
13
14
|
|
|
14
15
|
const Common = ({
|
|
@@ -52,6 +53,7 @@ const StyledAvatar = styled.span<{
|
|
|
52
53
|
$borderRadius?: ILibRadius
|
|
53
54
|
$backgroundColor: LibAllColors
|
|
54
55
|
$contentColor: LibAllColors
|
|
56
|
+
$fontSize: LibFontSizes
|
|
55
57
|
}>`
|
|
56
58
|
${Common}
|
|
57
59
|
${({ $border }) => Mixins.Border($border)};
|
|
@@ -61,6 +63,7 @@ const StyledAvatar = styled.span<{
|
|
|
61
63
|
font-weight: ${FONT_WEIGHTS.BLACK};
|
|
62
64
|
line-height: var(--avatar-size);
|
|
63
65
|
text-transform: uppercase;
|
|
66
|
+
font-size: ${({ $fontSize }) => Mixins.FontSize($fontSize)};
|
|
64
67
|
`
|
|
65
68
|
|
|
66
69
|
const StyledBadge = styled(Badge)<{
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
ILibPadding,
|
|
10
10
|
LibIcon,
|
|
11
11
|
LibAvatarBadgePosition,
|
|
12
|
+
LibFontSizes,
|
|
12
13
|
} from "../../types"
|
|
13
14
|
|
|
14
15
|
interface ILibAvatarBase extends LibComponentBase<HTMLSpanElement> {
|
|
@@ -18,8 +19,15 @@ interface ILibAvatarBase extends LibComponentBase<HTMLSpanElement> {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
interface AvatarWithImage extends ILibAvatarBase {
|
|
21
|
-
img:
|
|
22
|
+
img:
|
|
23
|
+
| string
|
|
24
|
+
| {
|
|
25
|
+
src: string
|
|
26
|
+
alt: string
|
|
27
|
+
fallback?: string
|
|
28
|
+
}
|
|
22
29
|
letter?: never
|
|
30
|
+
fontSize?: never
|
|
23
31
|
icon?: never
|
|
24
32
|
iconSize?: never
|
|
25
33
|
iconBaseUrl?: never
|
|
@@ -30,6 +38,7 @@ interface AvatarWithImage extends ILibAvatarBase {
|
|
|
30
38
|
interface AvatarWithLetter extends ILibAvatarBase {
|
|
31
39
|
img?: never
|
|
32
40
|
letter: string
|
|
41
|
+
fontSize?: LibFontSizes
|
|
33
42
|
icon?: never
|
|
34
43
|
iconSize?: never
|
|
35
44
|
iconBaseUrl?: never
|
|
@@ -40,6 +49,7 @@ interface AvatarWithLetter extends ILibAvatarBase {
|
|
|
40
49
|
interface AvatarWithIcon extends ILibAvatarBase {
|
|
41
50
|
img?: never
|
|
42
51
|
letter?: never
|
|
52
|
+
fontSize?: never
|
|
43
53
|
icon: LibIcon
|
|
44
54
|
iconSize?: number
|
|
45
55
|
iconBaseUrl?: string
|
|
@@ -19,6 +19,8 @@ export const ImageFunction = forwardRef<HTMLImageElement, ILibImage>(
|
|
|
19
19
|
height = "auto",
|
|
20
20
|
borderRadius,
|
|
21
21
|
fit,
|
|
22
|
+
loading = "lazy",
|
|
23
|
+
imgFallback,
|
|
22
24
|
...rest
|
|
23
25
|
},
|
|
24
26
|
ref
|
|
@@ -33,11 +35,16 @@ export const ImageFunction = forwardRef<HTMLImageElement, ILibImage>(
|
|
|
33
35
|
ref={ref}
|
|
34
36
|
src={src}
|
|
35
37
|
alt={alt}
|
|
38
|
+
loading={loading}
|
|
39
|
+
data-fallback={imgFallback?.text}
|
|
36
40
|
$aspectRatio={aspectRatio}
|
|
37
41
|
$width={width}
|
|
38
42
|
$height={height}
|
|
39
43
|
$borderRadius={borderRadius}
|
|
40
44
|
$fit={fit}
|
|
45
|
+
$fallbackBackground={imgFallback?.background ?? "primary"}
|
|
46
|
+
$fallbackTextColor={imgFallback?.textColor ?? "background"}
|
|
47
|
+
$fallbackFontSize={imgFallback?.fontSize ?? "body"}
|
|
41
48
|
{...rest}
|
|
42
49
|
/>
|
|
43
50
|
</Suspense>
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
import type { FC } from "react"
|
|
4
4
|
import styled from "styled-components"
|
|
5
5
|
import { stringifyPx } from "@julseb-lib/utils"
|
|
6
|
-
import { setDefaultTheme, Text, Mixins, SPACERS } from "../../"
|
|
6
|
+
import { setDefaultTheme, Text, Mixins, SPACERS, FONT_WEIGHTS } from "../../"
|
|
7
7
|
import type {
|
|
8
8
|
LibAllColors,
|
|
9
9
|
ILibRadius,
|
|
10
10
|
CssObjectFit,
|
|
11
11
|
LibImageBackgroundOverlay,
|
|
12
|
+
LibFontSizes,
|
|
12
13
|
} from "../../types"
|
|
13
14
|
|
|
14
15
|
const StyledImage = styled.img<{
|
|
@@ -17,6 +18,9 @@ const StyledImage = styled.img<{
|
|
|
17
18
|
$borderRadius?: ILibRadius
|
|
18
19
|
$fit?: CssObjectFit
|
|
19
20
|
$aspectRatio?: string
|
|
21
|
+
$fallbackBackground: LibAllColors
|
|
22
|
+
$fallbackTextColor: LibAllColors
|
|
23
|
+
$fallbackFontSize?: LibFontSizes
|
|
20
24
|
}>`
|
|
21
25
|
display: block;
|
|
22
26
|
width: ${({ $width }) => stringifyPx($width)};
|
|
@@ -26,6 +30,26 @@ const StyledImage = styled.img<{
|
|
|
26
30
|
position: relative;
|
|
27
31
|
z-index: 0;
|
|
28
32
|
${({ $borderRadius }) => Mixins.BorderRadius($borderRadius)}
|
|
33
|
+
|
|
34
|
+
&[alt]:after {
|
|
35
|
+
position: absolute;
|
|
36
|
+
top: 0;
|
|
37
|
+
left: 0;
|
|
38
|
+
${Mixins.Flexbox({
|
|
39
|
+
$alignItems: "center",
|
|
40
|
+
$justifyContent: "center",
|
|
41
|
+
})};
|
|
42
|
+
width: 100%;
|
|
43
|
+
height: 100%;
|
|
44
|
+
background-color: ${({ $fallbackBackground, theme }) =>
|
|
45
|
+
Mixins.AllColors($fallbackBackground, theme)};
|
|
46
|
+
color: ${({ $fallbackTextColor, theme }) =>
|
|
47
|
+
Mixins.AllColors($fallbackTextColor, theme)};
|
|
48
|
+
content: attr(data-fallback);
|
|
49
|
+
font-weight: ${FONT_WEIGHTS.BOLD};
|
|
50
|
+
font-size: ${({ $fallbackFontSize }) =>
|
|
51
|
+
Mixins.FontSize($fallbackFontSize)};
|
|
52
|
+
}
|
|
29
53
|
`
|
|
30
54
|
|
|
31
55
|
const ImgContainer = styled.figure<{
|
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
CssObjectFit,
|
|
8
8
|
LibAllColors,
|
|
9
9
|
LibImageBackgroundOverlay,
|
|
10
|
+
LibFontSizes,
|
|
10
11
|
} from "../../types"
|
|
11
12
|
|
|
12
13
|
interface ILibImageBase
|
|
@@ -16,6 +17,12 @@ interface ILibImageBase
|
|
|
16
17
|
fit?: CssObjectFit
|
|
17
18
|
aspectRatio?: string
|
|
18
19
|
fallback?: JSX.Element | string
|
|
20
|
+
imgFallback?: {
|
|
21
|
+
text: string
|
|
22
|
+
background?: LibAllColors
|
|
23
|
+
textColor?: LibAllColors
|
|
24
|
+
fontSize?: LibFontSizes
|
|
25
|
+
}
|
|
19
26
|
children?: never
|
|
20
27
|
}
|
|
21
28
|
|