@webpros/tsxuserprofilevue 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.nvmrc +1 -0
- package/.prettierrc +6 -0
- package/LICENSE.md +21 -0
- package/README.md +132 -0
- package/collectTranslationKeys.js +11 -0
- package/crowdin.yml +3 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.html +32 -0
- package/dist/index.js +3 -0
- package/dist/mockServiceWorker.js +303 -0
- package/dist/style.css +1 -0
- package/env.d.ts +1 -0
- package/histoire.config.ts +7 -0
- package/histoire.setup.ts +7 -0
- package/index.html +30 -0
- package/package.json +92 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vitest.setup.js +9 -0
package/.nvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
18
|
package/.prettierrc
ADDED
package/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 YOUR NAME
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# 360 User Profile
|
2
|
+
A web component that displays a user's information.
|
3
|
+
|
4
|
+
## Install
|
5
|
+
```shell
|
6
|
+
npm i @webpros/tsxuserprofile
|
7
|
+
```
|
8
|
+
|
9
|
+
** Alternative with a CDN**
|
10
|
+
Or download as script from this URL
|
11
|
+
|
12
|
+
```html
|
13
|
+
<script type="module" crossorigin src="https://unpkg.com/@webpros/tsxuserprofile/dist/index.js"></script>
|
14
|
+
```
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
The user profile `<tsx-user-profile>` is simply installed in the space provided, the component itself only outputs the content, if a different background colour, round corners, shadows etc. are required, this should be added via a wrapper in which the component is installed.
|
18
|
+
|
19
|
+
The component itself also only controls the display of the data, it has no direct connection to an API, all events are therefore sent out via [MITT](https://github.com/developit/mitt) events.
|
20
|
+
|
21
|
+
The component is controlled via three props: `current-language`, `user-data`, `inactive-fields`. The data is transmitted as a string (or JSON string) according to the WebComponent specification.
|
22
|
+
|
23
|
+
### Example
|
24
|
+
```html
|
25
|
+
<body>
|
26
|
+
<tsx-user-profile
|
27
|
+
current-language="de"
|
28
|
+
user-data="JSON.stringify(myUserData)"
|
29
|
+
inactive-fields="[]"
|
30
|
+
/>
|
31
|
+
</body>
|
32
|
+
```
|
33
|
+
|
34
|
+
### Props
|
35
|
+
- `current-language <string>` The current language used
|
36
|
+
- `user-data <JSON object>` The data of the user
|
37
|
+
- `inactive-fields <JSON array>` Specifying the profile blocks that you want to deactivate
|
38
|
+
|
39
|
+
## Usage with Frontend Frameworks
|
40
|
+
|
41
|
+
### Vue / Nuxt
|
42
|
+
So that Vue does not treat these elements as regular Vue components the tags must be ignored. The easiest way is to include the elements using `plugin`.
|
43
|
+
|
44
|
+
```js
|
45
|
+
import Vue from 'vue'
|
46
|
+
import '@webpros/tsxuserprofile'
|
47
|
+
|
48
|
+
Vue.config.ignoredElements = [
|
49
|
+
'tsx-user-profile'
|
50
|
+
]
|
51
|
+
```
|
52
|
+
|
53
|
+
### React / Next
|
54
|
+
Currently no findings.
|
55
|
+
|
56
|
+
## Languages
|
57
|
+
To change the language of the user profile, pass the language code through the prop to the application. Eight languages are available
|
58
|
+
|
59
|
+
```typescript
|
60
|
+
type TLanguage = 'de' | 'en' | 'fr' | 'es' | 'it' | 'ja' | 'ru' | 'pt'
|
61
|
+
```
|
62
|
+
|
63
|
+
## UserData
|
64
|
+
Via the user data, we transmit meta information of the user, such as the time zone, name, avatar and email. All information is optional.
|
65
|
+
|
66
|
+
_If no timezone is transmitted, the profile will use the timezone from the user's browser as soon as it is called up and automatically transmit it to the API._
|
67
|
+
|
68
|
+
```typescript
|
69
|
+
interface IProfileUser {
|
70
|
+
name?: string
|
71
|
+
email?: string
|
72
|
+
avatar?: string
|
73
|
+
timezone?: null | string
|
74
|
+
}
|
75
|
+
```
|
76
|
+
|
77
|
+
## InactiveFields
|
78
|
+
This prop can be used to specifically deactivate blocks of the profile, either because they should not be displayed in general, or because perhaps only the time zone should be visible at that point.
|
79
|
+
|
80
|
+
Currently the `avatar`, `email` and the `timezone` can be deactivated.
|
81
|
+
|
82
|
+
```typescript
|
83
|
+
interface IInactiveFields {
|
84
|
+
values: Array<'avatar' | 'email' | 'timezone'>
|
85
|
+
}
|
86
|
+
```
|
87
|
+
|
88
|
+
## Events
|
89
|
+
All click events are passed on to the outside as MITT events.
|
90
|
+
|
91
|
+
**Example**
|
92
|
+
```typescript
|
93
|
+
window.mitt.on('tsxUserProfile', (payload) => {
|
94
|
+
if (payload.timezone) {
|
95
|
+
console.log('Hello from changed Timezone', payload.timezone)
|
96
|
+
}
|
97
|
+
})
|
98
|
+
```
|
99
|
+
|
100
|
+
## Colors
|
101
|
+
The colors are defined using CSSVars and must be included either inline or in the custom stylesheet.
|
102
|
+
|
103
|
+
```css
|
104
|
+
:root {
|
105
|
+
--tsxup-brightest: #ffffff;
|
106
|
+
--tsxup-brightest-darker: #e5e7eb;
|
107
|
+
--tsxup-darkest: #111827;
|
108
|
+
--tsxup-darkest-light: #4b5563;
|
109
|
+
--tsxup-signal-success: #4CA154;
|
110
|
+
--tsxup-signal-error: #b73737;
|
111
|
+
--tsxup-primary: #1E40AF;
|
112
|
+
--tsxup-primary-light: #668bca;
|
113
|
+
/* -- Specific Element CSS Vars */
|
114
|
+
--tsxup-text: var(--tsxup-darkest);
|
115
|
+
--tsxup-text-lighter: var(--tsxup-darkest-light);
|
116
|
+
--tsxup-headline: var(--tsxup-darkest);
|
117
|
+
--tsxUp-button-color: var(--tsxup-brightest);
|
118
|
+
--tsxUp-button-bg: var(--tsxup-primary);
|
119
|
+
--tsxUp-button-color-hover: var(--tsxup-brightest);
|
120
|
+
--tsxUp-button-bg-hover: var(--tsxup-primary-light);
|
121
|
+
--tsxUp-selectField-border: var(--tsxup-brightest-darker);
|
122
|
+
--tsxUp-selectField-background: var(--tsxup-brightest);
|
123
|
+
--tsxUp-selectField-backgroundHover: var(--tsxup-brightest);
|
124
|
+
--tsxUp-selectField-backgroundDisabled: var(--tsxup-brightest-darker);
|
125
|
+
--tsxUp-selectField-color: var(--tsxup-darkest);
|
126
|
+
--tsxUp-selectField-selectedBackground: var(--tsxup-primary-light);
|
127
|
+
--tsxUp-selectField-selectedColor: var(--tsxup-brightest);
|
128
|
+
}
|
129
|
+
```
|
130
|
+
|
131
|
+
|
132
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
const fs = require('fs')
|
2
|
+
const locale = require('./src/locales/en.json')
|
3
|
+
|
4
|
+
const keysArray = Object.keys(locale)
|
5
|
+
|
6
|
+
fs.writeFile('./src/types/localeKeys.ts', `export type TLocaleKeys = ['${keysArray.join("', '")}'][number]`, function (err) {
|
7
|
+
if (err) {
|
8
|
+
return console.error(err)
|
9
|
+
}
|
10
|
+
console.log('Keys array has been saved to keys.js')
|
11
|
+
})
|
package/crowdin.yml
ADDED
package/dist/favicon.ico
ADDED
Binary file
|
package/dist/index.html
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html class="w-screen min-h-full" lang="en">
|
3
|
+
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8" />
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
7
|
+
<!-- <script
|
8
|
+
src="https://code.jquery.com/jquery-3.6.3.min.js"
|
9
|
+
integrity="sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU="
|
10
|
+
crossorigin="anonymous"></script> -->
|
11
|
+
<title>TITLE</title>
|
12
|
+
<script type="module" crossorigin src="/index.js"></script>
|
13
|
+
<link rel="stylesheet" href="/style.css">
|
14
|
+
</head>
|
15
|
+
|
16
|
+
<body>
|
17
|
+
<!-- <tsx-user-profile
|
18
|
+
current-language="de"
|
19
|
+
user-data='{"name":"Sascha Georg Fuchs","email":"features@leankoala.com"}'
|
20
|
+
inactive-fields="[]"
|
21
|
+
></tsx-user-profile> -->
|
22
|
+
<div id="app"></div>
|
23
|
+
|
24
|
+
<!-- <script>
|
25
|
+
console.log('hello start')
|
26
|
+
$(document).ready(function () {
|
27
|
+
console.log('hello finished')
|
28
|
+
});
|
29
|
+
</script> -->
|
30
|
+
</body>
|
31
|
+
|
32
|
+
</html>
|