@rpcbase/client 0.81.0 → 0.84.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/auth/AccountsList/AccountListItem.js +2 -3
- package/auth/SignUp/index.js +1 -1
- package/helpers/getInitials.js +39 -0
- package/helpers/getInitials.test.js +22 -0
- package/package.json +2 -1
- package/ui/Avatar/index.native.js +31 -0
- package/ui/Avatar/index.web.js +40 -0
- package/ui/Avatar/styles.js +41 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
import assert from "assert"
|
|
3
|
-
import {useTranslation} from "react-i18next"
|
|
4
3
|
import page from "page"
|
|
5
4
|
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import getInitials from "../../helpers/getInitials"
|
|
6
|
+
import Avatar from "../../ui/Avatar"
|
|
8
7
|
|
|
9
8
|
import "./account-list-item.scss"
|
|
10
9
|
|
package/auth/SignUp/index.js
CHANGED
|
@@ -27,7 +27,7 @@ const SignUp = ({
|
|
|
27
27
|
setError("Passwords do not match")
|
|
28
28
|
return
|
|
29
29
|
}
|
|
30
|
-
const res = await post("/
|
|
30
|
+
const res = await post("/public/v1/auth/sign_up", {email, password})
|
|
31
31
|
|
|
32
32
|
if (res.status === "ok") {
|
|
33
33
|
const {user_id} = res
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
const _deburr = require("lodash/deburr")
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const KNOWN_PREFIXES = ["O", "de", "Van"]
|
|
6
|
+
const INITIALS_MAX_LENGTH = 3
|
|
7
|
+
|
|
8
|
+
const getInitials = (input) => {
|
|
9
|
+
const cleaned = _deburr(input)
|
|
10
|
+
|
|
11
|
+
const initials = []
|
|
12
|
+
|
|
13
|
+
const splitted = cleaned.split(/'|’| |-/)
|
|
14
|
+
|
|
15
|
+
// when single word, return begining of that word as initials
|
|
16
|
+
if (splitted.length === 1) {
|
|
17
|
+
return splitted[0].toUpperCase().slice(0, INITIALS_MAX_LENGTH)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
for (let i = 0; i < splitted.length; i++) {
|
|
21
|
+
const part = splitted[i]
|
|
22
|
+
// TMP: this breaks for lowercased words
|
|
23
|
+
// skip if first letter not capitalized
|
|
24
|
+
// if (!/[A-Z]/.test(part[0])) {
|
|
25
|
+
// continue
|
|
26
|
+
// }
|
|
27
|
+
|
|
28
|
+
// skip if prefix, but not if prefix not followed by other non prefix word
|
|
29
|
+
if (KNOWN_PREFIXES.includes(part) && i < splitted.length - 1) {
|
|
30
|
+
continue
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
initials.push(part[0])
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return initials.slice(0, INITIALS_MAX_LENGTH).join("")
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = getInitials
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
const getInitials = require("./getInitials")
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const inputs = [
|
|
6
|
+
["Philippe de Reynal", "PR"],
|
|
7
|
+
["Sarah Connor", "SC"],
|
|
8
|
+
["Sarah O'Connor", "SC"],
|
|
9
|
+
["Cédric O", "CO"],
|
|
10
|
+
["Chloë Grace Moretz", "CGM"],
|
|
11
|
+
["Ella Marija Lani Yelich-O'Connor", "EML"],
|
|
12
|
+
["Hannah John-Kamen", "HJK"],
|
|
13
|
+
["npm", "NPM"],
|
|
14
|
+
["Apple", "APP"],
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
inputs.forEach((i) => {
|
|
18
|
+
test(i[0], () => {
|
|
19
|
+
const initials = getInitials(i[0])
|
|
20
|
+
expect(initials).toBe(i[1])
|
|
21
|
+
})
|
|
22
|
+
})
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.84.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build-firebase": "webpack -c firebase/webpack.config.js",
|
|
6
6
|
"build": "yarn build-firebase",
|
|
7
7
|
"test": "jest"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
+
"figma-squircle": "0.3.1",
|
|
10
11
|
"i18next": "23.4.4",
|
|
11
12
|
"i18next-chained-backend": "4.4.0",
|
|
12
13
|
"i18next-resources-to-backend": "1.1.4",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
import {Text, View} from "react-native"
|
|
3
|
+
|
|
4
|
+
// import View from "ui/View"
|
|
5
|
+
|
|
6
|
+
import {SIZE_STYLES} from "./styles"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const Avatar = ({size = "medium", style = {}, text = "?", color = "#000", textColor = "#FFF"}) => {
|
|
10
|
+
const sizeStyles = SIZE_STYLES[size]
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<View
|
|
14
|
+
className={"font-monospace"}
|
|
15
|
+
style={{
|
|
16
|
+
justifyContent: "center",
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
backgroundColor: color,
|
|
19
|
+
userSelect: "none",
|
|
20
|
+
...sizeStyles,
|
|
21
|
+
...style,
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
<Text style={{color: textColor}}>{text}</Text>
|
|
25
|
+
</View>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default Avatar
|
|
30
|
+
|
|
31
|
+
export {SIZE_STYLES}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
import {Text} from "react-native"
|
|
3
|
+
|
|
4
|
+
import {SIZE_STYLES} from "./styles"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const Avatar = ({
|
|
8
|
+
className = "",
|
|
9
|
+
size = "medium",
|
|
10
|
+
style = {},
|
|
11
|
+
text = "?",
|
|
12
|
+
color = "#000",
|
|
13
|
+
textColor = "#FFF",
|
|
14
|
+
}) => {
|
|
15
|
+
const sizeStyles = SIZE_STYLES[size]
|
|
16
|
+
|
|
17
|
+
// TODO: too many re-renders in conv sidebar
|
|
18
|
+
// console.log("RENDER AVATAR", text)
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div
|
|
22
|
+
className={cx("font-monospace", className)}
|
|
23
|
+
style={{
|
|
24
|
+
display: "flex",
|
|
25
|
+
justifyContent: "center",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
backgroundColor: color,
|
|
28
|
+
userSelect: "none",
|
|
29
|
+
...sizeStyles,
|
|
30
|
+
...style,
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<Text style={{color: textColor}}>{text}</Text>
|
|
34
|
+
</div>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default Avatar
|
|
39
|
+
|
|
40
|
+
export {SIZE_STYLES}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
import {getSvgPath} from "figma-squircle"
|
|
3
|
+
import {Platform} from "react-native"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const CORNER_SMOOTHING = 0.82
|
|
7
|
+
|
|
8
|
+
const getSizeProps = ({size, smoothRadius, fallbackRadius}) => ({
|
|
9
|
+
width: size,
|
|
10
|
+
height: size,
|
|
11
|
+
...Platform.select({
|
|
12
|
+
web: {
|
|
13
|
+
clipPath: `path('${getSvgPath({
|
|
14
|
+
width: size,
|
|
15
|
+
height: size,
|
|
16
|
+
cornerRadius: smoothRadius,
|
|
17
|
+
cornerSmoothing: CORNER_SMOOTHING,
|
|
18
|
+
})}')`,
|
|
19
|
+
},
|
|
20
|
+
native: {borderRadius: fallbackRadius},
|
|
21
|
+
}),
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
export const SIZE_STYLES = {
|
|
25
|
+
small: {
|
|
26
|
+
...getSizeProps({size: 22, smoothRadius: 4, fallbackRadius: 3}),
|
|
27
|
+
fontSize: 13,
|
|
28
|
+
},
|
|
29
|
+
medium: {
|
|
30
|
+
...getSizeProps({size: 34, smoothRadius: 8, fallbackRadius: 6}),
|
|
31
|
+
fontSize: 15,
|
|
32
|
+
},
|
|
33
|
+
large: {
|
|
34
|
+
...getSizeProps({size: 48, smoothRadius: 14, fallbackRadius: 6}),
|
|
35
|
+
fontSize: 26,
|
|
36
|
+
},
|
|
37
|
+
xlarge: {
|
|
38
|
+
...getSizeProps({size: 68, smoothRadius: 18, fallbackRadius: 8}),
|
|
39
|
+
fontSize: 26,
|
|
40
|
+
},
|
|
41
|
+
}
|