@agora-sdk/social-react-native 0.6.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 +202 -0
- package/dist/cjs/components/CommunityWeather.d.ts +24 -0
- package/dist/cjs/components/CommunityWeather.js +128 -0
- package/dist/cjs/components/CommunityWeather.js.map +1 -0
- package/dist/cjs/components/Constellation.d.ts +24 -0
- package/dist/cjs/components/Constellation.js +97 -0
- package/dist/cjs/components/Constellation.js.map +1 -0
- package/dist/cjs/components/Neighborhood.d.ts +24 -0
- package/dist/cjs/components/Neighborhood.js +131 -0
- package/dist/cjs/components/Neighborhood.js.map +1 -0
- package/dist/cjs/components/SocialTransparency.d.ts +21 -0
- package/dist/cjs/components/SocialTransparency.js +43 -0
- package/dist/cjs/components/SocialTransparency.js.map +1 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.js +40 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/layout.d.ts +25 -0
- package/dist/cjs/layout.js +54 -0
- package/dist/cjs/layout.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/palette.d.ts +58 -0
- package/dist/cjs/palette.js +65 -0
- package/dist/cjs/palette.js.map +1 -0
- package/dist/esm/components/CommunityWeather.d.ts +24 -0
- package/dist/esm/components/CommunityWeather.js +89 -0
- package/dist/esm/components/CommunityWeather.js.map +1 -0
- package/dist/esm/components/Constellation.d.ts +24 -0
- package/dist/esm/components/Constellation.js +61 -0
- package/dist/esm/components/Constellation.js.map +1 -0
- package/dist/esm/components/Neighborhood.d.ts +24 -0
- package/dist/esm/components/Neighborhood.js +92 -0
- package/dist/esm/components/Neighborhood.js.map +1 -0
- package/dist/esm/components/SocialTransparency.d.ts +21 -0
- package/dist/esm/components/SocialTransparency.js +40 -0
- package/dist/esm/components/SocialTransparency.js.map +1 -0
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/layout.d.ts +25 -0
- package/dist/esm/layout.js +50 -0
- package/dist/esm/layout.js.map +1 -0
- package/dist/esm/palette.d.ts +58 -0
- package/dist/esm/palette.js +60 -0
- package/dist/esm/palette.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2025 Replyke
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/** Props for {@link CommunityWeather}. */
|
|
3
|
+
export interface CommunityWeatherProps {
|
|
4
|
+
/** Optional style for the root chip (for host-app layout/spacing). */
|
|
5
|
+
style?: object;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Render the Community Weather as an ambient climate chip.
|
|
9
|
+
*
|
|
10
|
+
* Self-contained: reads {@link useSocialWeather} internally and gates on the feature config. Shows a
|
|
11
|
+
* band-tinted glowing orb plus a soft trend arrow when history is available. The warmth `value` is
|
|
12
|
+
* never displayed.
|
|
13
|
+
*
|
|
14
|
+
* @param props - {@link CommunityWeatherProps}.
|
|
15
|
+
* @returns The weather chip, or `null` when the lens is disabled or still loading.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <SocialProvider projectId={id} accessToken={token}>
|
|
20
|
+
* <CommunityWeather />
|
|
21
|
+
* </SocialProvider>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function CommunityWeather({ style }: CommunityWeatherProps): React.ReactElement | null;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.CommunityWeather = CommunityWeather;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
+
// <CommunityWeather /> — the Weather lens as an ambient climate indicator (React Native).
|
|
42
|
+
//
|
|
43
|
+
// Native port of the web component: the aggregate community warmth as a calm sky/climate chip
|
|
44
|
+
// (SOCIAL.md §5) — a band-tinted orb with a soft glow, a subtle trend cue (warming/cooling, never
|
|
45
|
+
// alarming text), and a "still forming" treatment for the `quiet` no-data sentinel. The raw `value`
|
|
46
|
+
// number is NEVER shown — warmth is communicated only as color/glow. Returns `null` when the lens is
|
|
47
|
+
// disabled or still loading, so a host can drop it in unconditionally and have it disappear when off.
|
|
48
|
+
//
|
|
49
|
+
// The orb's radial gradient is drawn with react-native-svg (the only cross-platform way to get a soft
|
|
50
|
+
// gradient orb in RN); the ambient glow is an RN View shadow/elevation around it.
|
|
51
|
+
const react_1 = __importDefault(require("react"));
|
|
52
|
+
const react_native_1 = require("react-native");
|
|
53
|
+
const react_native_svg_1 = __importStar(require("react-native-svg"));
|
|
54
|
+
const social_core_1 = require("@agora-sdk/social-core");
|
|
55
|
+
const palette_js_1 = require("../palette.js");
|
|
56
|
+
/** Human-readable, non-alarming captions per band. `stormy` stays gentle by design (SOCIAL.md §5). */
|
|
57
|
+
const BAND_CAPTION = {
|
|
58
|
+
quiet: "Still forming",
|
|
59
|
+
stormy: "Could use more warmth",
|
|
60
|
+
overcast: "Settling in",
|
|
61
|
+
fine: "Warm",
|
|
62
|
+
sunny: "Glowing",
|
|
63
|
+
};
|
|
64
|
+
const ORB = 22;
|
|
65
|
+
/**
|
|
66
|
+
* Render the Community Weather as an ambient climate chip.
|
|
67
|
+
*
|
|
68
|
+
* Self-contained: reads {@link useSocialWeather} internally and gates on the feature config. Shows a
|
|
69
|
+
* band-tinted glowing orb plus a soft trend arrow when history is available. The warmth `value` is
|
|
70
|
+
* never displayed.
|
|
71
|
+
*
|
|
72
|
+
* @param props - {@link CommunityWeatherProps}.
|
|
73
|
+
* @returns The weather chip, or `null` when the lens is disabled or still loading.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* <SocialProvider projectId={id} accessToken={token}>
|
|
78
|
+
* <CommunityWeather />
|
|
79
|
+
* </SocialProvider>
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
function CommunityWeather({ style }) {
|
|
83
|
+
const { weather } = (0, social_core_1.useSocialWeather)();
|
|
84
|
+
// react-native-svg references gradients by id; strip the colons React.useId emits so `url(#id)` is valid.
|
|
85
|
+
const gid = `cw-${react_1.default.useId().replace(/:/g, "")}`;
|
|
86
|
+
if (!weather)
|
|
87
|
+
return null;
|
|
88
|
+
const colors = (0, palette_js_1.bandColors)(weather.band);
|
|
89
|
+
const caption = BAND_CAPTION[weather.band] ?? "Still forming";
|
|
90
|
+
const forming = weather.band === "quiet" || weather.value === null;
|
|
91
|
+
// Trend → a subtle directional cue, never alarming text. Tiny magnitudes are treated as steady.
|
|
92
|
+
const trendArrow = weather.trend === null || Math.abs(weather.trend) < 0.005
|
|
93
|
+
? null
|
|
94
|
+
: weather.trend > 0
|
|
95
|
+
? "↗"
|
|
96
|
+
: "↘";
|
|
97
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [styles.chip, style], accessibilityRole: "image", accessibilityLabel: `Community weather: ${caption.toLowerCase()}`, children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: [
|
|
98
|
+
styles.orbWrap,
|
|
99
|
+
{
|
|
100
|
+
shadowColor: colors.glow,
|
|
101
|
+
shadowRadius: forming ? 10 : 18,
|
|
102
|
+
elevation: forming ? 4 : 8,
|
|
103
|
+
opacity: forming ? 0.8 : 1,
|
|
104
|
+
},
|
|
105
|
+
], children: (0, jsx_runtime_1.jsxs)(react_native_svg_1.default, { width: ORB, height: ORB, children: [(0, jsx_runtime_1.jsx)(react_native_svg_1.Defs, { children: (0, jsx_runtime_1.jsxs)(react_native_svg_1.RadialGradient, { id: gid, cx: "35%", cy: "30%", r: "70%", children: [(0, jsx_runtime_1.jsx)(react_native_svg_1.Stop, { offset: "0%", stopColor: colors.core, stopOpacity: 1 }), (0, jsx_runtime_1.jsx)(react_native_svg_1.Stop, { offset: "100%", stopColor: colors.core, stopOpacity: 0.2 })] }) }), (0, jsx_runtime_1.jsx)(react_native_svg_1.Circle, { cx: ORB / 2, cy: ORB / 2, r: ORB / 2, fill: `url(#${gid})` })] }) }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [styles.caption, { color: colors.core }], children: caption }), trendArrow && ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [styles.trend, { color: colors.core }], accessibilityElementsHidden: true, children: trendArrow }))] }));
|
|
106
|
+
}
|
|
107
|
+
const styles = react_native_1.StyleSheet.create({
|
|
108
|
+
chip: {
|
|
109
|
+
flexDirection: "row",
|
|
110
|
+
alignItems: "center",
|
|
111
|
+
alignSelf: "flex-start",
|
|
112
|
+
gap: 10,
|
|
113
|
+
paddingVertical: 8,
|
|
114
|
+
paddingHorizontal: 14,
|
|
115
|
+
borderRadius: 999,
|
|
116
|
+
backgroundColor: "rgba(15, 15, 24, 0.04)",
|
|
117
|
+
},
|
|
118
|
+
// iOS shadow needs a non-transparent shadowOpacity; the color already carries its own alpha.
|
|
119
|
+
orbWrap: {
|
|
120
|
+
width: ORB,
|
|
121
|
+
height: ORB,
|
|
122
|
+
shadowOpacity: 1,
|
|
123
|
+
shadowOffset: { width: 0, height: 0 },
|
|
124
|
+
},
|
|
125
|
+
caption: { fontSize: 13, fontWeight: "600" },
|
|
126
|
+
trend: { fontSize: 13, opacity: 0.7 },
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=CommunityWeather.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommunityWeather.js","sourceRoot":"","sources":["../../../src/components/CommunityWeather.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,4CAkDC;;A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AE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,YAAG,OAAO,GAAQ,EACtE,UAAU,IAAI,CACb,uBAAC,mBAAI,IAAC,KAAK,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,2BAA2B,kBAC7E,UAAU,GACN,CACR,IACI,CACR,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE;QACJ,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,SAAS,EAAE,YAAY;QACvB,GAAG,EAAE,EAAE;QACP,eAAe,EAAE,CAAC;QAClB,iBAAiB,EAAE,EAAE;QACrB,YAAY,EAAE,GAAG;QACjB,eAAe,EAAE,wBAAwB;KAC1C;IACD,6FAA6F;IAC7F,OAAO,EAAE;QACP,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,aAAa,EAAE,CAAC;QAChB,YAAY,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;KACtC;IACD,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;IAC5C,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;CACtC,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/** Props for {@link Constellation}. */
|
|
3
|
+
export interface ConstellationProps {
|
|
4
|
+
/** Canvas width in px. Defaults to 360. */
|
|
5
|
+
width?: number;
|
|
6
|
+
/** Canvas height in px. Defaults to 240. */
|
|
7
|
+
height?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Render the Constellation as a randomized field of warm blobs.
|
|
11
|
+
*
|
|
12
|
+
* Self-contained: reads {@link useSocialConstellation} and gates on the feature config. Returns `null`
|
|
13
|
+
* when disabled, a nebula when the snapshot is still forming (`asOf === null`), and otherwise a
|
|
14
|
+
* re-randomized SVG blob field. Blobs are sized by bucket and tinted by warmth only.
|
|
15
|
+
*
|
|
16
|
+
* @param props - {@link ConstellationProps}.
|
|
17
|
+
* @returns The blob canvas, a nebula, or `null`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <Constellation width={420} height={280} />
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function Constellation({ width, height, }: ConstellationProps): React.ReactElement | null;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Constellation = Constellation;
|
|
37
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
+
// <Constellation /> — the anonymous community "shape" as a field of warm, glowing blobs (React Native).
|
|
39
|
+
//
|
|
40
|
+
// Native port of the web component, drawn with react-native-svg. The privacy rules from SOCIAL.md §6
|
|
41
|
+
// are enforced structurally, identically to web:
|
|
42
|
+
// • No stable layout — positions are re-randomized on every mount / whenever the blob data changes
|
|
43
|
+
// (see `computePositions` in ../layout), so no cluster has a "home" a viewer could track.
|
|
44
|
+
// • Size by BUCKET, never an exact count — radius comes from a fixed bucket→px map.
|
|
45
|
+
// • Warmth-only tint — blobs use the same calm climate palette as Weather; friction never renders.
|
|
46
|
+
// • `asOf === null` is the valid "still forming" state — a wispy nebula, not an error or empty list.
|
|
47
|
+
//
|
|
48
|
+
// Each blob is an SVG <Circle> filled by a per-band radial gradient that fades to transparent at the
|
|
49
|
+
// edge, giving the soft "glow" look without an SVG blur filter (feGaussianBlur is not reliably
|
|
50
|
+
// supported on react-native-svg across platforms).
|
|
51
|
+
const react_1 = __importStar(require("react"));
|
|
52
|
+
const react_native_svg_1 = __importStar(require("react-native-svg"));
|
|
53
|
+
const social_core_1 = require("@agora-sdk/social-core");
|
|
54
|
+
const palette_js_1 = require("../palette.js");
|
|
55
|
+
const layout_js_1 = require("../layout.js");
|
|
56
|
+
/**
|
|
57
|
+
* Render the Constellation as a randomized field of warm blobs.
|
|
58
|
+
*
|
|
59
|
+
* Self-contained: reads {@link useSocialConstellation} and gates on the feature config. Returns `null`
|
|
60
|
+
* when disabled, a nebula when the snapshot is still forming (`asOf === null`), and otherwise a
|
|
61
|
+
* re-randomized SVG blob field. Blobs are sized by bucket and tinted by warmth only.
|
|
62
|
+
*
|
|
63
|
+
* @param props - {@link ConstellationProps}.
|
|
64
|
+
* @returns The blob canvas, a nebula, or `null`.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx
|
|
68
|
+
* <Constellation width={420} height={280} />
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
function Constellation({ width = 360, height = 240, }) {
|
|
72
|
+
const { constellation } = (0, social_core_1.useSocialConstellation)();
|
|
73
|
+
// react-native-svg references gradients by id; strip the colons React.useId emits so `url(#id)` is valid.
|
|
74
|
+
const gid = `cn-${react_1.default.useId().replace(/:/g, "")}`;
|
|
75
|
+
const blobs = constellation?.blobs ?? null;
|
|
76
|
+
// Positions live in state, seeded once per blob-set and re-seeded whenever the blobs change (or the
|
|
77
|
+
// canvas resizes). NOT recomputed on every render — only when the data/size actually changes — but
|
|
78
|
+
// also never a *stable* layout across mounts, since each fresh mount re-runs computePositions.
|
|
79
|
+
const [nodes, setNodes] = (0, react_1.useState)(() => blobs ? (0, layout_js_1.computePositions)(blobs, width, height) : []);
|
|
80
|
+
(0, react_1.useEffect)(() => {
|
|
81
|
+
if (blobs)
|
|
82
|
+
setNodes((0, layout_js_1.computePositions)(blobs, width, height));
|
|
83
|
+
}, [blobs, width, height]);
|
|
84
|
+
// One gradient per band actually present — referenced by the circles below.
|
|
85
|
+
const bandsPresent = (0, react_1.useMemo)(() => Array.from(new Set((blobs ?? []).map((b) => b.warmth))), [blobs]);
|
|
86
|
+
if (!constellation)
|
|
87
|
+
return null;
|
|
88
|
+
// Still-forming: a gentle nebula, never an error or empty state.
|
|
89
|
+
if (constellation.asOf === null) {
|
|
90
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_svg_1.default, { width: width, height: height, accessibilityRole: "image", accessibilityLabel: "Community constellation: still forming", children: [(0, jsx_runtime_1.jsx)(react_native_svg_1.Defs, { children: (0, jsx_runtime_1.jsxs)(react_native_svg_1.RadialGradient, { id: `${gid}-nebula`, cx: "50%", cy: "50%", r: "60%", children: [(0, jsx_runtime_1.jsx)(react_native_svg_1.Stop, { offset: "0%", stopColor: "#8a94a6", stopOpacity: 0.3 }), (0, jsx_runtime_1.jsx)(react_native_svg_1.Stop, { offset: "100%", stopColor: "#8a94a6", stopOpacity: 0 })] }) }), (0, jsx_runtime_1.jsx)(react_native_svg_1.Rect, { x: 0, y: 0, width: width, height: height, fill: `url(#${gid}-nebula)` })] }));
|
|
91
|
+
}
|
|
92
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_svg_1.default, { width: width, height: height, accessibilityRole: "image", accessibilityLabel: "Community constellation", children: [(0, jsx_runtime_1.jsx)(react_native_svg_1.Defs, { children: bandsPresent.map((band) => {
|
|
93
|
+
const colors = (0, palette_js_1.bandColors)(band);
|
|
94
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_svg_1.RadialGradient, { id: `${gid}-${band}`, cx: "50%", cy: "50%", r: "50%", children: [(0, jsx_runtime_1.jsx)(react_native_svg_1.Stop, { offset: "0%", stopColor: colors.core, stopOpacity: 0.9 }), (0, jsx_runtime_1.jsx)(react_native_svg_1.Stop, { offset: "100%", stopColor: colors.core, stopOpacity: 0 })] }, band));
|
|
95
|
+
}) }), nodes.map((n, i) => ((0, jsx_runtime_1.jsx)(react_native_svg_1.Circle, { cx: n.x, cy: n.y, r: n.r, fill: `url(#${gid}-${n.warmth})` }, i)))] }));
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=Constellation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Constellation.js","sourceRoot":"","sources":["../../../src/components/Constellation.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,sCA6DC;;AAxGD,wGAAwG;AACxG,EA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,IAAI,EAAE,EAAE,EAAE,EAAC,KAAK,EAAC,EAAE,EAAC,KAAK,EAAC,CAAC,EAAC,KAAK,aACxE,uBAAC,uBAAI,IAAC,MAAM,EAAC,IAAI,EAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,GAAI,EAC9D,uBAAC,uBAAI,IAAC,MAAM,EAAC,MAAM,EAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,GAAI,KAF3C,IAAI,CAGR,CAClB,CAAC;gBACJ,CAAC,CAAC,GACG,EACN,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACnB,uBAAC,yBAAM,IAAS,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC,CAAC,MAAM,GAAG,IAA7D,CAAC,CAAgE,CAC/E,CAAC,IACE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/** Props for {@link Neighborhood}. */
|
|
3
|
+
export interface NeighborhoodProps {
|
|
4
|
+
/** Render the "include interactions" toggle (wires to the hook's setter). Defaults to `false`. */
|
|
5
|
+
showInteractionsToggle?: boolean;
|
|
6
|
+
/** Optional style for the root element. */
|
|
7
|
+
style?: object;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Render the caller's Neighborhood — their named ties, lit by dyadic brightness.
|
|
11
|
+
*
|
|
12
|
+
* Self-contained: reads {@link useSocialNeighborhood} and gates on the feature config. Ties render in
|
|
13
|
+
* the server's brightest-first order; brightness becomes glow/scale, never a number. Optionally shows
|
|
14
|
+
* the interactions toggle.
|
|
15
|
+
*
|
|
16
|
+
* @param props - {@link NeighborhoodProps}.
|
|
17
|
+
* @returns The tie list, or `null` when the lens is disabled or still loading.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <Neighborhood showInteractionsToggle />
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function Neighborhood({ showInteractionsToggle, style, }: NeighborhoodProps): React.ReactElement | null;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Neighborhood = Neighborhood;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
+
// <Neighborhood /> — the caller's own named ties, lit by dyadic brightness (React Native).
|
|
42
|
+
//
|
|
43
|
+
// Native port of the web component. Renders the self-view tie list (brightest-first, as the server
|
|
44
|
+
// sorts it). Brightness drives a glow treatment ONLY — the number is never shown, labeled, or compared
|
|
45
|
+
// between ties (SOCIAL.md §6). Ties at the floor band render as a warm "sprout" (hopeful/new), not a
|
|
46
|
+
// grey absence. An optional RN Switch wires the `includeInteractions` toggle. Returns `null` when the
|
|
47
|
+
// lens is disabled or still loading.
|
|
48
|
+
//
|
|
49
|
+
// Privacy note: the underlying hook keeps ties in component state only and clears them on a user/project
|
|
50
|
+
// switch — this component adds no cache of its own, so the self-view never lingers across sign-outs.
|
|
51
|
+
const react_1 = __importDefault(require("react"));
|
|
52
|
+
const react_native_1 = require("react-native");
|
|
53
|
+
const react_native_svg_1 = __importStar(require("react-native-svg"));
|
|
54
|
+
const social_core_1 = require("@agora-sdk/social-core");
|
|
55
|
+
const palette_js_1 = require("../palette.js");
|
|
56
|
+
/** Subtle glyphs for the tie-kind chips. Hints, not labels. */
|
|
57
|
+
const TIE_KIND_GLYPH = {
|
|
58
|
+
follow: "→",
|
|
59
|
+
connection: "↔",
|
|
60
|
+
interaction: "·",
|
|
61
|
+
};
|
|
62
|
+
/** Best available display label for a tie, falling back gracefully when fields are null. */
|
|
63
|
+
function displayName(tie) {
|
|
64
|
+
return tie.name ?? tie.username ?? "Someone";
|
|
65
|
+
}
|
|
66
|
+
/** First glyph for the avatar fallback. */
|
|
67
|
+
function initial(tie) {
|
|
68
|
+
return displayName(tie).charAt(0).toUpperCase();
|
|
69
|
+
}
|
|
70
|
+
/** One tie card — avatar (or initial) + name + tie-kind chips, lit by brightness glow. */
|
|
71
|
+
function TieCard({ tie, gradientId }) {
|
|
72
|
+
const t = (0, palette_js_1.brightnessTreatment)(tie.brightness);
|
|
73
|
+
// Sprout ties get a warm amber halo (hopeful/new); brighter ties get a golden glow. Never grey.
|
|
74
|
+
// The opacity rides on shadowOpacity, so the color itself is fully opaque.
|
|
75
|
+
const glowColor = t.isSprout ? "#e0a955" : "#f4c64a";
|
|
76
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.card, children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: [
|
|
77
|
+
styles.avatar,
|
|
78
|
+
{
|
|
79
|
+
transform: [{ scale: t.scale }],
|
|
80
|
+
shadowColor: glowColor,
|
|
81
|
+
shadowRadius: t.shadowRadius,
|
|
82
|
+
shadowOpacity: t.shadowOpacity,
|
|
83
|
+
elevation: t.elevation,
|
|
84
|
+
},
|
|
85
|
+
], children: tie.avatar ? ((0, jsx_runtime_1.jsx)(react_native_1.Image, { source: { uri: tie.avatar }, style: styles.avatarImg })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(react_native_svg_1.default, { width: 40, height: 40, style: react_native_1.StyleSheet.absoluteFill, children: [(0, jsx_runtime_1.jsx)(react_native_svg_1.Defs, { children: (0, jsx_runtime_1.jsxs)(react_native_svg_1.LinearGradient, { id: gradientId, x1: "0", y1: "0", x2: "1", y2: "1", children: [(0, jsx_runtime_1.jsx)(react_native_svg_1.Stop, { offset: "0", stopColor: "#e0a955" }), (0, jsx_runtime_1.jsx)(react_native_svg_1.Stop, { offset: "1", stopColor: "#f4c64a" })] }) }), (0, jsx_runtime_1.jsx)(react_native_svg_1.Rect, { width: 40, height: 40, rx: 20, fill: `url(#${gradientId})` })] }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.avatarInitial, children: initial(tie) })] })) }), (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.cardText, children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.name, children: displayName(tie) }), (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.kinds, children: tie.tieKinds.map((kind) => ((0, jsx_runtime_1.jsxs)(react_native_1.Text, { style: styles.kind, accessibilityLabel: kind, children: [TIE_KIND_GLYPH[kind], " ", kind] }, kind))) })] })] }));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Render the caller's Neighborhood — their named ties, lit by dyadic brightness.
|
|
89
|
+
*
|
|
90
|
+
* Self-contained: reads {@link useSocialNeighborhood} and gates on the feature config. Ties render in
|
|
91
|
+
* the server's brightest-first order; brightness becomes glow/scale, never a number. Optionally shows
|
|
92
|
+
* the interactions toggle.
|
|
93
|
+
*
|
|
94
|
+
* @param props - {@link NeighborhoodProps}.
|
|
95
|
+
* @returns The tie list, or `null` when the lens is disabled or still loading.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```tsx
|
|
99
|
+
* <Neighborhood showInteractionsToggle />
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
function Neighborhood({ showInteractionsToggle = false, style, }) {
|
|
103
|
+
const { neighborhood, includeInteractions, setIncludeInteractions } = (0, social_core_1.useSocialNeighborhood)();
|
|
104
|
+
// Stable per-mount prefix so each tie's fallback gradient id is unique within this component instance.
|
|
105
|
+
const gid = `nb-${react_1.default.useId().replace(/:/g, "")}`;
|
|
106
|
+
if (!neighborhood)
|
|
107
|
+
return null;
|
|
108
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: style, children: [showInteractionsToggle && ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.toggleRow, children: [(0, jsx_runtime_1.jsx)(react_native_1.Switch, { value: includeInteractions, onValueChange: setIncludeInteractions }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.toggleLabel, children: "Include people I\u2019ve interacted with" })] })), (0, jsx_runtime_1.jsx)(react_native_1.ScrollView, { children: neighborhood.ties.map((tie, i) => ((0, jsx_runtime_1.jsx)(TieCard, { tie: tie, gradientId: `${gid}-${i}` }, tie.userId))) })] }));
|
|
109
|
+
}
|
|
110
|
+
const styles = react_native_1.StyleSheet.create({
|
|
111
|
+
toggleRow: { flexDirection: "row", alignItems: "center", gap: 8, marginBottom: 8 },
|
|
112
|
+
toggleLabel: { fontSize: 13 },
|
|
113
|
+
card: { flexDirection: "row", alignItems: "center", gap: 12, paddingVertical: 8, paddingHorizontal: 4 },
|
|
114
|
+
avatar: {
|
|
115
|
+
width: 40,
|
|
116
|
+
height: 40,
|
|
117
|
+
borderRadius: 20,
|
|
118
|
+
overflow: "visible",
|
|
119
|
+
alignItems: "center",
|
|
120
|
+
justifyContent: "center",
|
|
121
|
+
shadowOffset: { width: 0, height: 0 },
|
|
122
|
+
backgroundColor: "#e0a955", // base tint behind the SVG/Image so the glow never reads grey
|
|
123
|
+
},
|
|
124
|
+
avatarImg: { width: 40, height: 40, borderRadius: 20 },
|
|
125
|
+
avatarInitial: { color: "#1b1b24", fontWeight: "700", fontSize: 16 },
|
|
126
|
+
cardText: { flexDirection: "column", gap: 2 },
|
|
127
|
+
name: { fontSize: 14, fontWeight: "600" },
|
|
128
|
+
kinds: { flexDirection: "row", gap: 6 },
|
|
129
|
+
kind: { fontSize: 11, color: "#9ca3af" },
|
|
130
|
+
});
|
|
131
|
+
//# sourceMappingURL=Neighborhood.js.map
|