diff options
Diffstat (limited to 'src/view/com/util')
-rw-r--r-- | src/view/com/util/UserAvatar.tsx | 11 | ||||
-rw-r--r-- | src/view/com/util/UserBanner.tsx | 23 |
2 files changed, 31 insertions, 3 deletions
diff --git a/src/view/com/util/UserAvatar.tsx b/src/view/com/util/UserAvatar.tsx index 9b8ceb37a..8699bcd37 100644 --- a/src/view/com/util/UserAvatar.tsx +++ b/src/view/com/util/UserAvatar.tsx @@ -19,13 +19,13 @@ export function UserAvatar({ handle: string }) { const initials = getInitials(displayName || handle) - const gi = cyrb53(handle) % GRADIENTS.length + const gradient = getGradient(handle) return ( <Svg width={size} height={size} viewBox="0 0 100 100"> <Defs> <LinearGradient id="grad" x1="0" y1="0" x2="1" y2="1"> - <Stop offset="0" stopColor={GRADIENTS[gi][0]} stopOpacity="1" /> - <Stop offset="1" stopColor={GRADIENTS[gi][1]} stopOpacity="1" /> + <Stop offset="0" stopColor={gradient[0]} stopOpacity="1" /> + <Stop offset="1" stopColor={gradient[1]} stopOpacity="1" /> </LinearGradient> </Defs> <Circle cx="50" cy="50" r="50" fill="url(#grad)" /> @@ -42,6 +42,11 @@ export function UserAvatar({ ) } +export function getGradient(handle: string): string[] { + const gi = cyrb53(handle) % GRADIENTS.length + return GRADIENTS[gi] +} + function getInitials(str: string): string { const tokens = str .split(' ') diff --git a/src/view/com/util/UserBanner.tsx b/src/view/com/util/UserBanner.tsx new file mode 100644 index 000000000..aa7ceab83 --- /dev/null +++ b/src/view/com/util/UserBanner.tsx @@ -0,0 +1,23 @@ +import React from 'react' +import Svg, {Rect, Defs, LinearGradient, Stop} from 'react-native-svg' +import {getGradient} from './UserAvatar' + +export function UserBanner({handle}: {handle: string}) { + const gradient = getGradient(handle) + return ( + <Svg width="400" height="120" viewBox="50 0 200 100"> + <Defs> + <LinearGradient id="grad" x1="0" y1="0" x2="1" y2="1"> + <Stop offset="0" stopColor={gradient[0]} stopOpacity="1" /> + <Stop offset="1" stopColor={gradient[1]} stopOpacity="1" /> + </LinearGradient> + <LinearGradient id="grad2" x1="0" y1="0" x2="0" y2="1"> + <Stop offset="0" stopColor="#000" stopOpacity="0" /> + <Stop offset="1" stopColor="#000" stopOpacity="0.7" /> + </LinearGradient> + </Defs> + <Rect x="0" y="0" width="400" height="100" fill="url(#grad)" /> + <Rect x="0" y="0" width="400" height="100" fill="url(#grad2)" /> + </Svg> + ) +} |