@openpeepshq/rn-components 0.6.1 → 0.6.2

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.
Files changed (34) hide show
  1. package/package.json +7 -6
  2. package/src/components/conversations/ConversationMessageBubble.tsx +11 -1
  3. package/src/components/custom/navigation/side-menu.tsx +2 -1
  4. package/src/components/icons/index.ts +8 -0
  5. package/src/components/index.ts +1 -0
  6. package/src/components/navigation/helpers.ts +3 -0
  7. package/src/components/navigation/main-navigator.tsx +4 -0
  8. package/src/components/navigation/nativeRouter.tsx +11 -0
  9. package/src/components/navigation/tab-navigator.tsx +13 -3
  10. package/src/components/navigation/types/main.ts +6 -0
  11. package/src/components/navigation/types/tabs.ts +2 -0
  12. package/src/components/post/CompactReplyParent.tsx +22 -0
  13. package/src/components/post/FeedPostContent.tsx +4 -0
  14. package/src/components/post/NewResourceButton.tsx +57 -0
  15. package/src/components/post/PostDetail.tsx +3 -0
  16. package/src/components/post/index.ts +1 -0
  17. package/src/components/post/pieces/PostMenu.tsx +15 -9
  18. package/src/components/post/post-form/PostTypeSwitcher.tsx +19 -1
  19. package/src/components/post/post-form/ResourceForm.tsx +221 -0
  20. package/src/components/post/post-form/index.ts +1 -0
  21. package/src/components/post/types/index.ts +1 -0
  22. package/src/components/post/types/resource/FullResource.tsx +177 -0
  23. package/src/components/resources/ResourceCard.tsx +289 -0
  24. package/src/components/resources/ResourceLibrary.tsx +369 -0
  25. package/src/components/resources/index.ts +4 -0
  26. package/src/global.css +42 -42
  27. package/src/pages/groups/Show.tsx +19 -1
  28. package/src/pages/index.ts +3 -0
  29. package/src/pages/resources/Edit.tsx +72 -0
  30. package/src/pages/resources/Index.tsx +25 -0
  31. package/src/pages/resources/New.tsx +55 -0
  32. package/src/theme/defaults.ts +21 -105
  33. package/src/theme/utils.ts +15 -9
  34. package/tailwind.config.js +31 -29
@@ -1,111 +1,27 @@
1
1
  import type { OpenPeepsTheme, ColorName, ColorValue } from './types';
2
2
 
3
3
  export const DEFAULT_COLORS: ColorValue[] = [
4
- {
5
- name: 'background',
6
- light: '#ffffff',
7
- dark: '#0a0a0f',
8
- },
9
- {
10
- name: 'foreground',
11
- light: '#0a0a0b',
12
- dark: '#fafafa',
13
- },
14
- {
15
- name: 'card',
16
- light: '#ffffff',
17
- dark: '#0a0a0f',
18
- },
19
- {
20
- name: 'card-foreground',
21
- light: '#0a0a0b',
22
- dark: '#fafafa',
23
- },
24
- {
25
- name: 'popover',
26
- light: '#ffffff',
27
- dark: '#0a0a0f',
28
- },
29
- {
30
- name: 'popover-foreground',
31
- light: '#0a0a0b',
32
- dark: '#fafafa',
33
- },
34
- {
35
- name: 'primary',
36
- light: '#16161a',
37
- dark: '#fafafa',
38
- },
39
- {
40
- name: 'primary-foreground',
41
- light: '#fafafa',
42
- dark: '#16161a',
43
- },
44
- {
45
- name: 'secondary',
46
- light: '#f4f4f5',
47
- dark: '#28282e',
48
- },
49
- {
50
- name: 'secondary-foreground',
51
- light: '#16161a',
52
- dark: '#fafafa',
53
- },
54
- {
55
- name: 'muted',
56
- light: '#f4f4f6',
57
- dark: '#27272a',
58
- },
59
- {
60
- name: 'muted-foreground',
61
- light: '#71717a',
62
- dark: '#a1a1aa',
63
- },
64
- {
65
- name: 'accent',
66
- light: '#f4f4f5',
67
- dark: '#28282e',
68
- },
69
- {
70
- name: 'accent-foreground',
71
- light: '#16161a',
72
- dark: '#fafafa',
73
- },
74
- {
75
- name: 'destructive',
76
- light: '#ef4444',
77
- dark: '#dc2626',
78
- },
79
- {
80
- name: 'destructive-foreground',
81
- light: '#fafafa',
82
- dark: '#fafafa',
83
- },
84
- {
85
- name: 'border',
86
- light: '#e4e4e7',
87
- dark: '#28282e',
88
- },
89
- {
90
- name: 'input',
91
- light: '#e4e4e7',
92
- dark: '#28282e',
93
- },
94
- {
95
- name: 'ring',
96
- light: '#16161a',
97
- dark: '#d4d4d8',
98
- },
99
- {
100
- name: 'alpha',
101
- light: '#fafafa',
102
- dark: '#18181b',
103
- },
104
- {
105
- name: 'surface-2',
106
- light: '#e4e4e7',
107
- dark: '#3f3f46',
108
- },
4
+ { name: 'background', light: '#ffffff', dark: '#0a0a0f' },
5
+ { name: 'foreground', light: '#0a0a0b', dark: '#fafafa' },
6
+ { name: 'card', light: '#ffffff', dark: '#0a0a0f' },
7
+ { name: 'card-foreground', light: '#0a0a0b', dark: '#fafafa' },
8
+ { name: 'popover', light: '#ffffff', dark: '#0a0a0f' },
9
+ { name: 'popover-foreground', light: '#0a0a0b', dark: '#fafafa' },
10
+ { name: 'primary', light: '#16161a', dark: '#fafafa' },
11
+ { name: 'primary-foreground', light: '#fafafa', dark: '#16161a' },
12
+ { name: 'secondary', light: '#f4f4f5', dark: '#28282e' },
13
+ { name: 'secondary-foreground', light: '#16161a', dark: '#fafafa' },
14
+ { name: 'muted', light: '#f4f4f6', dark: '#27272a' },
15
+ { name: 'muted-foreground', light: '#71717a', dark: '#a1a1aa' },
16
+ { name: 'accent', light: '#f4f4f5', dark: '#28282e' },
17
+ { name: 'accent-foreground', light: '#16161a', dark: '#fafafa' },
18
+ { name: 'destructive', light: '#ef4444', dark: '#dc2626' },
19
+ { name: 'destructive-foreground', light: '#fafafa', dark: '#fafafa' },
20
+ { name: 'border', light: '#e4e4e7', dark: '#28282e' },
21
+ { name: 'input', light: '#e4e4e7', dark: '#28282e' },
22
+ { name: 'ring', light: '#16161a', dark: '#d4d4d8' },
23
+ { name: 'alpha', light: '#fafafa', dark: '#18181b' },
24
+ { name: 'surface-2', light: '#e4e4e7', dark: '#3f3f46' },
109
25
  ];
110
26
 
111
27
  export const mapColors = (isDark: boolean) =>
@@ -2,8 +2,10 @@ import { vars } from 'nativewind';
2
2
  import { mapColors } from './defaults';
3
3
  import type { OpenPeepsTheme } from './types';
4
4
 
5
- /** Convert a hex color (#rrggbb) to "R G B" channel string for CSS `rgb()` usage. */
6
- const hexToRgbChannels = (hex: string): string => {
5
+ /** Convert a hex color (#rrggbb) to "R G B" channel string for use in
6
+ * `rgb()` expressions in inline styles (NativeWind doesn't support `/N`
7
+ * opacity modifiers on CSS-variable colors). */
8
+ export const hexToRgbChannels = (hex: string): string => {
7
9
  const sanitized = hex.replaceAll('##', '#');
8
10
  const m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(sanitized);
9
11
  if (!m) return hex;
@@ -12,19 +14,23 @@ const hexToRgbChannels = (hex: string): string => {
12
14
  return `${parseInt(r, 16)} ${parseInt(g, 16)} ${parseInt(b, 16)}`;
13
15
  };
14
16
 
17
+ /** Convert a hex color to an `rgba(r, g, b, a)` string for inline styles. */
18
+ export const hexWithOpacity = (hex: string, opacity: number): string => {
19
+ const sanitized = hex.replaceAll('##', '#');
20
+ const m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(sanitized);
21
+ if (!m) return hex;
22
+ const [, r, g, b] = m;
23
+ if (r === undefined || g === undefined || b === undefined) return hex;
24
+ return `rgba(${parseInt(r, 16)}, ${parseInt(g, 16)}, ${parseInt(b, 16)}, ${opacity})`;
25
+ };
26
+
15
27
  export const getThemeVars = (
16
28
  colors: OpenPeepsTheme['colors'],
17
29
  radii?: { buttonRadius?: string; radius?: string }
18
30
  ) =>
19
31
  vars({
20
- // CSS custom properties consumed by Tailwind `channel()` classes need
21
- // "R G B" channel format so `rgb(var(--x) / <alpha-value>)` resolves.
22
- // The `colors` object keeps hex strings for direct RN style usage.
23
32
  ...Object.fromEntries(
24
- Object.entries(colors).map(([key, value]) => [
25
- `--${key}`,
26
- hexToRgbChannels(value),
27
- ])
33
+ Object.entries(colors).map(([key, value]) => [`--${key}`, value])
28
34
  ),
29
35
  '--theme-rounded-base': radii?.buttonRadius || '9999px',
30
36
  '--theme-rounded-container': radii?.radius || '0.5rem',
@@ -1,10 +1,12 @@
1
1
  const { hairlineWidth } = require('nativewind/theme');
2
2
 
3
- /** `channel()` pattern: `rgb(var(--name) / <alpha-value>)` so `/N` opacity
4
- * modifiers (e.g. `bg-primary/10`) work on native. Requires CSS variables to
5
- * be in "R G B" channel format (see global.css / theme/utils.ts). */
6
- const channel = (name) => `rgb(var(${name}) / <alpha-value>)`;
7
-
3
+ /**
4
+ * NOTE: NativeWind v4 does not resolve Tailwind's `<alpha-value>` token,
5
+ * so the `rgb(var(--x) / <alpha-value>)` "channel()" pattern used on web
6
+ * breaks ALL color classes on native. Colors use plain `var(--x)` references
7
+ * instead. Opacity modifiers (`bg-primary/10`) are handled via inline styles
8
+ * in the components that need them (see ConversationMessageBubble).
9
+ */
8
10
  export default {
9
11
  // NOTE: Update this to include the paths to all of your component files.
10
12
  darkMode: 'class',
@@ -14,51 +16,51 @@ export default {
14
16
  theme: {
15
17
  extend: {
16
18
  colors: {
17
- 'border': channel('--border'),
18
- 'input': channel('--input'),
19
- 'ring': channel('--ring'),
20
- 'background': channel('--background'),
21
- 'foreground': channel('--foreground'),
19
+ 'border': 'var(--border)',
20
+ 'input': 'var(--input)',
21
+ 'ring': 'var(--ring)',
22
+ 'background': 'var(--background)',
23
+ 'foreground': 'var(--foreground)',
22
24
  'primary': {
23
- DEFAULT: channel('--primary'),
24
- foreground: channel('--primary-foreground'),
25
+ DEFAULT: 'var(--primary)',
26
+ foreground: 'var(--primary-foreground)',
25
27
  },
26
28
  'secondary': {
27
- DEFAULT: channel('--secondary'),
28
- foreground: channel('--secondary-foreground'),
29
+ DEFAULT: 'var(--secondary)',
30
+ foreground: 'var(--secondary-foreground)',
29
31
  },
30
32
  'destructive': {
31
- DEFAULT: channel('--destructive'),
32
- foreground: channel('--destructive-foreground'),
33
+ DEFAULT: 'var(--destructive)',
34
+ foreground: 'var(--destructive-foreground)',
33
35
  },
34
36
  'muted': {
35
- DEFAULT: channel('--muted'),
36
- foreground: channel('--muted-foreground'),
37
+ DEFAULT: 'var(--muted)',
38
+ foreground: 'var(--muted-foreground)',
37
39
  },
38
40
  'accent': {
39
- DEFAULT: channel('--accent'),
40
- foreground: channel('--accent-foreground'),
41
+ DEFAULT: 'var(--accent)',
42
+ foreground: 'var(--accent-foreground)',
41
43
  },
42
44
  'popover': {
43
- DEFAULT: channel('--popover'),
44
- foreground: channel('--popover-foreground'),
45
+ DEFAULT: 'var(--popover)',
46
+ foreground: 'var(--popover-foreground)',
45
47
  },
46
48
  'card': {
47
- DEFAULT: channel('--card'),
48
- foreground: channel('--card-foreground'),
49
+ DEFAULT: 'var(--card)',
50
+ foreground: 'var(--card-foreground)',
49
51
  },
50
52
  // `surface` mirrors `muted` (same token on the web preset).
51
53
  'surface': {
52
- DEFAULT: channel('--muted'),
53
- foreground: channel('--muted-foreground'),
54
+ DEFAULT: 'var(--muted)',
55
+ foreground: 'var(--muted-foreground)',
54
56
  },
55
- 'surface-2': channel('--surface-2'),
56
- 'alpha': channel('--alpha'),
57
+ 'surface-2': 'var(--surface-2)',
58
+ 'alpha': 'var(--alpha)',
57
59
  },
58
60
  // Override Tailwind's default `borderColor.DEFAULT` so bare `border`/`border-b`
59
61
  // utilities follow the theme border color instead of a static gray.
60
62
  borderColor: {
61
- DEFAULT: channel('--border'),
63
+ DEFAULT: 'var(--border)',
62
64
  },
63
65
  borderWidth: {
64
66
  hairline: hairlineWidth(),