@startupjs-ui/user 0.1.3
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/CHANGELOG.md +25 -0
- package/README.mdx +175 -0
- package/index.cssx.styl +47 -0
- package/index.d.ts +34 -0
- package/index.tsx +81 -0
- package/package.json +22 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [0.1.3](https://github.com/startupjs/startupjs-ui/compare/v0.1.2...v0.1.3) (2025-12-29)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @startupjs-ui/user
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.1.2](https://github.com/startupjs/startupjs-ui/compare/v0.1.1...v0.1.2) (2025-12-29)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **user/readme:** minor ([56b16c1](https://github.com/startupjs/startupjs-ui/commit/56b16c1ebce2e5b5ce98ae672901866544e47dba))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* add mdx and docs packages. Refactor docs to get rid of any @startupjs/ui usage and use startupjs-ui instead ([703c926](https://github.com/startupjs/startupjs-ui/commit/703c92636efb0421ffd11783f692fc892b74018f))
|
|
25
|
+
* **user:** refactor User component ([c8d5494](https://github.com/startupjs/startupjs-ui/commit/c8d5494d2d709cb5f676118b524893e8207b39de))
|
package/README.mdx
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react'
|
|
2
|
+
import { pug, styl } from 'startupjs'
|
|
3
|
+
import { Sandbox } from '@startupjs-ui/docs'
|
|
4
|
+
import Div from '@startupjs-ui/div'
|
|
5
|
+
import Br from '@startupjs-ui/br'
|
|
6
|
+
import Span from '@startupjs-ui/span'
|
|
7
|
+
import User, { _PropsJsonSchema as UserPropsJsonSchema } from './index'
|
|
8
|
+
|
|
9
|
+
# User
|
|
10
|
+
|
|
11
|
+
Inherits [Div props](/docs/components/Div).
|
|
12
|
+
|
|
13
|
+
User is used to display information about users. It uses [Avatar](/docs/components/Avatar) component to display user avatar.
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
import { User } from 'startupjs-ui'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Simple example
|
|
20
|
+
|
|
21
|
+
```jsx example
|
|
22
|
+
return (
|
|
23
|
+
<User avatarUrl='/img/avatar1.jpeg' />
|
|
24
|
+
)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Sizes
|
|
28
|
+
|
|
29
|
+
Size is `m` by default. It can be changed by changing `size` prop. Possible values of property can be found in the `Sandbox` section at the bottom of the page.
|
|
30
|
+
|
|
31
|
+
```jsx example
|
|
32
|
+
return (
|
|
33
|
+
<Div>
|
|
34
|
+
<User
|
|
35
|
+
size='s'
|
|
36
|
+
avatarUrl='/img/avatar2.jpeg'
|
|
37
|
+
name='John Doe'
|
|
38
|
+
description='s size'
|
|
39
|
+
/>
|
|
40
|
+
<Br />
|
|
41
|
+
<User
|
|
42
|
+
avatarUrl='/img/avatar3.jpeg'
|
|
43
|
+
name='John Doe'
|
|
44
|
+
description='m size, this is the default size'
|
|
45
|
+
/>
|
|
46
|
+
<Br />
|
|
47
|
+
<User
|
|
48
|
+
size='l'
|
|
49
|
+
avatarUrl='/img/avatar1.jpeg'
|
|
50
|
+
name='John Doe'
|
|
51
|
+
description='l size'
|
|
52
|
+
/>
|
|
53
|
+
</Div>
|
|
54
|
+
)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## User status
|
|
58
|
+
|
|
59
|
+
To display user online status on avatar you can pass string `online` or `away` to property `status`.
|
|
60
|
+
|
|
61
|
+
```jsx example
|
|
62
|
+
return (
|
|
63
|
+
<Div>
|
|
64
|
+
<User
|
|
65
|
+
status='online'
|
|
66
|
+
avatarUrl='/img/avatar1.jpeg'
|
|
67
|
+
name='John Doe'
|
|
68
|
+
description='Online description'
|
|
69
|
+
/>
|
|
70
|
+
<Br />
|
|
71
|
+
<User
|
|
72
|
+
status='away'
|
|
73
|
+
avatarUrl='/img/avatar2.jpeg'
|
|
74
|
+
name='John Doe'
|
|
75
|
+
description='Offline description'
|
|
76
|
+
/>
|
|
77
|
+
</Div>
|
|
78
|
+
)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## User avatar position
|
|
82
|
+
|
|
83
|
+
Avatar position can be modified by passing string `left` (default) or `right` to `avatarPosition` property.
|
|
84
|
+
|
|
85
|
+
```jsx example
|
|
86
|
+
return (
|
|
87
|
+
<User
|
|
88
|
+
avatarPosition='right'
|
|
89
|
+
avatarUrl='/img/avatar1.jpeg'
|
|
90
|
+
name='John Doe'
|
|
91
|
+
description='The cat is a domestic species of small carnivorous mammal'
|
|
92
|
+
/>
|
|
93
|
+
)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Actions
|
|
97
|
+
|
|
98
|
+
Passed handler to `onPress` property will be called when the user taps the component.
|
|
99
|
+
|
|
100
|
+
```jsx example
|
|
101
|
+
const [clicked, setClicked] = useState(0)
|
|
102
|
+
return (
|
|
103
|
+
<Div>
|
|
104
|
+
<User
|
|
105
|
+
avatarUrl='/img/avatar1.jpeg'
|
|
106
|
+
name='John Doe'
|
|
107
|
+
description='The cat is a domestic species of small carnivorous mammal'
|
|
108
|
+
onPress={() => setClicked(clicked + 1)}
|
|
109
|
+
/>
|
|
110
|
+
<Br />
|
|
111
|
+
<Span>
|
|
112
|
+
{clicked ? `User clicked ${clicked} ${clicked === 1 ? 'time' : 'times'}` : 'Click on user'}
|
|
113
|
+
</Span>
|
|
114
|
+
</Div>
|
|
115
|
+
)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Custom status icon
|
|
119
|
+
|
|
120
|
+
You can provide custom components for the status icon using `statusComponents` prop.
|
|
121
|
+
|
|
122
|
+
```jsx example
|
|
123
|
+
const AbsentStatus = useCallback(({ style }) => (
|
|
124
|
+
<Div style={style} styleName='absent'>
|
|
125
|
+
<Div styleName='absent-line absent-line-1' />
|
|
126
|
+
<Div styleName='absent-line absent-line-2' />
|
|
127
|
+
</Div>
|
|
128
|
+
))
|
|
129
|
+
|
|
130
|
+
return pug`
|
|
131
|
+
Div
|
|
132
|
+
User(
|
|
133
|
+
name='John Doe'
|
|
134
|
+
description='The cat is a domestic species of small carnivorous mammal'
|
|
135
|
+
avatarUrl='/img/avatar1.jpeg'
|
|
136
|
+
status='online'
|
|
137
|
+
)
|
|
138
|
+
Br
|
|
139
|
+
User(
|
|
140
|
+
name='John Doe'
|
|
141
|
+
description='The cat is a domestic species of small carnivorous mammal'
|
|
142
|
+
avatarUrl='/img/avatar2.jpeg'
|
|
143
|
+
status='absent'
|
|
144
|
+
statusComponents={
|
|
145
|
+
absent: AbsentStatus
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
`
|
|
149
|
+
|
|
150
|
+
styl`
|
|
151
|
+
.absent
|
|
152
|
+
background-color white
|
|
153
|
+
justify-content center
|
|
154
|
+
&-line
|
|
155
|
+
position absolute
|
|
156
|
+
height 2px
|
|
157
|
+
left 0
|
|
158
|
+
right 0
|
|
159
|
+
background-color red
|
|
160
|
+
&-1
|
|
161
|
+
transform rotate(45deg)
|
|
162
|
+
&-2
|
|
163
|
+
transform rotate(-45deg)
|
|
164
|
+
`
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Sandbox
|
|
168
|
+
|
|
169
|
+
<Sandbox
|
|
170
|
+
Component={User}
|
|
171
|
+
propsJsonSchema={UserPropsJsonSchema}
|
|
172
|
+
props={{
|
|
173
|
+
onPress: () => alert('"onPress" event on "User" component'),
|
|
174
|
+
}}
|
|
175
|
+
/>
|
package/index.cssx.styl
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.root
|
|
2
|
+
flex-direction row
|
|
3
|
+
align-items center
|
|
4
|
+
|
|
5
|
+
&.right
|
|
6
|
+
flex-direction row-reverse
|
|
7
|
+
|
|
8
|
+
.avatar
|
|
9
|
+
&.left
|
|
10
|
+
margin-right 1u
|
|
11
|
+
|
|
12
|
+
&.right
|
|
13
|
+
margin-left 1u
|
|
14
|
+
|
|
15
|
+
.userInfo
|
|
16
|
+
flex-shrink 1
|
|
17
|
+
|
|
18
|
+
.name
|
|
19
|
+
.description
|
|
20
|
+
&.right
|
|
21
|
+
text-align right
|
|
22
|
+
|
|
23
|
+
.name,
|
|
24
|
+
&.xs
|
|
25
|
+
&.s
|
|
26
|
+
&.m
|
|
27
|
+
font(body2)
|
|
28
|
+
|
|
29
|
+
&.l
|
|
30
|
+
&.xl
|
|
31
|
+
font(body1)
|
|
32
|
+
|
|
33
|
+
&.xxl
|
|
34
|
+
font(h5)
|
|
35
|
+
|
|
36
|
+
.description
|
|
37
|
+
&.xs
|
|
38
|
+
&.s
|
|
39
|
+
&.m
|
|
40
|
+
font(caption)
|
|
41
|
+
|
|
42
|
+
&.l
|
|
43
|
+
&.xl
|
|
44
|
+
font(body2)
|
|
45
|
+
|
|
46
|
+
&.xxl
|
|
47
|
+
font(body1)
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// DO NOT MODIFY THIS FILE - IT IS AUTOMATICALLY GENERATED ON COMMITS.
|
|
3
|
+
|
|
4
|
+
import { type StyleProp, type TextStyle, type ViewStyle } from 'react-native';
|
|
5
|
+
import { type AvatarProps } from '@startupjs-ui/avatar';
|
|
6
|
+
import { type DivProps } from '@startupjs-ui/div';
|
|
7
|
+
import './index.cssx.styl';
|
|
8
|
+
declare const _default: import("react").ComponentType<UserProps>;
|
|
9
|
+
export default _default;
|
|
10
|
+
export declare const _PropsJsonSchema: {};
|
|
11
|
+
export interface UserProps extends DivProps {
|
|
12
|
+
/** Custom styles applied to the root view */
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
/** Custom styles applied to the name text */
|
|
15
|
+
nameStyle?: StyleProp<TextStyle>;
|
|
16
|
+
/** Custom styles applied to the description text */
|
|
17
|
+
descriptionStyle?: StyleProp<TextStyle>;
|
|
18
|
+
/** Avatar image source URL */
|
|
19
|
+
avatarUrl?: string;
|
|
20
|
+
/** Additional description text below the name */
|
|
21
|
+
description?: string;
|
|
22
|
+
/** Maximum number of lines for the description */
|
|
23
|
+
descriptionNumberOfLines?: number;
|
|
24
|
+
/** User name displayed next to the avatar */
|
|
25
|
+
name?: string;
|
|
26
|
+
/** Position of the avatar relative to text @default 'left' */
|
|
27
|
+
avatarPosition?: 'left' | 'right';
|
|
28
|
+
/** Size preset forwarded to avatar and texts @default 'm' */
|
|
29
|
+
size?: 's' | 'm' | 'l';
|
|
30
|
+
/** Status indicator name for the avatar */
|
|
31
|
+
status?: 'online' | 'away' | string;
|
|
32
|
+
/** Custom components for avatar statuses */
|
|
33
|
+
statusComponents?: AvatarProps['statusComponents'];
|
|
34
|
+
}
|
package/index.tsx
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type ReactNode } from 'react'
|
|
2
|
+
import { View, type StyleProp, type TextStyle, type ViewStyle } from 'react-native'
|
|
3
|
+
import { pug, observer } from 'startupjs'
|
|
4
|
+
import { themed } from '@startupjs-ui/core'
|
|
5
|
+
import Avatar, { type AvatarProps } from '@startupjs-ui/avatar'
|
|
6
|
+
import Div, { type DivProps } from '@startupjs-ui/div'
|
|
7
|
+
import Span from '@startupjs-ui/span'
|
|
8
|
+
import './index.cssx.styl'
|
|
9
|
+
|
|
10
|
+
export default observer(themed('User', User))
|
|
11
|
+
|
|
12
|
+
export const _PropsJsonSchema = {/* UserProps */} // used in docs generation
|
|
13
|
+
|
|
14
|
+
export interface UserProps extends DivProps {
|
|
15
|
+
/** Custom styles applied to the root view */
|
|
16
|
+
style?: StyleProp<ViewStyle>
|
|
17
|
+
/** Custom styles applied to the name text */
|
|
18
|
+
nameStyle?: StyleProp<TextStyle>
|
|
19
|
+
/** Custom styles applied to the description text */
|
|
20
|
+
descriptionStyle?: StyleProp<TextStyle>
|
|
21
|
+
/** Avatar image source URL */
|
|
22
|
+
avatarUrl?: string
|
|
23
|
+
/** Additional description text below the name */
|
|
24
|
+
description?: string
|
|
25
|
+
/** Maximum number of lines for the description */
|
|
26
|
+
descriptionNumberOfLines?: number
|
|
27
|
+
/** User name displayed next to the avatar */
|
|
28
|
+
name?: string
|
|
29
|
+
/** Position of the avatar relative to text @default 'left' */
|
|
30
|
+
avatarPosition?: 'left' | 'right'
|
|
31
|
+
/** Size preset forwarded to avatar and texts @default 'm' */
|
|
32
|
+
size?: 's' | 'm' | 'l'
|
|
33
|
+
/** Status indicator name for the avatar */
|
|
34
|
+
status?: 'online' | 'away' | string
|
|
35
|
+
/** Custom components for avatar statuses */
|
|
36
|
+
statusComponents?: AvatarProps['statusComponents']
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function User ({
|
|
40
|
+
style,
|
|
41
|
+
nameStyle,
|
|
42
|
+
descriptionStyle,
|
|
43
|
+
avatarUrl,
|
|
44
|
+
description,
|
|
45
|
+
descriptionNumberOfLines,
|
|
46
|
+
name,
|
|
47
|
+
avatarPosition = 'left',
|
|
48
|
+
size = 'm',
|
|
49
|
+
status,
|
|
50
|
+
statusComponents,
|
|
51
|
+
...props
|
|
52
|
+
}: UserProps): ReactNode {
|
|
53
|
+
return pug`
|
|
54
|
+
Div.root(
|
|
55
|
+
style=style
|
|
56
|
+
styleName=[avatarPosition]
|
|
57
|
+
...props
|
|
58
|
+
)
|
|
59
|
+
Avatar.avatar(
|
|
60
|
+
styleName=[avatarPosition]
|
|
61
|
+
size=size
|
|
62
|
+
status=status
|
|
63
|
+
src=avatarUrl
|
|
64
|
+
statusComponents=statusComponents
|
|
65
|
+
)= name
|
|
66
|
+
View.userInfo
|
|
67
|
+
Span.name(
|
|
68
|
+
style=nameStyle
|
|
69
|
+
styleName=[size, avatarPosition]
|
|
70
|
+
numberOfLines=1
|
|
71
|
+
bold
|
|
72
|
+
)= name
|
|
73
|
+
if description
|
|
74
|
+
Span.description(
|
|
75
|
+
style=descriptionStyle
|
|
76
|
+
styleName=[size, avatarPosition]
|
|
77
|
+
numberOfLines=descriptionNumberOfLines
|
|
78
|
+
description
|
|
79
|
+
)= description
|
|
80
|
+
`
|
|
81
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@startupjs-ui/user",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"main": "index.tsx",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@startupjs-ui/avatar": "^0.1.3",
|
|
12
|
+
"@startupjs-ui/core": "^0.1.3",
|
|
13
|
+
"@startupjs-ui/div": "^0.1.3",
|
|
14
|
+
"@startupjs-ui/span": "^0.1.3"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"react": "*",
|
|
18
|
+
"react-native": "*",
|
|
19
|
+
"startupjs": "*"
|
|
20
|
+
},
|
|
21
|
+
"gitHead": "fd964ebc3892d3dd0a6c85438c0af619cc50c3f0"
|
|
22
|
+
}
|