@julseb-lib/react 0.0.88 → 0.0.90
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 +659 -666
- package/dist/index.css +679 -570
- package/dist/index.es.js +3243 -2733
- package/dist/index.umd.js +1141 -1148
- package/dist/lib/Mixins.tsx +970 -970
- package/dist/lib/components/Avatar/Avatar.tsx +1 -1
- package/dist/lib/components/Avatar/AvatarFunction.tsx +99 -106
- package/dist/lib/components/Avatar/styles.tsx +62 -89
- package/dist/lib/components/Badge/Badge.tsx +54 -52
- package/dist/lib/components/Image/Image.tsx +77 -73
- package/dist/lib/components/Image/ImageFunction.tsx +39 -37
- package/dist/lib/components/Timepicker/Timepicker.tsx +234 -235
- package/dist/lib/components/Youtube/types.ts +5 -4
- package/dist/lib/index.css +679 -570
- package/dist/lib/index.ts +56 -55
- package/dist/lib/types/global.ts +129 -128
- package/dist/lib/types/index.ts +0 -1
- package/license.md +21 -0
- package/package.json +1 -1
- /package/dist/lib/{types/design-tokens.ts → design-tokens.ts} +0 -0
|
@@ -5,125 +5,118 @@ import { Image } from "../../"
|
|
|
5
5
|
import { appendStyles } from "../../lib-utils"
|
|
6
6
|
import { LibIcon } from "../LibIcon"
|
|
7
7
|
import type { LibComponentBase } from "../../types"
|
|
8
|
-
import { StyledAvatar
|
|
8
|
+
import { StyledAvatar } from "./styles"
|
|
9
9
|
import type { ILibAvatar } from "./types"
|
|
10
10
|
|
|
11
11
|
type IAvatarFunction = Pick<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
ILibAvatar,
|
|
13
|
+
| "data-testid"
|
|
14
|
+
| "as"
|
|
15
|
+
| "className"
|
|
16
|
+
| "id"
|
|
17
|
+
| "backgroundColor"
|
|
18
|
+
| "border"
|
|
19
|
+
| "borderRadius"
|
|
20
|
+
| "size"
|
|
21
|
+
| "contentColor"
|
|
22
|
+
| "img"
|
|
23
|
+
| "letter"
|
|
24
|
+
| "icon"
|
|
25
|
+
| "iconSize"
|
|
26
|
+
| "iconBaseUrl"
|
|
27
|
+
| "fontSize"
|
|
28
28
|
> &
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
LibComponentBase<HTMLSpanElement> & {
|
|
30
|
+
hasBadge?: boolean
|
|
31
|
+
}
|
|
32
32
|
|
|
33
33
|
export const AvatarFunction: FC<IAvatarFunction> = ({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
34
|
+
"data-testid": testid,
|
|
35
|
+
as,
|
|
36
|
+
ref,
|
|
37
|
+
className,
|
|
38
|
+
id,
|
|
39
|
+
hasBadge,
|
|
40
|
+
backgroundColor,
|
|
41
|
+
border,
|
|
42
|
+
borderRadius,
|
|
43
|
+
size = 48,
|
|
44
|
+
contentColor,
|
|
45
|
+
img,
|
|
46
|
+
letter,
|
|
47
|
+
icon,
|
|
48
|
+
iconSize,
|
|
49
|
+
iconBaseUrl,
|
|
50
|
+
fontSize = "body",
|
|
51
|
+
...rest
|
|
52
52
|
}) => {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
const randomClass = getRandomString(10, true)
|
|
54
|
+
const withClass = className?.split(" ")[0] || randomClass
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
appendStyles(`
|
|
57
57
|
${id ? `#${id}` : `.${withClass}`} {
|
|
58
58
|
--avatar-size: ${size}px;
|
|
59
59
|
}
|
|
60
60
|
`)
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
data-testid={hasBadge && testid ? `${testid}.Avatar` : testid}
|
|
65
|
-
ref={!hasBadge ? ref : undefined}
|
|
66
|
-
as={!hasBadge ? as : "span"}
|
|
67
|
-
id={id}
|
|
68
|
-
className={classNames(
|
|
69
|
-
hasBadge && className ? `Avatar` : className,
|
|
70
|
-
randomClass
|
|
71
|
-
)}
|
|
72
|
-
$backgroundColor={backgroundColor}
|
|
73
|
-
$border={border}
|
|
74
|
-
$borderRadius={borderRadius}
|
|
75
|
-
$size={size}
|
|
76
|
-
$contentColor={contentColor}
|
|
77
|
-
$fontSize={fontSize}
|
|
78
|
-
{...rest}
|
|
79
|
-
>
|
|
80
|
-
{img && (
|
|
81
|
-
<Image
|
|
82
|
-
data-testid={testid && `${testid}.Image`}
|
|
83
|
-
className={className && "Image"}
|
|
84
|
-
src={typeof img === "object" ? img.src : img}
|
|
85
|
-
alt={typeof img === "object" ? img.alt : "Avatar"}
|
|
86
|
-
width="100%"
|
|
87
|
-
height="100%"
|
|
88
|
-
fit="cover"
|
|
89
|
-
imgFallback={
|
|
90
|
-
typeof img === "object"
|
|
91
|
-
? { text: img.fallback || "", fontSize }
|
|
92
|
-
: undefined
|
|
93
|
-
}
|
|
94
|
-
fallback={
|
|
95
|
-
typeof img === "object" ? (
|
|
96
|
-
// @ts-ignore
|
|
97
|
-
<StyledFallback
|
|
98
|
-
$backgroundColor={
|
|
99
|
-
img.fallbackBackgroundColor ??
|
|
100
|
-
backgroundColor
|
|
101
|
-
}
|
|
102
|
-
$fontColor={
|
|
103
|
-
img.fallbackFontColor ?? contentColor
|
|
104
|
-
}
|
|
105
|
-
$size={size}
|
|
106
|
-
$fontSize={img.fallbackFontSize ?? fontSize}
|
|
107
|
-
>
|
|
108
|
-
{img.fallback}
|
|
109
|
-
</StyledFallback>
|
|
110
|
-
) : undefined
|
|
111
|
-
}
|
|
112
|
-
/>
|
|
113
|
-
)}
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
console.log(img?.fallbackBackgroundColor)
|
|
114
64
|
|
|
115
|
-
|
|
65
|
+
return (
|
|
66
|
+
<StyledAvatar
|
|
67
|
+
data-testid={hasBadge && testid ? `${testid}.Avatar` : testid}
|
|
68
|
+
ref={!hasBadge ? ref : undefined}
|
|
69
|
+
as={!hasBadge ? as : "span"}
|
|
70
|
+
id={id}
|
|
71
|
+
className={classNames(
|
|
72
|
+
hasBadge && className ? `Avatar` : className,
|
|
73
|
+
randomClass
|
|
74
|
+
)}
|
|
75
|
+
$backgroundColor={backgroundColor}
|
|
76
|
+
$border={border}
|
|
77
|
+
$borderRadius={borderRadius}
|
|
78
|
+
$size={size}
|
|
79
|
+
$contentColor={contentColor}
|
|
80
|
+
$fontSize={fontSize}
|
|
81
|
+
{...rest}
|
|
82
|
+
>
|
|
83
|
+
{img && (
|
|
84
|
+
<Image
|
|
85
|
+
data-testid={testid && `${testid}.Image`}
|
|
86
|
+
className={className && "Image"}
|
|
87
|
+
src={typeof img === "object" ? img.src : img}
|
|
88
|
+
alt={typeof img === "object" ? img.alt : "Avatar"}
|
|
89
|
+
width="100%"
|
|
90
|
+
height="100%"
|
|
91
|
+
fit="cover"
|
|
92
|
+
imgFallback={
|
|
93
|
+
typeof img === "object"
|
|
94
|
+
? {
|
|
95
|
+
text: img.fallback ?? "",
|
|
96
|
+
fontSize: img.fallbackFontSize ?? fontSize,
|
|
97
|
+
background:
|
|
98
|
+
img.fallbackBackgroundColor ??
|
|
99
|
+
backgroundColor,
|
|
100
|
+
textColor:
|
|
101
|
+
img.fallbackFontColor ?? contentColor,
|
|
102
|
+
}
|
|
103
|
+
: undefined
|
|
104
|
+
}
|
|
105
|
+
/>
|
|
106
|
+
)}
|
|
116
107
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
108
|
+
{letter && letter}
|
|
109
|
+
|
|
110
|
+
{icon && (
|
|
111
|
+
<LibIcon
|
|
112
|
+
data-testid={testid && `${testid}.Icon`}
|
|
113
|
+
className={className && "Icon"}
|
|
114
|
+
icon={icon}
|
|
115
|
+
size={iconSize}
|
|
116
|
+
color={contentColor}
|
|
117
|
+
baseUrl={iconBaseUrl}
|
|
118
|
+
/>
|
|
119
|
+
)}
|
|
120
|
+
</StyledAvatar>
|
|
121
|
+
)
|
|
129
122
|
}
|
|
@@ -1,115 +1,88 @@
|
|
|
1
1
|
import type { FC } from "react"
|
|
2
2
|
import styled, { css } from "styled-components"
|
|
3
|
-
import {
|
|
4
|
-
setDefaultTheme,
|
|
5
|
-
Badge,
|
|
6
|
-
Mixins,
|
|
7
|
-
FONT_WEIGHTS,
|
|
8
|
-
SPACERS,
|
|
9
|
-
stringifyPx,
|
|
10
|
-
} from "../../"
|
|
3
|
+
import { setDefaultTheme, Badge, Mixins, FONT_WEIGHTS, SPACERS } from "../../"
|
|
11
4
|
import type {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
LibAllColors,
|
|
6
|
+
ILibBorder,
|
|
7
|
+
ILibRadius,
|
|
8
|
+
LibSpacers,
|
|
9
|
+
ILibOutline,
|
|
10
|
+
LibFontSizes,
|
|
18
11
|
} from "../../types"
|
|
19
12
|
|
|
20
13
|
const Common = ({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
$borderRadius,
|
|
15
|
+
$backgroundColor,
|
|
16
|
+
$contentColor,
|
|
24
17
|
}: {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
$borderRadius?: ILibRadius
|
|
19
|
+
$backgroundColor: LibAllColors
|
|
20
|
+
$contentColor: LibAllColors
|
|
28
21
|
}) => css`
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
background-color: ${({ theme }) =>
|
|
23
|
+
Mixins.AllColors($backgroundColor, theme)};
|
|
24
|
+
color: ${({ theme }) => Mixins.AllColors($contentColor, theme)};
|
|
25
|
+
${Mixins.BorderRadius($borderRadius)};
|
|
26
|
+
${Mixins.Flexbox({
|
|
27
|
+
$inline: true,
|
|
28
|
+
$alignItems: "center",
|
|
29
|
+
$justifyContent: "center",
|
|
30
|
+
})}
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
&& {
|
|
33
|
+
width: var(--avatar-size);
|
|
34
|
+
height: var(--avatar-size);
|
|
35
|
+
}
|
|
43
36
|
`
|
|
44
37
|
|
|
45
38
|
const StyledAvatarContainer = styled.span<{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
$borderRadius?: ILibRadius
|
|
40
|
+
$backgroundColor: LibAllColors
|
|
41
|
+
$contentColor: LibAllColors
|
|
49
42
|
}>`
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
${Common}
|
|
44
|
+
position: relative;
|
|
45
|
+
padding: 0;
|
|
46
|
+
border-style: inherit;
|
|
54
47
|
`
|
|
55
48
|
|
|
56
49
|
const StyledAvatar = styled.span<{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
$border?: ILibBorder
|
|
51
|
+
$borderRadius?: ILibRadius
|
|
52
|
+
$backgroundColor: LibAllColors
|
|
53
|
+
$contentColor: LibAllColors
|
|
54
|
+
$fontSize: LibFontSizes
|
|
62
55
|
}>`
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
56
|
+
${Common}
|
|
57
|
+
${({ $border }) => Mixins.Border($border)};
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
position: relative;
|
|
60
|
+
z-index: 0;
|
|
61
|
+
font-weight: ${FONT_WEIGHTS.BLACK};
|
|
62
|
+
line-height: var(--avatar-size);
|
|
63
|
+
text-transform: uppercase;
|
|
64
|
+
font-size: ${({ $fontSize }) => Mixins.FontSize($fontSize)};
|
|
72
65
|
`
|
|
73
66
|
|
|
74
67
|
const StyledBadge = styled(Badge)<{
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
$width: number
|
|
69
|
+
$paddingLeftRight: LibSpacers | "auto"
|
|
70
|
+
$outline?: ILibOutline
|
|
78
71
|
}>`
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
position: absolute;
|
|
73
|
+
right: ${({ $width, $paddingLeftRight }) =>
|
|
74
|
+
`calc((${$width / 2}px + ${Mixins.Spacer($paddingLeftRight)}) * -1)`};
|
|
75
|
+
${({ $outline }) => Mixins.Outline($outline)}
|
|
83
76
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
&.PositionTop {
|
|
78
|
+
top: ${SPACERS.XXS};
|
|
79
|
+
}
|
|
87
80
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
&.PositionBottom {
|
|
82
|
+
bottom: ${SPACERS.XXS};
|
|
83
|
+
}
|
|
91
84
|
` as FC<any>
|
|
92
85
|
|
|
93
|
-
|
|
94
|
-
$size: number
|
|
95
|
-
$backgroundColor: LibAllColors
|
|
96
|
-
$fontColor: LibAllColors
|
|
97
|
-
$fontSize: LibFontSizes
|
|
98
|
-
}>`
|
|
99
|
-
width: ${({ $size }) => stringifyPx($size)};
|
|
100
|
-
height: ${({ $size }) => stringifyPx($size)};
|
|
101
|
-
font-weight: ${FONT_WEIGHTS.BLACK};
|
|
102
|
-
background-color: ${({ $backgroundColor, theme }) =>
|
|
103
|
-
Mixins.AllColors($backgroundColor, theme)};
|
|
104
|
-
color: ${({ $fontColor, theme }) => Mixins.AllColors($fontColor, theme)};
|
|
105
|
-
font-size: ${({ $fontSize }) => Mixins.FontSize($fontSize)};
|
|
106
|
-
`
|
|
107
|
-
|
|
108
|
-
setDefaultTheme([
|
|
109
|
-
StyledAvatarContainer,
|
|
110
|
-
StyledAvatar,
|
|
111
|
-
StyledBadge,
|
|
112
|
-
StyledFallback,
|
|
113
|
-
])
|
|
86
|
+
setDefaultTheme([StyledAvatarContainer, StyledAvatar, StyledBadge])
|
|
114
87
|
|
|
115
|
-
export { StyledAvatarContainer, StyledAvatar, StyledBadge
|
|
88
|
+
export { StyledAvatarContainer, StyledAvatar, StyledBadge }
|
|
@@ -33,65 +33,67 @@ import type { ILibBadge } from "./types"
|
|
|
33
33
|
* <Badge icon={<CustomIcon />} size={24} />
|
|
34
34
|
*/
|
|
35
35
|
export const Badge: FC<ILibBadge> = ({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
36
|
+
"data-testid": testid,
|
|
37
|
+
className,
|
|
38
|
+
ref,
|
|
39
|
+
id,
|
|
40
|
+
as,
|
|
41
|
+
size = 16,
|
|
42
|
+
icon,
|
|
43
|
+
iconSize = roundIconSize(size),
|
|
44
|
+
iconBaseUrl,
|
|
45
|
+
number,
|
|
46
|
+
backgroundColor = "primary",
|
|
47
|
+
contentColor = backgroundColor === "white"
|
|
48
|
+
? "primary"
|
|
49
|
+
: backgroundColor === "black"
|
|
50
|
+
? "white"
|
|
51
|
+
: backgroundColor === "background"
|
|
52
|
+
? "font"
|
|
53
|
+
: "background",
|
|
54
|
+
borderRadius = "round",
|
|
55
|
+
padding = {
|
|
56
|
+
leftRight: "xs",
|
|
57
|
+
},
|
|
58
|
+
...rest
|
|
57
59
|
}) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
const randomClass = getRandomString(10, true)
|
|
61
|
+
const withClass = className?.split(" ")[0] || randomClass
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
appendStyles(`
|
|
62
64
|
${id ? `#${id}` : `.${withClass}`} {
|
|
63
65
|
--badge-size: ${size}px;
|
|
64
66
|
--badge-font-size: ${roundIconSize(size)}px;
|
|
65
67
|
}
|
|
66
68
|
`)
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
70
|
+
return (
|
|
71
|
+
<StyledBadge
|
|
72
|
+
data-testid={testid}
|
|
73
|
+
ref={ref}
|
|
74
|
+
as={as}
|
|
75
|
+
className={classNames(className, randomClass)}
|
|
76
|
+
id={id}
|
|
77
|
+
$backgroundColor={backgroundColor}
|
|
78
|
+
$contentColor={contentColor}
|
|
79
|
+
$borderRadius={borderRadius}
|
|
80
|
+
$padding={padding}
|
|
81
|
+
$hasChildren={!!(icon || number)}
|
|
82
|
+
$childrenLength={number?.toString().length}
|
|
83
|
+
{...rest}
|
|
84
|
+
>
|
|
85
|
+
{icon && (
|
|
86
|
+
<LibIcon
|
|
87
|
+
data-testid={testid && `${testid}.Icon`}
|
|
88
|
+
className={className && "Icon"}
|
|
89
|
+
icon={icon}
|
|
90
|
+
color={contentColor}
|
|
91
|
+
size={iconSize}
|
|
92
|
+
baseUrl={iconBaseUrl}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
{number}
|
|
97
|
+
</StyledBadge>
|
|
98
|
+
)
|
|
97
99
|
}
|