@react-cupertino-ui/conversation-header 1.0.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/LICENSE +24 -0
- package/dist/index.css +135 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +26 -0
- package/dist/index.scss +156 -0
- package/package.json +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Anderson Lima
|
|
4
|
+
|
|
5
|
+
This project is inspired by Apple's design principles but is not affiliated with, endorsed, or sponsored by Apple Inc.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
.react-cupertino-ui-conversation-header {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: space-between;
|
|
5
|
+
gap: 1.25rem;
|
|
6
|
+
padding: 1rem 1.5rem;
|
|
7
|
+
border-radius: 2.5rem;
|
|
8
|
+
border: 1px solid rgba(14, 14, 15, 0.06);
|
|
9
|
+
background: var(--color-white, rgba(255, 255, 255, 0.95));
|
|
10
|
+
box-shadow: 0 20px 40px rgba(15, 15, 15, 0.08);
|
|
11
|
+
transition: box-shadow 150ms ease, transform 150ms ease;
|
|
12
|
+
}
|
|
13
|
+
.react-cupertino-ui-conversation-header.variant-glass {
|
|
14
|
+
background: rgba(255, 255, 255, 0.6);
|
|
15
|
+
border-color: rgba(255, 255, 255, 0.4);
|
|
16
|
+
backdrop-filter: blur(24px);
|
|
17
|
+
}
|
|
18
|
+
.react-cupertino-ui-conversation-header.variant-solid {
|
|
19
|
+
background: rgba(245, 245, 247, 0.9);
|
|
20
|
+
border-color: rgba(14, 14, 15, 0.08);
|
|
21
|
+
}
|
|
22
|
+
.react-cupertino-ui-conversation-header.variant-outline {
|
|
23
|
+
border-color: rgba(12, 12, 13, 0.12);
|
|
24
|
+
background: transparent;
|
|
25
|
+
}
|
|
26
|
+
.react-cupertino-ui-conversation-header:hover {
|
|
27
|
+
box-shadow: 0 25px 60px rgba(15, 15, 15, 0.15);
|
|
28
|
+
transform: translateY(-1px);
|
|
29
|
+
}
|
|
30
|
+
.react-cupertino-ui-conversation-header__info {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: 1rem;
|
|
34
|
+
min-width: 0;
|
|
35
|
+
flex: 1;
|
|
36
|
+
}
|
|
37
|
+
.react-cupertino-ui-conversation-header__avatar {
|
|
38
|
+
width: 3.5rem;
|
|
39
|
+
height: 3.5rem;
|
|
40
|
+
border-radius: 50%;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
border: 1px solid rgba(255, 255, 255, 0.6);
|
|
43
|
+
box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.7);
|
|
44
|
+
background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(214, 214, 219, 0.7));
|
|
45
|
+
display: inline-flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
flex-shrink: 0;
|
|
49
|
+
}
|
|
50
|
+
.react-cupertino-ui-conversation-header__avatar img {
|
|
51
|
+
width: 100%;
|
|
52
|
+
height: 100%;
|
|
53
|
+
object-fit: cover;
|
|
54
|
+
border-radius: inherit;
|
|
55
|
+
}
|
|
56
|
+
.react-cupertino-ui-conversation-header__text {
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
gap: 0.3rem;
|
|
60
|
+
min-width: 0;
|
|
61
|
+
}
|
|
62
|
+
.react-cupertino-ui-conversation-header__title-row {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: baseline;
|
|
65
|
+
gap: 0.5rem;
|
|
66
|
+
flex-wrap: wrap;
|
|
67
|
+
}
|
|
68
|
+
.react-cupertino-ui-conversation-header__title {
|
|
69
|
+
font-weight: 600;
|
|
70
|
+
font-size: 1.15rem;
|
|
71
|
+
color: #0b0b0f;
|
|
72
|
+
line-height: 1.2;
|
|
73
|
+
}
|
|
74
|
+
.react-cupertino-ui-conversation-header__meta {
|
|
75
|
+
font-size: 0.8rem;
|
|
76
|
+
text-transform: uppercase;
|
|
77
|
+
letter-spacing: 0.08em;
|
|
78
|
+
color: #6e6e73;
|
|
79
|
+
}
|
|
80
|
+
.react-cupertino-ui-conversation-header__subtitle {
|
|
81
|
+
margin: 0;
|
|
82
|
+
font-size: 0.95rem;
|
|
83
|
+
color: #6e6e73;
|
|
84
|
+
}
|
|
85
|
+
.react-cupertino-ui-conversation-header__status {
|
|
86
|
+
display: inline-flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
gap: 0.35rem;
|
|
89
|
+
font-size: 0.85rem;
|
|
90
|
+
color: #6e6e73;
|
|
91
|
+
}
|
|
92
|
+
.react-cupertino-ui-conversation-header__status-indicator {
|
|
93
|
+
width: 0.45rem;
|
|
94
|
+
height: 0.45rem;
|
|
95
|
+
border-radius: 999px;
|
|
96
|
+
background: #34c759;
|
|
97
|
+
box-shadow: 0 0 0 4px rgba(52, 199, 89, 0.15);
|
|
98
|
+
}
|
|
99
|
+
.react-cupertino-ui-conversation-header__status-indicator.is-away {
|
|
100
|
+
background: #ff9f0a;
|
|
101
|
+
box-shadow: 0 0 0 4px rgba(255, 159, 10, 0.15);
|
|
102
|
+
}
|
|
103
|
+
.react-cupertino-ui-conversation-header__status-indicator.is-busy {
|
|
104
|
+
background: #ff3b30;
|
|
105
|
+
box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.18);
|
|
106
|
+
}
|
|
107
|
+
.react-cupertino-ui-conversation-header__status-indicator.is-offline {
|
|
108
|
+
background: #d1d1d6;
|
|
109
|
+
box-shadow: 0 0 0 4px rgba(209, 209, 214, 0.25);
|
|
110
|
+
}
|
|
111
|
+
.react-cupertino-ui-conversation-header__extra {
|
|
112
|
+
font-size: 0.85rem;
|
|
113
|
+
color: #86868b;
|
|
114
|
+
}
|
|
115
|
+
.react-cupertino-ui-conversation-header__actions {
|
|
116
|
+
display: inline-flex;
|
|
117
|
+
align-items: center;
|
|
118
|
+
gap: 0.5rem;
|
|
119
|
+
flex-shrink: 0;
|
|
120
|
+
}
|
|
121
|
+
.react-cupertino-ui-conversation-header__actions > * {
|
|
122
|
+
flex-shrink: 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@media (max-width: 640px) {
|
|
126
|
+
.react-cupertino-ui-conversation-header {
|
|
127
|
+
flex-direction: column;
|
|
128
|
+
align-items: flex-start;
|
|
129
|
+
gap: 0.75rem;
|
|
130
|
+
}
|
|
131
|
+
.react-cupertino-ui-conversation-header__actions {
|
|
132
|
+
width: 100%;
|
|
133
|
+
justify-content: flex-end;
|
|
134
|
+
}
|
|
135
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { BaseProps } from "@react-cupertino-ui/shared/lib/interfaces/BaseProps";
|
|
3
|
+
import "./index.scss";
|
|
4
|
+
export type ConversationPresence = "online" | "away" | "busy" | "offline";
|
|
5
|
+
export interface ConversationHeaderProps extends BaseProps<HTMLDivElement> {
|
|
6
|
+
title: string;
|
|
7
|
+
subtitle?: string;
|
|
8
|
+
avatarSrc?: string;
|
|
9
|
+
avatarAlt?: string;
|
|
10
|
+
avatarFallback?: React.ReactNode;
|
|
11
|
+
status?: ConversationPresence;
|
|
12
|
+
statusText?: string;
|
|
13
|
+
meta?: React.ReactNode;
|
|
14
|
+
actions?: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
declare const ConversationHeader: React.ForwardRefExoticComponent<ConversationHeaderProps & React.RefAttributes<HTMLDivElement>>;
|
|
17
|
+
export { ConversationHeader };
|
|
18
|
+
export default ConversationHeader;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { cn } from "@react-cupertino-ui/shared/lib/utils";
|
|
5
|
+
import { BaseVariants } from "@react-cupertino-ui/shared/lib/interfaces/BaseProps";
|
|
6
|
+
import "./index.scss";
|
|
7
|
+
const presenceLabels = {
|
|
8
|
+
online: "Online",
|
|
9
|
+
away: "Away",
|
|
10
|
+
busy: "Do Not Disturb",
|
|
11
|
+
offline: "Offline",
|
|
12
|
+
};
|
|
13
|
+
const ConversationHeader = React.forwardRef((props, ref) => {
|
|
14
|
+
const { title, subtitle, avatarSrc, avatarAlt = title, avatarFallback, status, statusText, meta, actions, className, variant, size, asChild = false, children, ...rest } = props;
|
|
15
|
+
const Comp = asChild ? Slot : "header";
|
|
16
|
+
const classes = BaseVariants("react-cupertino-ui-conversation-header", {
|
|
17
|
+
className,
|
|
18
|
+
variant,
|
|
19
|
+
size,
|
|
20
|
+
});
|
|
21
|
+
const resolvedStatus = status ? presenceLabels[status] : undefined;
|
|
22
|
+
return (_jsxs(Comp, { ref: ref, className: cn(classes, status && `has-status-${status}`), ...rest, children: [_jsxs("div", { className: "react-cupertino-ui-conversation-header__info", children: [(avatarSrc || avatarFallback) && (_jsx("span", { className: "react-cupertino-ui-conversation-header__avatar", children: avatarSrc ? (_jsx("img", { src: avatarSrc, alt: avatarAlt })) : (avatarFallback) })), _jsxs("div", { className: "react-cupertino-ui-conversation-header__text", children: [_jsxs("div", { className: "react-cupertino-ui-conversation-header__title-row", children: [_jsx("span", { className: "react-cupertino-ui-conversation-header__title", children: title }), meta ? (_jsx("span", { className: "react-cupertino-ui-conversation-header__meta", children: meta })) : null] }), subtitle ? (_jsx("p", { className: "react-cupertino-ui-conversation-header__subtitle", children: subtitle })) : null, status || statusText ? (_jsxs("div", { className: "react-cupertino-ui-conversation-header__status", children: [status ? (_jsx("span", { className: cn("react-cupertino-ui-conversation-header__status-indicator", `is-${status}`), "aria-hidden": "true" })) : null, _jsx("span", { children: statusText || resolvedStatus })] })) : null, children ? (_jsx("div", { className: "react-cupertino-ui-conversation-header__extra", children: children })) : null] })] }), actions ? (_jsx("div", { className: "react-cupertino-ui-conversation-header__actions", children: actions })) : null] }));
|
|
23
|
+
});
|
|
24
|
+
ConversationHeader.displayName = "ConversationHeader";
|
|
25
|
+
export { ConversationHeader };
|
|
26
|
+
export default ConversationHeader;
|
package/dist/index.scss
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
.react-cupertino-ui-conversation-header {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: space-between;
|
|
5
|
+
gap: 1.25rem;
|
|
6
|
+
padding: 1rem 1.5rem;
|
|
7
|
+
border-radius: 2.5rem;
|
|
8
|
+
border: 1px solid rgba(14, 14, 15, 0.06);
|
|
9
|
+
background: var(--color-white, rgba(255, 255, 255, 0.95));
|
|
10
|
+
box-shadow: 0 20px 40px rgba(15, 15, 15, 0.08);
|
|
11
|
+
transition: box-shadow 150ms ease, transform 150ms ease;
|
|
12
|
+
|
|
13
|
+
&.variant-glass {
|
|
14
|
+
background: rgba(255, 255, 255, 0.6);
|
|
15
|
+
border-color: rgba(255, 255, 255, 0.4);
|
|
16
|
+
backdrop-filter: blur(24px);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.variant-solid {
|
|
20
|
+
background: rgba(245, 245, 247, 0.9);
|
|
21
|
+
border-color: rgba(14, 14, 15, 0.08);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.variant-outline {
|
|
25
|
+
border-color: rgba(12, 12, 13, 0.12);
|
|
26
|
+
background: transparent;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&:hover {
|
|
30
|
+
box-shadow: 0 25px 60px rgba(15, 15, 15, 0.15);
|
|
31
|
+
transform: translateY(-1px);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&__info {
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
gap: 1rem;
|
|
38
|
+
min-width: 0;
|
|
39
|
+
flex: 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&__avatar {
|
|
43
|
+
width: 3.5rem;
|
|
44
|
+
height: 3.5rem;
|
|
45
|
+
border-radius: 50%;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
border: 1px solid rgba(255, 255, 255, 0.6);
|
|
48
|
+
box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.7);
|
|
49
|
+
background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(214, 214, 219, 0.7));
|
|
50
|
+
display: inline-flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
flex-shrink: 0;
|
|
54
|
+
|
|
55
|
+
img {
|
|
56
|
+
width: 100%;
|
|
57
|
+
height: 100%;
|
|
58
|
+
object-fit: cover;
|
|
59
|
+
border-radius: inherit;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&__text {
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
gap: 0.3rem;
|
|
67
|
+
min-width: 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&__title-row {
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: baseline;
|
|
73
|
+
gap: 0.5rem;
|
|
74
|
+
flex-wrap: wrap;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&__title {
|
|
78
|
+
font-weight: 600;
|
|
79
|
+
font-size: 1.15rem;
|
|
80
|
+
color: #0b0b0f;
|
|
81
|
+
line-height: 1.2;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&__meta {
|
|
85
|
+
font-size: 0.8rem;
|
|
86
|
+
text-transform: uppercase;
|
|
87
|
+
letter-spacing: 0.08em;
|
|
88
|
+
color: #6e6e73;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&__subtitle {
|
|
92
|
+
margin: 0;
|
|
93
|
+
font-size: 0.95rem;
|
|
94
|
+
color: #6e6e73;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&__status {
|
|
98
|
+
display: inline-flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
gap: 0.35rem;
|
|
101
|
+
font-size: 0.85rem;
|
|
102
|
+
color: #6e6e73;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&__status-indicator {
|
|
106
|
+
width: 0.45rem;
|
|
107
|
+
height: 0.45rem;
|
|
108
|
+
border-radius: 999px;
|
|
109
|
+
background: #34c759;
|
|
110
|
+
box-shadow: 0 0 0 4px rgba(52, 199, 89, 0.15);
|
|
111
|
+
|
|
112
|
+
&.is-away {
|
|
113
|
+
background: #ff9f0a;
|
|
114
|
+
box-shadow: 0 0 0 4px rgba(255, 159, 10, 0.15);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&.is-busy {
|
|
118
|
+
background: #ff3b30;
|
|
119
|
+
box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.18);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&.is-offline {
|
|
123
|
+
background: #d1d1d6;
|
|
124
|
+
box-shadow: 0 0 0 4px rgba(209, 209, 214, 0.25);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&__extra {
|
|
129
|
+
font-size: 0.85rem;
|
|
130
|
+
color: #86868b;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&__actions {
|
|
134
|
+
display: inline-flex;
|
|
135
|
+
align-items: center;
|
|
136
|
+
gap: 0.5rem;
|
|
137
|
+
flex-shrink: 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
&__actions > * {
|
|
141
|
+
flex-shrink: 0;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@media (max-width: 640px) {
|
|
146
|
+
.react-cupertino-ui-conversation-header {
|
|
147
|
+
flex-direction: column;
|
|
148
|
+
align-items: flex-start;
|
|
149
|
+
gap: 0.75rem;
|
|
150
|
+
|
|
151
|
+
&__actions {
|
|
152
|
+
width: 100%;
|
|
153
|
+
justify-content: flex-end;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-cupertino-ui/conversation-header",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Chat conversation header",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"./dist/**/*.css",
|
|
14
|
+
"./dist/**/*.scss"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -p tsconfig.build.json && npm run build:styles",
|
|
18
|
+
"build:styles": "node ../../../scripts/build-styles.mjs"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"react": "^18.3.1",
|
|
22
|
+
"react-dom": "^18.3.1"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@react-cupertino-ui/shared": "workspace:*"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "^5.2.2"
|
|
29
|
+
},
|
|
30
|
+
"gitHead": "3f53987bdb936a331665691b517c2ba9984777f8",
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
}
|
|
34
|
+
}
|