@opndev/react-native-events 0.0.13 → 0.0.14
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/Changes +5 -0
- package/lib/components/panel.jsx +65 -0
- package/lib/components.js +1 -0
- package/lib/index.js +1 -1
- package/lib/widgets/news-widget.jsx +19 -0
- package/package.json +1 -1
package/Changes
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
Revision history for @opndev/opndev-react-native-events
|
|
2
2
|
|
|
3
|
+
0.0.14 2026-06-26 04:53:23Z
|
|
4
|
+
|
|
5
|
+
* Add Panel instead of a Tile, Tiles are more buttony thing. Panels are
|
|
6
|
+
panels. ha.
|
|
7
|
+
|
|
3
8
|
0.0.13 2026-06-26 03:59:55Z
|
|
4
9
|
|
|
5
10
|
* Update news item segment to be included as a widget.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Wesley Schwengle <wesleys@opperschaap.net>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-OPNDEV-exceptions
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { View, Pressable, StyleSheet } from 'react-native';
|
|
7
|
+
|
|
8
|
+
const defaultStyle = StyleSheet.create({
|
|
9
|
+
surface: {
|
|
10
|
+
borderRadius: 16,
|
|
11
|
+
overflow: 'hidden',
|
|
12
|
+
},
|
|
13
|
+
content: {
|
|
14
|
+
padding: 16,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Panel
|
|
20
|
+
*
|
|
21
|
+
* Simple rounded-corner surface that sizes to its content. Unlike
|
|
22
|
+
* Tile (built for a centered icon+label grid cell with flex: 1),
|
|
23
|
+
* Panel imposes no layout assumptions on its children at all — no
|
|
24
|
+
* forced centering, no forced flex sizing — so content-driven
|
|
25
|
+
* widgets (lists, text blocks, NewsWidget, etc.) render exactly as
|
|
26
|
+
* they would un-wrapped, just inside a rounded/backgrounded card.
|
|
27
|
+
*
|
|
28
|
+
* @param {object} props
|
|
29
|
+
* @param {React.ReactNode} props.children
|
|
30
|
+
* @param {string} [props.backgroundColor]
|
|
31
|
+
* @param {Function} [props.onPress] If provided, the whole panel becomes pressable.
|
|
32
|
+
* @param {object} [props.style] Style for the outer rounded surface.
|
|
33
|
+
* @param {object} [props.contentStyle] Style for the inner content wrapper (default padding: 16).
|
|
34
|
+
*
|
|
35
|
+
* @returns {JSX.Element}
|
|
36
|
+
*/
|
|
37
|
+
export default function Panel({
|
|
38
|
+
children,
|
|
39
|
+
backgroundColor,
|
|
40
|
+
onPress,
|
|
41
|
+
style,
|
|
42
|
+
contentStyle,
|
|
43
|
+
}) {
|
|
44
|
+
const surfaceStyle = [
|
|
45
|
+
defaultStyle.surface,
|
|
46
|
+
backgroundColor ? { backgroundColor } : null,
|
|
47
|
+
style,
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const content = (
|
|
51
|
+
<View style={[defaultStyle.content, contentStyle]}>
|
|
52
|
+
{children}
|
|
53
|
+
</View>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
if (onPress) {
|
|
57
|
+
return (
|
|
58
|
+
<Pressable onPress={onPress} style={surfaceStyle}>
|
|
59
|
+
{content}
|
|
60
|
+
</Pressable>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return <View style={surfaceStyle}>{content}</View>;
|
|
65
|
+
}
|
package/lib/components.js
CHANGED
|
@@ -11,6 +11,7 @@ export { default as Tile } from './components/tile.jsx';
|
|
|
11
11
|
export { default as GradientTile } from './components/gradient-tile.jsx';
|
|
12
12
|
export { default as QRCodeForm } from './components/qr-code-form.jsx';
|
|
13
13
|
export { default as ScaledLogo } from './components/scaled-logo.jsx';
|
|
14
|
+
export { default as Panel } from './components/panel.jsx';
|
|
14
15
|
|
|
15
16
|
export { openUrl, openApp, openExternal } from './utils/launch.js';
|
|
16
17
|
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Wesley Schwengle <wesleys@opperschaap.net>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-OPNDEV-exceptions
|
|
4
|
+
|
|
1
5
|
import React, {
|
|
2
6
|
forwardRef,
|
|
3
7
|
useEffect,
|
|
@@ -22,6 +26,12 @@ const defaultStyle = StyleSheet.create({
|
|
|
22
26
|
title: {
|
|
23
27
|
fontWeight: '700',
|
|
24
28
|
},
|
|
29
|
+
divider: {
|
|
30
|
+
height: 1,
|
|
31
|
+
backgroundColor: 'rgba(0,0,0,0.15)',
|
|
32
|
+
marginTop: 4,
|
|
33
|
+
marginBottom: 4,
|
|
34
|
+
},
|
|
25
35
|
item: {
|
|
26
36
|
flexDirection: 'row',
|
|
27
37
|
gap: 8,
|
|
@@ -59,6 +69,8 @@ const defaultStyle = StyleSheet.create({
|
|
|
59
69
|
* @param {string} [props.bearerToken]
|
|
60
70
|
* @param {number} [props.limit] Max items shown. Defaults to 4.
|
|
61
71
|
* @param {string} [props.title] Defaults to 'News'.
|
|
72
|
+
* @param {boolean} [props.showDivider] Thin line under the title, like 'News' / '-----'. Defaults to true. Ignored if title is falsy.
|
|
73
|
+
* @param {object} [props.dividerStyle]
|
|
62
74
|
* @param {React.ComponentType} [props.TextComponent] Defaults to Text.
|
|
63
75
|
* @param {Function} [props.onPressItem]
|
|
64
76
|
* @param {number} [props.refreshIntervalMs] Defaults to 15 minutes.
|
|
@@ -79,6 +91,8 @@ const NewsWidget = forwardRef(function NewsWidget(
|
|
|
79
91
|
bearerToken,
|
|
80
92
|
limit = 4,
|
|
81
93
|
title = 'News',
|
|
94
|
+
showDivider = true,
|
|
95
|
+
dividerStyle,
|
|
82
96
|
TextComponent = Text,
|
|
83
97
|
onPressItem,
|
|
84
98
|
refreshIntervalMs = 15 * 60 * 1000,
|
|
@@ -142,6 +156,10 @@ const NewsWidget = forwardRef(function NewsWidget(
|
|
|
142
156
|
</TextComponent>
|
|
143
157
|
) : null}
|
|
144
158
|
|
|
159
|
+
{title && showDivider ? (
|
|
160
|
+
<View style={[defaultStyle.divider, dividerStyle]} />
|
|
161
|
+
) : null}
|
|
162
|
+
|
|
145
163
|
{loading ? <ActivityIndicator /> : null}
|
|
146
164
|
|
|
147
165
|
{!loading && error ? (
|
|
@@ -169,3 +187,4 @@ const NewsWidget = forwardRef(function NewsWidget(
|
|
|
169
187
|
});
|
|
170
188
|
|
|
171
189
|
export default NewsWidget;
|
|
190
|
+
|
package/package.json
CHANGED