@proulr/sdui-components 0.1.2 → 0.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proulr/sdui-components",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "main": "./src/renderer/index.ts",
5
5
  "types": "./src/renderer/index.ts",
6
6
  "exports": {
@@ -44,6 +44,19 @@ function textFromChildren(children: BdcElement[]): string {
44
44
  .trim();
45
45
  }
46
46
 
47
+ function mapHeaderToWire(header: Record<string, unknown>): SduiHeaderWire {
48
+ const wire: Record<string, unknown> = {};
49
+ for (const [key, value] of Object.entries(header)) {
50
+ if (key === 'slotBlocks' || key === 'slot_blocks' || key === 'headerSlot') continue;
51
+ if (key === 'headerSearch') {
52
+ wire.header_search = value;
53
+ continue;
54
+ }
55
+ wire[camelToSnake(key)] = value;
56
+ }
57
+ return wire as SduiHeaderWire;
58
+ }
59
+
47
60
  export function compileBdcBlock(element: BdcElement, path = '0'): SduiBlockWire {
48
61
  return mapBlock(element, path);
49
62
  }
@@ -105,7 +118,7 @@ export function compileBdcToWire(root: BdcElement): SduiScreenWire {
105
118
  .filter((child) => child.type !== '_fragment')
106
119
  .map((child, index) => mapBlock(child, String(index)));
107
120
 
108
- const compiledHeader = header ? { ...header } : undefined;
121
+ const compiledHeader = header ? mapHeaderToWire(header as Record<string, unknown>) : undefined;
109
122
  if (compiledHeader && headerSlot) {
110
123
  const slotRoots = Array.isArray(headerSlot) ? headerSlot : [headerSlot];
111
124
  compiledHeader.slot_blocks = slotRoots.map((slot, index) => mapBlock(slot, `header.${index}`));
@@ -29,6 +29,7 @@ export const ProfileOnboarding: BdcComponent = (props) => nativeBlock('profile_o
29
29
  export const AlbumGrid: BdcComponent = (props) => nativeBlock('album_grid', props);
30
30
  export const AlbumDetail: BdcComponent = (props) => nativeBlock('album_detail', props);
31
31
  export const NewPostComposer: BdcComponent = (props) => nativeBlock('new_post_composer', props);
32
+ export const NewStoryComposer: BdcComponent = (props) => nativeBlock('new_story_composer', props);
32
33
  export const PostComments: BdcComponent = (props) => nativeBlock('post_comments', props);
33
34
  export const SocialProfile: BdcComponent = (props) => nativeBlock('social_profile', props);
34
35
  export const SettingsHome: BdcComponent = (props) => nativeBlock('settings_home', props);
package/src/bdc/index.ts CHANGED
@@ -25,6 +25,7 @@ export {
25
25
  ChatThread,
26
26
  FlashInboxList,
27
27
  NewPostComposer,
28
+ NewStoryComposer,
28
29
  PostComments,
29
30
  ProfileOnboarding,
30
31
  ProfileSelf,
@@ -31,6 +31,7 @@ function NativeBlockShell({
31
31
  | 'renderAlbumGrid'
32
32
  | 'renderAlbumDetail'
33
33
  | 'renderNewPostComposer'
34
+ | 'renderNewStoryComposer'
34
35
  | 'renderPostComments'
35
36
  | 'renderSocialProfile'
36
37
  | 'renderSettingsHome'
@@ -118,6 +119,10 @@ export function SduiNewPostComposerBlock(props: SduiBlockRenderProps) {
118
119
  return <NativeBlockShell {...props} rendererKey="renderNewPostComposer" fallbackLabel="Nova publicação" />;
119
120
  }
120
121
 
122
+ export function SduiNewStoryComposerBlock(props: SduiBlockRenderProps) {
123
+ return <NativeBlockShell {...props} rendererKey="renderNewStoryComposer" fallbackLabel="Novo story" />;
124
+ }
125
+
121
126
  export function SduiPostCommentsBlock(props: SduiBlockRenderProps) {
122
127
  return <NativeBlockShell {...props} rendererKey="renderPostComments" fallbackLabel="Comentários" />;
123
128
  }
@@ -37,6 +37,7 @@ import {
37
37
  SduiChatThreadBlock,
38
38
  SduiFlashInboxListBlock,
39
39
  SduiNewPostComposerBlock,
40
+ SduiNewStoryComposerBlock,
40
41
  SduiPostCommentsBlock,
41
42
  SduiProfileOnboardingBlock,
42
43
  SduiProfileSelfBlock,
@@ -88,6 +89,7 @@ const REGISTRY: Record<string, SduiBlockComponent> = {
88
89
  album_grid: SduiAlbumGridBlock,
89
90
  album_detail: SduiAlbumDetailBlock,
90
91
  new_post_composer: SduiNewPostComposerBlock,
92
+ new_story_composer: SduiNewStoryComposerBlock,
91
93
  post_comments: SduiPostCommentsBlock,
92
94
  social_profile: SduiSocialProfileBlock,
93
95
  settings_home: SduiSettingsHomeBlock,
@@ -66,6 +66,7 @@ export type SduiHybridRenderers = {
66
66
  renderAlbumGrid?: (props: SduiNativeBlockRenderProps) => ReactNode;
67
67
  renderAlbumDetail?: (props: SduiNativeBlockRenderProps) => ReactNode;
68
68
  renderNewPostComposer?: (props: SduiNativeBlockRenderProps) => ReactNode;
69
+ renderNewStoryComposer?: (props: SduiNativeBlockRenderProps) => ReactNode;
69
70
  renderPostComments?: (props: SduiNativeBlockRenderProps) => ReactNode;
70
71
  renderSocialProfile?: (props: SduiNativeBlockRenderProps) => ReactNode;
71
72
  renderSettingsHome?: (props: SduiNativeBlockRenderProps) => ReactNode;
@@ -1,4 +1,4 @@
1
- import { StyleSheet, View } from 'react-native';
1
+ import { Platform, StyleSheet, Text, View } from 'react-native';
2
2
  import { m3Colors } from '../theme/proulr-theme';
3
3
 
4
4
  export type AppChromeGlyphProps = {
@@ -833,48 +833,23 @@ export function AppChromeRepostGlyph({ color = m3Colors.primary, size = 24 }: Ap
833
833
  type HeartGlyphProps = AppChromeGlyphProps & { filled?: boolean };
834
834
 
835
835
  function AppChromeHeartShape({ color = m3Colors.primary, size = 24, filled = false }: HeartGlyphProps) {
836
- const stroke = strokeFor(size);
837
- const unit = size * 0.26;
838
- const fill = filled ? color : 'transparent';
839
- const borderW = filled ? 0 : stroke;
840
-
836
+ const glyph = filled ? '♥' : '♡';
841
837
  return (
842
838
  <View style={{ width: size, height: size, alignItems: 'center', justifyContent: 'center' }}>
843
- <View
839
+ <Text
844
840
  style={{
845
- width: unit * 1.65,
846
- height: unit * 1.65,
847
- transform: [{ rotate: '-45deg' }],
848
- marginTop: unit * 0.18,
841
+ color,
842
+ fontSize: size * 0.9,
843
+ lineHeight: size,
844
+ height: size,
845
+ textAlign: 'center',
846
+ ...(Platform.OS === 'android'
847
+ ? { includeFontPadding: false, textAlignVertical: 'center' as const }
848
+ : null),
849
849
  }}
850
850
  >
851
- <View
852
- style={{
853
- position: 'absolute',
854
- width: unit,
855
- height: unit * 1.62,
856
- borderRadius: unit,
857
- backgroundColor: fill,
858
- borderWidth: borderW,
859
- borderColor: color,
860
- top: 0,
861
- left: unit * 0.32,
862
- }}
863
- />
864
- <View
865
- style={{
866
- position: 'absolute',
867
- width: unit * 1.62,
868
- height: unit,
869
- borderRadius: unit,
870
- backgroundColor: fill,
871
- borderWidth: borderW,
872
- borderColor: color,
873
- top: unit * 0.32,
874
- left: 0,
875
- }}
876
- />
877
- </View>
851
+ {glyph}
852
+ </Text>
878
853
  </View>
879
854
  );
880
855
  }
@@ -928,6 +903,60 @@ export function AppChromeHeartFilledGlyph(props: AppChromeGlyphProps) {
928
903
  return <AppChromeHeartShape {...props} filled />;
929
904
  }
930
905
 
906
+ type ThumbsUpGlyphProps = AppChromeGlyphProps & { filled?: boolean };
907
+
908
+ function AppChromeThumbsUpShape({ color = m3Colors.primary, size = 24, filled = false }: ThumbsUpGlyphProps) {
909
+ const stroke = strokeFor(size);
910
+ const palmW = size * 0.46;
911
+ const palmH = size * 0.34;
912
+ const thumbW = size * 0.2;
913
+ const thumbH = size * 0.36;
914
+ const fill = filled ? color : 'transparent';
915
+ const borderW = filled ? 0 : stroke;
916
+ const radius = Math.max(2, size * 0.07);
917
+
918
+ return (
919
+ <View style={{ width: size, height: size, alignItems: 'center', justifyContent: 'center' }}>
920
+ <View style={{ width: palmW, height: palmH + thumbH * 0.62 }}>
921
+ <View
922
+ style={{
923
+ position: 'absolute',
924
+ top: 0,
925
+ right: palmW * 0.04,
926
+ width: thumbW,
927
+ height: thumbH,
928
+ borderRadius: thumbW / 2,
929
+ backgroundColor: fill,
930
+ borderWidth: borderW,
931
+ borderColor: color,
932
+ }}
933
+ />
934
+ <View
935
+ style={{
936
+ position: 'absolute',
937
+ bottom: 0,
938
+ left: 0,
939
+ width: palmW,
940
+ height: palmH,
941
+ borderRadius: radius,
942
+ backgroundColor: fill,
943
+ borderWidth: borderW,
944
+ borderColor: color,
945
+ }}
946
+ />
947
+ </View>
948
+ </View>
949
+ );
950
+ }
951
+
952
+ export function AppChromeThumbsUpGlyph(props: AppChromeGlyphProps) {
953
+ return <AppChromeThumbsUpShape {...props} filled={false} />;
954
+ }
955
+
956
+ export function AppChromeThumbsUpFilledGlyph(props: AppChromeGlyphProps) {
957
+ return <AppChromeThumbsUpShape {...props} filled />;
958
+ }
959
+
931
960
  export function AppChromePlusGlyph({ color = m3Colors.primary, size = 24 }: AppChromeGlyphProps) {
932
961
  const stroke = strokeFor(size);
933
962
  const arm = size * 0.46;
@@ -16,6 +16,8 @@ import {
16
16
  AppChromeFlipCameraGlyph,
17
17
  AppChromeHeartFilledGlyph,
18
18
  AppChromeHeartGlyph,
19
+ AppChromeThumbsUpFilledGlyph,
20
+ AppChromeThumbsUpGlyph,
19
21
  AppChromeHuntGlyph,
20
22
  AppChromeIncognitoGlyph,
21
23
  AppChromeListGlyph,
@@ -102,6 +104,8 @@ export type AppIconName =
102
104
  | 'repost'
103
105
  | 'heart'
104
106
  | 'heart-filled'
107
+ | 'thumbs-up'
108
+ | 'thumbs-up-filled'
105
109
  | 'play'
106
110
  | 'pause'
107
111
  | 'plus'
@@ -154,6 +158,8 @@ const ICON_REGISTRY: Record<AppIconName, ComponentType<AppChromeGlyphProps>> = {
154
158
  repost: AppChromeRepostGlyph,
155
159
  heart: AppChromeHeartGlyph,
156
160
  'heart-filled': AppChromeHeartFilledGlyph,
161
+ 'thumbs-up': AppChromeThumbsUpGlyph,
162
+ 'thumbs-up-filled': AppChromeThumbsUpFilledGlyph,
157
163
  play: AppChromePlayGlyph,
158
164
  pause: AppChromePauseGlyph,
159
165
  plus: AppChromePlusGlyph,
@@ -33,6 +33,8 @@ export {
33
33
  AppChromeFlipCameraGlyph,
34
34
  AppChromeHeartFilledGlyph,
35
35
  AppChromeHeartGlyph,
36
+ AppChromeThumbsUpFilledGlyph,
37
+ AppChromeThumbsUpGlyph,
36
38
  AppChromeHuntGlyph,
37
39
  AppChromeIncognitoGlyph,
38
40
  AppChromeListGlyph,