@proulr/sdui-components 0.1.45 → 0.1.46

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.45",
3
+ "version": "0.1.46",
4
4
  "type": "module",
5
5
  "main": "./src/renderer/index.ts",
6
6
  "types": "./src/renderer/index.ts",
@@ -1,18 +1,11 @@
1
1
  import React from 'react';
2
- import { StyleSheet, Text, View } from 'react-native';
3
- import QRCode from 'react-native-qrcode-svg';
4
- import { gradients, m3Colors, m3Shape, m3Type, spacing } from '../theme/proulr-theme';
5
2
  import { resolveViewStyleProps } from '../theme/resolve-style-props';
3
+ import { BrandQrNametag } from '../ui/brand-qr-code';
6
4
  import type { SduiBlockRenderProps } from './SduiPrimitiveBlocks';
7
5
 
8
- // `require` (padrão RN para assets estáticos) — import ESM de .png exigiria um
9
- // ambient d.ts que consumers compilando o source em node_modules não enxergam.
10
- const brandMarkAsset = require('../assets/proulr-brand-mark.png') as number;
11
-
12
6
  /**
13
- * Nametag de QR estilo "cartão de convite" (ref. Instagram): cartão claro
14
- * (inverseSurface) com QR customizado da marca — módulos no gradiente Proulr
15
- * (roxo → fúcsia) e brand mark no centro (ECC alto para manter a leitura).
7
+ * Bloco wire do QR de marca — delega para o BrandQrNametag (componente único
8
+ * de QR do produto, usado também fora do SDUI, ex.: convite de grupo no chat).
16
9
  * Wire: `value` = conteúdo do QR, `size` em px, `label` = texto sob o código.
17
10
  */
18
11
  export function SduiQrCodeBlock({ block }: SduiBlockRenderProps) {
@@ -23,41 +16,11 @@ export function SduiQrCodeBlock({ block }: SduiBlockRenderProps) {
23
16
  const label = typeof block.props.label === 'string' ? block.props.label : '';
24
17
 
25
18
  return (
26
- <View
27
- style={[styles.card, resolveViewStyleProps(block.props.style as Record<string, unknown>)]}
28
- >
29
- <QRCode
30
- value={value}
31
- size={size}
32
- backgroundColor={m3Colors.inverseSurface}
33
- enableLinearGradient
34
- linearGradient={[...gradients.brand]}
35
- ecl="H"
36
- logo={brandMarkAsset}
37
- logoSize={Math.round(size * 0.22)}
38
- logoBackgroundColor={m3Colors.inverseSurface}
39
- logoMargin={Math.max(3, Math.round(size * 0.02))}
40
- logoBorderRadius={m3Shape.cornerMedium}
41
- />
42
- {label ? <Text style={styles.label}>{label}</Text> : null}
43
- </View>
19
+ <BrandQrNametag
20
+ value={value}
21
+ size={size}
22
+ label={label || undefined}
23
+ style={resolveViewStyleProps(block.props.style as Record<string, unknown>)}
24
+ />
44
25
  );
45
26
  }
46
-
47
- const styles = StyleSheet.create({
48
- card: {
49
- alignSelf: 'center',
50
- alignItems: 'center',
51
- gap: spacing.lg,
52
- backgroundColor: m3Colors.inverseSurface,
53
- borderRadius: m3Shape.cornerExtraLarge,
54
- paddingVertical: spacing.xl,
55
- paddingHorizontal: spacing.xl,
56
- },
57
- label: {
58
- ...m3Type.title,
59
- color: m3Colors.inverseOnSurface,
60
- letterSpacing: 2,
61
- textTransform: 'uppercase',
62
- },
63
- });
@@ -0,0 +1,72 @@
1
+ import React from 'react';
2
+ import { StyleSheet, Text, View, type StyleProp, type ViewStyle } from 'react-native';
3
+ import QRCode from 'react-native-qrcode-svg';
4
+ import { gradients, m3Colors, m3Shape, m3Type, spacing } from '../theme/proulr-theme';
5
+
6
+ // `require` (padrão RN para assets estáticos) — import ESM de .png exigiria um
7
+ // ambient d.ts que consumers compilando o source em node_modules não enxergam.
8
+ const brandMarkAsset = require('../assets/proulr-brand-mark.png') as number;
9
+
10
+ export type BrandQrCodeProps = {
11
+ value: string;
12
+ size?: number;
13
+ };
14
+
15
+ /**
16
+ * QR customizado da marca (ref. QR do Instagram): módulos no gradiente Proulr
17
+ * (roxo → fúcsia) sobre fundo claro e brand mark no centro, com ECC "H" para
18
+ * manter a leitura mesmo com o logo cobrindo o miolo. Componente único para
19
+ * todo QR de produto (convidar amigos, convite de grupo, etc.).
20
+ */
21
+ export function BrandQrCode({ value, size = 200 }: BrandQrCodeProps) {
22
+ return (
23
+ <QRCode
24
+ value={value}
25
+ size={size}
26
+ backgroundColor={m3Colors.inverseSurface}
27
+ enableLinearGradient
28
+ linearGradient={[...gradients.brand]}
29
+ ecl="H"
30
+ logo={brandMarkAsset}
31
+ logoSize={Math.round(size * 0.22)}
32
+ logoBackgroundColor={m3Colors.inverseSurface}
33
+ logoMargin={Math.max(3, Math.round(size * 0.02))}
34
+ logoBorderRadius={m3Shape.cornerMedium}
35
+ />
36
+ );
37
+ }
38
+
39
+ export type BrandQrNametagProps = BrandQrCodeProps & {
40
+ label?: string;
41
+ style?: StyleProp<ViewStyle>;
42
+ };
43
+
44
+ /**
45
+ * Nametag: cartão claro (inverseSurface) com o BrandQrCode e rótulo opcional
46
+ * (ex.: @handle). É o "cartão de convite" padrão exibido em telas e bubbles.
47
+ */
48
+ export function BrandQrNametag({ value, size = 200, label, style }: BrandQrNametagProps) {
49
+ const cardPadding = size >= 160 ? spacing.xl : spacing.md;
50
+ return (
51
+ <View style={[styles.card, { padding: cardPadding }, style]}>
52
+ <BrandQrCode value={value} size={size} />
53
+ {label ? <Text style={styles.label}>{label}</Text> : null}
54
+ </View>
55
+ );
56
+ }
57
+
58
+ const styles = StyleSheet.create({
59
+ card: {
60
+ alignSelf: 'center',
61
+ alignItems: 'center',
62
+ gap: spacing.lg,
63
+ backgroundColor: m3Colors.inverseSurface,
64
+ borderRadius: m3Shape.cornerExtraLarge,
65
+ },
66
+ label: {
67
+ ...m3Type.title,
68
+ color: m3Colors.inverseOnSurface,
69
+ letterSpacing: 2,
70
+ textTransform: 'uppercase',
71
+ },
72
+ });
@@ -1,4 +1,10 @@
1
1
  export { AppButton } from './AppButton';
2
+ export {
3
+ BrandQrCode,
4
+ BrandQrNametag,
5
+ type BrandQrCodeProps,
6
+ type BrandQrNametagProps,
7
+ } from './brand-qr-code';
2
8
  export { AppChromeIconButton } from './AppChromeIconButton';
3
9
  export { AppLoadingSpinner } from './AppLoadingSpinner';
4
10
  export { AuthStepShell } from './AuthStepShell';