@devvit/ui-renderer 0.9.0 → 0.9.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 (92) hide show
  1. package/blocks/attributes.d.ts +3 -1
  2. package/blocks/attributes.d.ts.map +1 -1
  3. package/blocks/attributes.js +29 -17
  4. package/blocks/components/devvit-blocks-webview.d.ts +2 -0
  5. package/blocks/components/devvit-blocks-webview.d.ts.map +1 -0
  6. package/blocks/components/devvit-blocks-webview.js +81 -0
  7. package/blocks/templates/index.d.ts +4 -5
  8. package/blocks/templates/index.d.ts.map +1 -1
  9. package/blocks/templates/index.js +5 -4
  10. package/blocks/templates/renderAnimationBlock.d.ts.map +1 -1
  11. package/blocks/templates/renderAnimationBlock.js +4 -1
  12. package/blocks/templates/renderAvatarBlock.d.ts.map +1 -1
  13. package/blocks/templates/renderAvatarBlock.js +4 -1
  14. package/blocks/templates/renderBlock.d.ts.map +1 -1
  15. package/blocks/templates/renderBlock.js +31 -10
  16. package/blocks/templates/renderButtonBlock.d.ts.map +1 -1
  17. package/blocks/templates/renderButtonBlock.js +11 -2
  18. package/blocks/templates/renderFullSnooBlock.d.ts.map +1 -1
  19. package/blocks/templates/renderFullSnooBlock.js +4 -1
  20. package/blocks/templates/renderIconBlock.d.ts.map +1 -1
  21. package/blocks/templates/renderIconBlock.js +6 -2
  22. package/blocks/templates/renderImageBlock.d.ts.map +1 -1
  23. package/blocks/templates/renderImageBlock.js +4 -1
  24. package/blocks/templates/renderSpacerBlock.d.ts.map +1 -1
  25. package/blocks/templates/renderSpacerBlock.js +8 -2
  26. package/blocks/templates/renderStackBlock.d.ts.map +1 -1
  27. package/blocks/templates/renderStackBlock.js +21 -2
  28. package/blocks/templates/renderTextBlock.d.ts.map +1 -1
  29. package/blocks/templates/renderTextBlock.js +4 -1
  30. package/blocks/templates/renderWebViewBlock.d.ts +1 -0
  31. package/blocks/templates/renderWebViewBlock.d.ts.map +1 -1
  32. package/blocks/templates/renderWebViewBlock.js +9 -16
  33. package/client/devvit-custom-post.d.ts +2 -2
  34. package/client/devvit-custom-post.d.ts.map +1 -1
  35. package/client/devvit-custom-post.js +23 -12
  36. package/client/effects/form-effect-handler.d.ts +1 -0
  37. package/client/effects/form-effect-handler.d.ts.map +1 -1
  38. package/client/effects/form-effect-handler.js +9 -5
  39. package/client/formbuilder/components/devvit-form-selection-dropdown.d.ts +17 -0
  40. package/client/formbuilder/components/devvit-form-selection-dropdown.d.ts.map +1 -0
  41. package/client/formbuilder/components/devvit-form-selection-dropdown.js +138 -0
  42. package/client/formbuilder/components/devvit-form-selection-list.d.ts +14 -0
  43. package/client/formbuilder/components/devvit-form-selection-list.d.ts.map +1 -0
  44. package/client/formbuilder/components/devvit-form-selection-list.js +91 -0
  45. package/client/formbuilder/devvit-form-dialog.d.ts +17 -0
  46. package/client/formbuilder/devvit-form-dialog.d.ts.map +1 -0
  47. package/client/formbuilder/devvit-form-dialog.js +152 -0
  48. package/client/formbuilder/fields/index.d.ts +12 -0
  49. package/client/formbuilder/fields/index.d.ts.map +1 -0
  50. package/client/formbuilder/fields/index.js +10 -0
  51. package/client/formbuilder/fields/renderBooleanField.d.ts +4 -0
  52. package/client/formbuilder/fields/renderBooleanField.d.ts.map +1 -0
  53. package/client/formbuilder/fields/renderBooleanField.js +14 -0
  54. package/client/formbuilder/fields/renderFieldLabel.d.ts +3 -0
  55. package/client/formbuilder/fields/renderFieldLabel.d.ts.map +1 -0
  56. package/client/formbuilder/fields/renderFieldLabel.js +3 -0
  57. package/client/formbuilder/fields/renderFormFields.d.ts +4 -0
  58. package/client/formbuilder/fields/renderFormFields.d.ts.map +1 -0
  59. package/client/formbuilder/fields/renderFormFields.js +18 -0
  60. package/client/formbuilder/fields/renderGroupField.d.ts +3 -0
  61. package/client/formbuilder/fields/renderGroupField.d.ts.map +1 -0
  62. package/client/formbuilder/fields/renderGroupField.js +13 -0
  63. package/client/formbuilder/fields/renderHelpText.d.ts +4 -0
  64. package/client/formbuilder/fields/renderHelpText.d.ts.map +1 -0
  65. package/client/formbuilder/fields/renderHelpText.js +3 -0
  66. package/client/formbuilder/fields/renderListField.d.ts +2 -0
  67. package/client/formbuilder/fields/renderListField.d.ts.map +1 -0
  68. package/client/formbuilder/fields/renderListField.js +1 -0
  69. package/client/formbuilder/fields/renderNumberField.d.ts +4 -0
  70. package/client/formbuilder/fields/renderNumberField.d.ts.map +1 -0
  71. package/client/formbuilder/fields/renderNumberField.js +23 -0
  72. package/client/formbuilder/fields/renderParagraphField.d.ts +5 -0
  73. package/client/formbuilder/fields/renderParagraphField.d.ts.map +1 -0
  74. package/client/formbuilder/fields/renderParagraphField.js +25 -0
  75. package/client/formbuilder/fields/renderSelectionField.d.ts +5 -0
  76. package/client/formbuilder/fields/renderSelectionField.d.ts.map +1 -0
  77. package/client/formbuilder/fields/renderSelectionField.js +18 -0
  78. package/client/formbuilder/fields/renderStringField.d.ts +4 -0
  79. package/client/formbuilder/fields/renderStringField.d.ts.map +1 -0
  80. package/client/formbuilder/fields/renderStringField.js +24 -0
  81. package/client/formbuilder/index.d.ts +2 -0
  82. package/client/formbuilder/index.d.ts.map +1 -0
  83. package/client/formbuilder/index.js +1 -0
  84. package/package.json +28 -22
  85. package/styles.css +793 -51
  86. package/styles.d.ts +2 -0
  87. package/styles.d.ts.map +1 -0
  88. package/styles.js +3 -0
  89. package/types/events.d.ts +20 -0
  90. package/types/events.d.ts.map +1 -0
  91. package/types/events.js +1 -0
  92. package/tailwind.devvit.cjs +0 -15
@@ -1,9 +1,11 @@
1
1
  import { ClassInfo } from 'lit/directives/class-map.js';
2
2
  import { StyleInfo } from 'lit/directives/style-map.js';
3
3
  import { ButtonAppearance, ButtonSize } from '@reddit/faceplate-ui/templates/button.js';
4
- import { Block, BlockAlignment, BlockAvatarFacing, BlockAvatarSize, BlockBorder, BlockButtonAppearance, BlockButtonSize, BlockFullSnooSize, BlockGap, BlockIconSize, BlockImageResizeMode, BlockPadding, BlockRadius, BlockSize, BlockSpacerSize, BlockStackDirection, BlockTextOutline, BlockTextSize, BlockTextWeight } from '@devvit/protos';
4
+ import { Block, BlockAlignment, BlockAvatarFacing, BlockAvatarSize, BlockBorder, BlockButtonAppearance, BlockButtonSize, BlockFullSnooSize, BlockGap, BlockIconSize, BlockImageResizeMode, BlockPadding, BlockRadius, BlockSize, BlockSpacerSize, BlockStackDirection, BlockTextOutline, BlockTextSize, BlockTextWeight, BlockType } from '@devvit/protos';
5
5
  import { RenderContext } from './templates/index.js';
6
+ export declare function defaultClasses(type: BlockType): ClassInfo;
6
7
  export declare function stackDirectionClass(direction: BlockStackDirection, reverse: boolean | undefined): ClassInfo;
8
+ export declare function stackChildClass(parentDirection: BlockStackDirection): ClassInfo;
7
9
  export declare function sizingClass(sizing: BlockSize | undefined): ClassInfo;
8
10
  export declare function sizingStyle(sizing: BlockSize | undefined): StyleInfo;
9
11
  export declare function paddingClass(padding: BlockPadding | undefined): ClassInfo;
@@ -1 +1 @@
1
- {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/blocks/attributes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAExF,OAAO,EACL,KAAK,EAEL,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,WAAW,EAEX,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,QAAQ,EAER,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,WAAW,EACX,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,eAAe,EAEhB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAQrD,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,mBAAmB,EAC9B,OAAO,EAAE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AAE,MAAM,GAAG,SAAS,GAC7B,SAAS,CAQX;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAI/D;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,eAAe,GAAG,SAAS,EACjC,cAAc,EAAE,mBAAmB,GAClC,SAAS,CAiBX;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,oBAAoB,GAAG,SAAS,GAAG,SAAS,CASvF;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,GAAG,SAAS,CAOxE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,eAAe,GAAG,SAAS,GAAG,SAAS,CAY5E;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,SAAS,GAAG,SAAS,CAK5E;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,GAAG,SAAS,CAgBhF;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,qBAAqB,GAAG,SAAS,GAAG,gBAAgB,CA2BhG;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,SAAS,GAAG,UAAU,CAexE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CASxF"}
@@ -1,10 +1,16 @@
1
1
  import { ButtonSize } from '@reddit/faceplate-ui/templates/button.js';
2
- import { BlockActionType, BlockAvatarFacing, BlockAvatarSize, BlockBorderWidth, BlockButtonAppearance, BlockButtonSize, BlockFullSnooSize, BlockGap, BlockHorizontalAlignment, BlockIconSize, BlockImageResizeMode, BlockPadding, BlockRadius, BlockSpacerSize, BlockStackDirection, BlockTextOutline, BlockTextSize, BlockTextWeight, BlockVerticalAlignment, } from '@devvit/protos';
2
+ import { BlockActionType, BlockAvatarFacing, BlockAvatarSize, BlockBorderWidth, BlockButtonAppearance, BlockButtonSize, BlockFullSnooSize, BlockGap, BlockHorizontalAlignment, BlockIconSize, BlockImageResizeMode, BlockPadding, BlockRadius, BlockSpacerSize, BlockStackDirection, BlockTextOutline, BlockTextSize, BlockTextWeight, BlockType, BlockVerticalAlignment, } from '@devvit/protos';
3
3
  function findColor(color) {
4
4
  // TODO: check CSS for color var and wrap in var(--color-${background}-background)
5
5
  // - will need access to shadow root
6
6
  return color;
7
7
  }
8
+ export function defaultClasses(type) {
9
+ return {
10
+ 'overflow-hidden': type === BlockType.BLOCK_ROOT || type === BlockType.BLOCK_STACK,
11
+ 'm-0': type === BlockType.BLOCK_IMAGE,
12
+ };
13
+ }
8
14
  export function stackDirectionClass(direction, reverse) {
9
15
  const vstack = direction === BlockStackDirection.STACK_VERTICAL;
10
16
  const hstack = direction === BlockStackDirection.STACK_HORIZONTAL;
@@ -15,12 +21,21 @@ export function stackDirectionClass(direction, reverse) {
15
21
  'flex-row-reverse': hstack && reverse === true,
16
22
  'flex-col': vstack,
17
23
  'flex-col-reverse': vstack && reverse === true,
18
- 'devvit-depth': zstack,
24
+ grid: zstack,
25
+ 'grid-cols-1': zstack,
26
+ };
27
+ }
28
+ export function stackChildClass(parentDirection) {
29
+ const zstack = parentDirection === BlockStackDirection.STACK_DEPTH;
30
+ return {
31
+ 'col-start-1': zstack,
32
+ 'row-start-1': zstack,
19
33
  };
20
34
  }
21
35
  export function sizingClass(sizing) {
22
36
  return {
23
- grow: sizing?.grow === true,
37
+ 'col-start-1': sizing?.grow === true,
38
+ 'row-start-1': sizing?.grow === true,
24
39
  };
25
40
  }
26
41
  export function sizingStyle(sizing) {
@@ -68,14 +83,10 @@ export function alignmentClass(direction, align) {
68
83
  'justify-items-center': center && zstack,
69
84
  'justify-items-end': end && zstack,
70
85
  // Cross-axis alignment
71
- 'items-start': (top && hstack) || (start && vstack),
72
- 'items-center': (middle && hstack) || (center && vstack),
73
- 'items-stretch': (vnone && hstack) || (hnone && vstack),
74
- 'items-end': (bottom && hstack) || (end && vstack),
75
- // Alternate for ZStack
76
- 'content-start': top && zstack,
77
- 'content-center': middle && zstack,
78
- 'content-end': bottom && zstack,
86
+ 'items-start': (top && (hstack || zstack)) || (start && vstack),
87
+ 'items-center': (middle && (hstack || zstack)) || (center && vstack),
88
+ 'items-stretch': (vnone && (hstack || zstack)) || (hnone && vstack),
89
+ 'items-end': (bottom && (hstack || zstack)) || (end && vstack),
79
90
  };
80
91
  }
81
92
  export function backgroundStyle(background) {
@@ -84,15 +95,16 @@ export function backgroundStyle(background) {
84
95
  };
85
96
  }
86
97
  export function borderClass(border) {
87
- const hasBorder = border !== undefined && border.width !== BlockBorderWidth.BORDER_WIDTH_NONE;
98
+ const thin = border?.width === BlockBorderWidth.BORDER_WIDTH_THIN;
99
+ const thick = border?.width === BlockBorderWidth.BORDER_WIDTH_THICK;
100
+ const none = !thin && !thick;
101
+ const hasBorder = border !== undefined && !none;
88
102
  return {
89
103
  'border-0': !hasBorder,
90
104
  'border-solid': hasBorder,
91
- 'border-dx-thin': border?.width === BlockBorderWidth.BORDER_WIDTH_THIN,
92
- 'border-dx-thick': border?.width === BlockBorderWidth.BORDER_WIDTH_THICK,
93
- 'border-neutral-border': border !== undefined &&
94
- border.width !== BlockBorderWidth.BORDER_WIDTH_NONE &&
95
- border.color === undefined,
105
+ 'border-dx-thin': thin,
106
+ 'border-dx-thick': thick,
107
+ 'border-neutral-border': hasBorder && border.color === undefined,
96
108
  };
97
109
  }
98
110
  export function borderStyle(border) {
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=devvit-blocks-webview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devvit-blocks-webview.d.ts","sourceRoot":"","sources":["../../../src/blocks/components/devvit-blocks-webview.ts"],"names":[],"mappings":""}
@@ -0,0 +1,81 @@
1
+ var _DevvitBlocksWebview_iframe, _DevvitBlocksWebview_handleMessage, _DevvitBlocksWebview_onLoad;
2
+ import { __classPrivateFieldGet, __decorate, __metadata } from "tslib";
3
+ import { css, html, LitElement } from 'lit';
4
+ import { customElement, property } from 'lit/decorators.js';
5
+ import { createRef, ref } from 'lit/directives/ref.js';
6
+ import { ifDefined } from '@reddit/baseplate/html.js';
7
+ import { customEvent } from '@reddit/faceplate/lib/custom-event.js';
8
+ import { BlockActionType } from '@devvit/protos';
9
+ /**
10
+ * Wraps an iframe to capture messages sent from within to be handled by the app rendering the Blocks
11
+ */
12
+ let DevvitBlocksWebview = class DevvitBlocksWebview extends LitElement {
13
+ constructor() {
14
+ super(...arguments);
15
+ _DevvitBlocksWebview_iframe.set(this, createRef());
16
+ _DevvitBlocksWebview_handleMessage.set(this, (event) => {
17
+ if (event.source === __classPrivateFieldGet(this, _DevvitBlocksWebview_iframe, "f").value?.contentWindow) {
18
+ event.stopImmediatePropagation();
19
+ const action = {
20
+ type: BlockActionType.ACTION_WEBVIEW,
21
+ id: event.data.id,
22
+ data: event.data.data,
23
+ };
24
+ this.dispatchEvent(customEvent('devvit-user-action', { action }));
25
+ }
26
+ });
27
+ _DevvitBlocksWebview_onLoad.set(this, () => {
28
+ __classPrivateFieldGet(this, _DevvitBlocksWebview_iframe, "f")?.value?.contentWindow?.postMessage({
29
+ event: this.request,
30
+ state: this.state,
31
+ }, '*');
32
+ });
33
+ }
34
+ static get styles() {
35
+ return [
36
+ css `
37
+ :host {
38
+ display: flex;
39
+ flex-direction: row;
40
+ }
41
+
42
+ iframe {
43
+ flex-grow: 1;
44
+ border: 0;
45
+ }
46
+ `,
47
+ ];
48
+ }
49
+ connectedCallback() {
50
+ super.connectedCallback();
51
+ window.addEventListener('message', __classPrivateFieldGet(this, _DevvitBlocksWebview_handleMessage, "f"));
52
+ }
53
+ disconnectedCallback() {
54
+ super.disconnectedCallback();
55
+ window.removeEventListener('message', __classPrivateFieldGet(this, _DevvitBlocksWebview_handleMessage, "f"));
56
+ }
57
+ render() {
58
+ return html `<iframe
59
+ src="${ifDefined(this.src)}"
60
+ sandbox="allow-scripts"
61
+ @load="${__classPrivateFieldGet(this, _DevvitBlocksWebview_onLoad, "f")}"
62
+ ${ref(__classPrivateFieldGet(this, _DevvitBlocksWebview_iframe, "f"))}
63
+ ></iframe>`;
64
+ }
65
+ };
66
+ _DevvitBlocksWebview_iframe = new WeakMap(), _DevvitBlocksWebview_handleMessage = new WeakMap(), _DevvitBlocksWebview_onLoad = new WeakMap();
67
+ __decorate([
68
+ property({ type: String }),
69
+ __metadata("design:type", Object)
70
+ ], DevvitBlocksWebview.prototype, "src", void 0);
71
+ __decorate([
72
+ property({ attribute: false }),
73
+ __metadata("design:type", Object)
74
+ ], DevvitBlocksWebview.prototype, "request", void 0);
75
+ __decorate([
76
+ property({ attribute: false }),
77
+ __metadata("design:type", Object)
78
+ ], DevvitBlocksWebview.prototype, "state", void 0);
79
+ DevvitBlocksWebview = __decorate([
80
+ customElement('devvit-blocks-webview')
81
+ ], DevvitBlocksWebview);
@@ -1,13 +1,12 @@
1
- import { classMap as clientClassMap } from 'lit/directives/class-map.js';
1
+ import { ClassInfo, classMap as clientClassMap } from 'lit/directives/class-map.js';
2
2
  import { TemplateLike, UnsafeString } from '@reddit/baseplate/html.js';
3
- import { Block, BlockAction, BlockRenderResponse, BlockStackDirection } from '@devvit/protos';
4
- import { ClassInfo } from 'lit/directives/class-map.js';
3
+ import { Block, BlockAction, BlockRenderRequest, BlockStackDirection } from '@devvit/protos';
5
4
  export interface RenderContext {
6
- blockRender?: BlockRenderResponse | undefined;
5
+ request?: BlockRenderRequest | undefined;
7
6
  state?: unknown | undefined;
8
7
  stackDirection: BlockStackDirection;
9
8
  onAction?: ((action: BlockAction) => void) | undefined;
10
9
  }
11
10
  export declare function renderBlocks(block: Block, context?: Partial<RenderContext>): TemplateLike;
12
- export declare function classMap(classInfo: ClassInfo): UnsafeString | ReturnType<typeof clientClassMap>;
11
+ export declare function classMap(classInfo: ClassInfo, forceString?: boolean): UnsafeString | ReturnType<typeof clientClassMap>;
13
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EAAW,YAAY,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEhF,OAAO,EACL,KAAK,EACL,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EAEpB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAGxD,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;IAC9C,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,cAAc,EAAE,mBAAmB,CAAC;IACpC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACxD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,GAAG,YAAY,CAsB7F;AAED,wBAAgB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,YAAY,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAe/F"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAEpF,OAAO,EAAW,YAAY,EAAU,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAExF,OAAO,EACL,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACzC,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,cAAc,EAAE,mBAAmB,CAAC;IACpC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACxD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,GAAG,YAAY,CAsB7F;AAED,wBAAgB,QAAQ,CACtB,SAAS,EAAE,SAAS,EACpB,WAAW,CAAC,EAAE,OAAO,GACpB,YAAY,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAgBlD"}
@@ -1,5 +1,5 @@
1
1
  import { classMap as clientClassMap } from 'lit/directives/class-map.js';
2
- import { nothing } from '@reddit/baseplate/html.js';
2
+ import { nothing, unsafe } from '@reddit/baseplate/html.js';
3
3
  import { BlockStackDirection, BlockType, } from '@devvit/protos';
4
4
  import { renderBlock } from './renderBlock.js';
5
5
  import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
@@ -22,9 +22,9 @@ export function renderBlocks(block, context = {}) {
22
22
  stackDirection: BlockStackDirection.UNRECOGNIZED,
23
23
  });
24
24
  }
25
- export function classMap(classInfo) {
25
+ export function classMap(classInfo, forceString) {
26
26
  const { getType } = getTemplateRenderingStrategy();
27
- if (getType() === 'client') {
27
+ if (getType() === 'client' && forceString !== true) {
28
28
  return clientClassMap(classInfo);
29
29
  }
30
30
  let result = '';
@@ -33,5 +33,6 @@ export function classMap(classInfo) {
33
33
  result += `${name} `;
34
34
  }
35
35
  }
36
- return result;
36
+ // eslint-disable-next-line @reddit/no-unsafe/no-unsafe-function-usage
37
+ return unsafe(result);
37
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderAnimationBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderAnimationBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAIlE,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA0BnF"}
1
+ {"version":3,"file":"renderAnimationBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderAnimationBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAUlE,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA6BnF"}
@@ -1,6 +1,6 @@
1
1
  import { nothing } from '@reddit/baseplate/html.js';
2
2
  import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
3
- import { onClickAction, sizingClass, sizingStyle } from '../attributes.js';
3
+ import { defaultClasses, onClickAction, sizingClass, sizingStyle, stackChildClass, } from '../attributes.js';
4
4
  import { classMap } from './index.js';
5
5
  export function renderAnimationBlock(block, ctx) {
6
6
  const { html, styleMap, ifDefined } = getTemplateRenderingStrategy();
@@ -10,6 +10,8 @@ export function renderAnimationBlock(block, ctx) {
10
10
  }
11
11
  const { url, type } = block.config.animationConfig;
12
12
  const classes = {
13
+ ...defaultClasses(block.type),
14
+ ...stackChildClass(ctx.stackDirection),
13
15
  ...sizingClass(block.size),
14
16
  };
15
17
  const styles = {
@@ -22,5 +24,6 @@ export function renderAnimationBlock(block, ctx) {
22
24
  src="${url}"
23
25
  type="${type}"
24
26
  @click="${ifDefined(onClick)}"
27
+ data-debug-block-type="animation"
25
28
  ></devvit-animation-player>`;
26
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderAvatarBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderAvatarBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAUlE,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA0BhF"}
1
+ {"version":3,"file":"renderAvatarBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderAvatarBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAYlE,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA6BhF"}
@@ -1,6 +1,6 @@
1
1
  import { nothing } from '@reddit/baseplate/html.js';
2
2
  import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
3
- import { avatarSizeClass, facingClass, onClickAction, sizingClass, sizingStyle, } from '../attributes.js';
3
+ import { avatarSizeClass, defaultClasses, facingClass, onClickAction, sizingClass, sizingStyle, stackChildClass, } from '../attributes.js';
4
4
  import { classMap } from './index.js';
5
5
  export function renderAvatarBlock(block, ctx) {
6
6
  const { html, styleMap, ifDefined } = getTemplateRenderingStrategy();
@@ -10,6 +10,8 @@ export function renderAvatarBlock(block, ctx) {
10
10
  }
11
11
  const { thingId, facing, size, background } = block.config.avatarConfig;
12
12
  const classes = {
13
+ ...defaultClasses(block.type),
14
+ ...stackChildClass(ctx.stackDirection),
13
15
  ...sizingClass(block.size),
14
16
  ...avatarSizeClass(size),
15
17
  ...facingClass(facing),
@@ -22,5 +24,6 @@ export function renderAvatarBlock(block, ctx) {
22
24
  class="${classMap(classes)}"
23
25
  style="${styleMap(styles)}"
24
26
  @click="${ifDefined(onClick)}"
27
+ data-debug-block-type="avatar"
25
28
  ></div>`;
26
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EAAE,KAAK,EAAa,MAAM,gBAAgB,CAAC;AAYlD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA0B1E"}
1
+ {"version":3,"file":"renderBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EAAE,KAAK,EAAa,MAAM,gBAAgB,CAAC;AAYlD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA+C1E"}
@@ -10,30 +10,51 @@ import { renderWebViewBlock } from './renderWebViewBlock.js';
10
10
  import { renderAnimationBlock } from './renderAnimationBlock.js';
11
11
  import { renderAvatarBlock } from './renderAvatarBlock.js';
12
12
  import { renderFullSnooBlock } from './renderFullSnooBlock.js';
13
+ import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
13
14
  export function renderBlock(block, ctx) {
15
+ const { html } = getTemplateRenderingStrategy();
16
+ let render;
14
17
  switch (block.type) {
15
18
  case BlockType.BLOCK_STACK:
16
- return renderStackBlock(block, ctx);
19
+ render = renderStackBlock(block, ctx);
20
+ break;
17
21
  case BlockType.BLOCK_SPACER:
18
- return renderSpacerBlock(block, ctx);
22
+ render = renderSpacerBlock(block, ctx);
23
+ break;
19
24
  case BlockType.BLOCK_TEXT:
20
- return renderTextBlock(block, ctx);
25
+ render = renderTextBlock(block, ctx);
26
+ break;
21
27
  case BlockType.BLOCK_IMAGE:
22
- return renderImageBlock(block, ctx);
28
+ render = renderImageBlock(block, ctx);
29
+ break;
23
30
  case BlockType.BLOCK_ICON:
24
- return renderIconBlock(block, ctx);
31
+ render = renderIconBlock(block, ctx);
32
+ break;
25
33
  case BlockType.BLOCK_BUTTON:
26
- return renderButtonBlock(block, ctx);
34
+ render = renderButtonBlock(block, ctx);
35
+ break;
27
36
  case BlockType.BLOCK_WEBVIEW:
28
- return renderWebViewBlock(block, ctx);
37
+ render = renderWebViewBlock(block, ctx);
38
+ break;
29
39
  case BlockType.BLOCK_ANIMATION:
30
- return renderAnimationBlock(block, ctx);
40
+ render = renderAnimationBlock(block, ctx);
41
+ break;
31
42
  case BlockType.BLOCK_AVATAR:
32
- return renderAvatarBlock(block, ctx);
43
+ render = renderAvatarBlock(block, ctx);
44
+ break;
33
45
  case BlockType.BLOCK_FULLSNOO:
34
- return renderFullSnooBlock(block, ctx);
46
+ render = renderFullSnooBlock(block, ctx);
47
+ break;
35
48
  case BlockType.UNRECOGNIZED:
36
49
  default:
37
50
  return nothing;
38
51
  }
52
+ if (block.size?.grow == true) {
53
+ return html `<div class="basis-full grid grid-cols-1 items-stretch justify-stretch">
54
+ ${render}
55
+ </div>`;
56
+ }
57
+ else {
58
+ return render;
59
+ }
39
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderButtonBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderButtonBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAKzD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AASvC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAyBhF"}
1
+ {"version":3,"file":"renderButtonBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderButtonBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,MAAM,2BAA2B,CAAC;AAKvE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAYvC,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAkChF"}
@@ -1,14 +1,21 @@
1
1
  import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
2
2
  import { button } from '@reddit/faceplate-ui/templates/button.js';
3
3
  import { styleMap } from '@reddit/faceplate-ui/templateUtils/styleMap.js';
4
- import { backgroundStyle, buttonAppearance, buttonSize, colorStyle, onClickAction, } from '../attributes.js';
4
+ import { buttonAppearance, buttonSize, colorStyle, defaultClasses, onClickAction, sizingClass, stackChildClass, } from '../attributes.js';
5
+ import { classMap } from './index.js';
5
6
  export function renderButtonBlock(block, ctx) {
6
7
  const { html, ifDefined } = getTemplateRenderingStrategy();
7
8
  // let buttonIcon = block.config?.buttonConfig?.icon;
8
9
  const disabled = block.config?.buttonConfig?.disabled === true;
10
+ const classes = {
11
+ ...defaultClasses(block.type),
12
+ ...stackChildClass(ctx.stackDirection),
13
+ ...sizingClass(block.size),
14
+ };
9
15
  const styles = {
10
16
  ...colorStyle(block.config?.buttonConfig?.textColor),
11
- ...backgroundStyle(block.config?.buttonConfig?.backgroundColor),
17
+ // not available in all platforms yet
18
+ // ...backgroundStyle(block.config?.buttonConfig?.backgroundColor),
12
19
  };
13
20
  const onClick = onClickAction(block, ctx);
14
21
  return html `${button({
@@ -20,7 +27,9 @@ export function renderButtonBlock(block, ctx) {
20
27
  disabled,
21
28
  // convert from StyleInfo to CSSStyleDeclaration
22
29
  style: styleMap(styles).string,
30
+ className: classMap(classes, true).string,
23
31
  onclick: onClick ?? null,
32
+ 'data-debug-block-type': 'button',
24
33
  },
25
34
  })}`;
26
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderFullSnooBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderFullSnooBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AASvC,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA0BlF"}
1
+ {"version":3,"file":"renderFullSnooBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderFullSnooBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAWvC,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA6BlF"}
@@ -1,6 +1,6 @@
1
1
  import { nothing } from '@reddit/baseplate/html.js';
2
2
  import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
3
- import { facingClass, fullSnooSizeClass, onClickAction, sizingClass, sizingStyle, } from '../attributes.js';
3
+ import { defaultClasses, facingClass, fullSnooSizeClass, onClickAction, sizingClass, sizingStyle, stackChildClass, } from '../attributes.js';
4
4
  import { classMap } from './index.js';
5
5
  export function renderFullSnooBlock(block, ctx) {
6
6
  const { html, styleMap, ifDefined } = getTemplateRenderingStrategy();
@@ -10,6 +10,8 @@ export function renderFullSnooBlock(block, ctx) {
10
10
  }
11
11
  const { userId, size, facing } = block.config.fullsnooConfig;
12
12
  const classes = {
13
+ ...defaultClasses(block.type),
14
+ ...stackChildClass(ctx.stackDirection),
13
15
  ...sizingClass(block.size),
14
16
  ...fullSnooSizeClass(size),
15
17
  ...facingClass(facing),
@@ -22,5 +24,6 @@ export function renderFullSnooBlock(block, ctx) {
22
24
  class="${classMap(classes)}"
23
25
  style="${styleMap(styles)}"
24
26
  @click="${ifDefined(onClick)}"
27
+ data-debug-block-type="fullsnoo"
25
28
  ></div>`;
26
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderIconBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderIconBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAmB9E"}
1
+ {"version":3,"file":"renderIconBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderIconBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AASvC,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAsB9E"}
@@ -1,6 +1,7 @@
1
1
  import { nothing } from '@reddit/baseplate/html.js';
2
2
  import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
3
- import { iconSizeClass, onClickAction } from '../attributes.js';
3
+ import { defaultClasses, iconSizeClass, onClickAction, sizingClass, stackChildClass, } from '../attributes.js';
4
+ import { classMap } from './index.js';
4
5
  export function renderIconBlock(block, ctx) {
5
6
  const { html } = getTemplateRenderingStrategy();
6
7
  if (!block.config?.iconConfig) {
@@ -10,8 +11,11 @@ export function renderIconBlock(block, ctx) {
10
11
  const { icon, size, color } = block.config.iconConfig;
11
12
  // adopt `icons-all.ts` from faceplate-ui storybook
12
13
  const classes = {
14
+ ...defaultClasses(block.type),
15
+ ...stackChildClass(ctx.stackDirection),
16
+ ...sizingClass(block.size),
13
17
  ...iconSizeClass(size),
14
18
  };
15
19
  const onClick = onClickAction(block, ctx);
16
- return html `<div></div>`;
20
+ return html `<div class="${classMap(classes)}" data-debug-block-type="icon"></div>`;
17
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderImageBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderImageBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA+B/E"}
1
+ {"version":3,"file":"renderImageBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderImageBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAUvC,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAkC/E"}
@@ -1,6 +1,6 @@
1
1
  import { nothing } from '@reddit/baseplate/html.js';
2
2
  import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
3
- import { onClickAction, resizeModeClass, sizingClass, sizingStyle } from '../attributes.js';
3
+ import { defaultClasses, onClickAction, resizeModeClass, sizingClass, sizingStyle, stackChildClass, } from '../attributes.js';
4
4
  import { classMap } from './index.js';
5
5
  export function renderImageBlock(block, ctx) {
6
6
  const { html, styleMap, ifDefined } = getTemplateRenderingStrategy();
@@ -10,6 +10,8 @@ export function renderImageBlock(block, ctx) {
10
10
  }
11
11
  const { width, height, url, description, resizeMode } = block.config.imageConfig;
12
12
  const classes = {
13
+ ...defaultClasses(block.type),
14
+ ...stackChildClass(ctx.stackDirection),
13
15
  ...sizingClass(block.size),
14
16
  ...resizeModeClass(resizeMode),
15
17
  };
@@ -26,6 +28,7 @@ export function renderImageBlock(block, ctx) {
26
28
  class="${classMap(classes)}"
27
29
  style="${styleMap(styles)}"
28
30
  @click="${ifDefined(onClick)}"
31
+ data-debug-block-type="image"
29
32
  />
30
33
  `;
31
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderSpacerBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderSpacerBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAahF"}
1
+ {"version":3,"file":"renderSpacerBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderSpacerBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AASvC,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAmBhF"}
@@ -1,14 +1,20 @@
1
1
  import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
2
- import { sizingClass, sizingStyle, spacerSizeClass } from '../attributes.js';
2
+ import { defaultClasses, sizingClass, sizingStyle, spacerSizeClass, stackChildClass, } from '../attributes.js';
3
3
  import { classMap } from './index.js';
4
4
  export function renderSpacerBlock(block, ctx) {
5
5
  const { html, styleMap } = getTemplateRenderingStrategy();
6
6
  const classes = {
7
+ ...defaultClasses(block.type),
8
+ ...stackChildClass(ctx.stackDirection),
7
9
  ...sizingClass(block.size),
8
10
  ...spacerSizeClass(block.config?.spacerConfig?.size, ctx.stackDirection),
9
11
  };
10
12
  const styles = {
11
13
  ...sizingStyle(block.size),
12
14
  };
13
- return html `<div class="${classMap(classes)}" style="${styleMap(styles)}"></div>`;
15
+ return html `<div
16
+ class="${classMap(classes)}"
17
+ style="${styleMap(styles)}"
18
+ data-debug-block-type="spacer"
19
+ ></div>`;
14
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderStackBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderStackBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAuB,MAAM,gBAAgB,CAAC;AAgB5D,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,EACZ,GAAG,GAAE,aAAoE,GACxE,YAAY,CAgDd"}
1
+ {"version":3,"file":"renderStackBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderStackBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAuB,MAAM,gBAAgB,CAAC;AAkB5D,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,EACZ,GAAG,GAAE,aAAoE,GACxE,YAAY,CAoEd"}
@@ -1,7 +1,7 @@
1
1
  import { nothing } from '@reddit/baseplate/html.js';
2
2
  import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
3
3
  import { BlockStackDirection } from '@devvit/protos';
4
- import { alignmentClass, backgroundStyle, borderClass, borderStyle, gapClass, onClickAction, paddingClass, radiusClass, sizingClass, sizingStyle, stackDirectionClass, } from '../attributes.js';
4
+ import { alignmentClass, backgroundStyle, borderClass, borderStyle, defaultClasses, gapClass, onClickAction, paddingClass, radiusClass, sizingClass, sizingStyle, stackChildClass, stackDirectionClass, } from '../attributes.js';
5
5
  import { renderBlock } from './renderBlock.js';
6
6
  import { classMap } from './index.js';
7
7
  export function renderStackBlock(block, ctx = { stackDirection: BlockStackDirection.UNRECOGNIZED }) {
@@ -12,7 +12,9 @@ export function renderStackBlock(block, ctx = { stackDirection: BlockStackDirect
12
12
  }
13
13
  const { children, direction, padding, gap, alignment, reverse, backgroundColor, border, cornerRadius, } = block.config.stackConfig;
14
14
  const classes = {
15
+ ...defaultClasses(block.type),
15
16
  ...stackDirectionClass(direction, reverse),
17
+ ...stackChildClass(ctx.stackDirection),
16
18
  ...sizingClass(block.size),
17
19
  ...paddingClass(padding),
18
20
  ...gapClass(gap),
@@ -30,8 +32,25 @@ export function renderStackBlock(block, ctx = { stackDirection: BlockStackDirect
30
32
  stackDirection: direction,
31
33
  };
32
34
  const onClick = onClickAction(block, ctx);
35
+ let blockType = '';
36
+ switch (direction) {
37
+ case BlockStackDirection.STACK_DEPTH:
38
+ blockType = 'zstack';
39
+ break;
40
+ case BlockStackDirection.STACK_VERTICAL:
41
+ blockType = 'vstack';
42
+ break;
43
+ case BlockStackDirection.STACK_HORIZONTAL:
44
+ blockType = 'hstack';
45
+ break;
46
+ }
33
47
  return html `
34
- <div class="${classMap(classes)}" style="${styleMap(styles)}" @click="${ifDefined(onClick)}">
48
+ <div
49
+ class="${classMap(classes)}"
50
+ style="${styleMap(styles)}"
51
+ @click="${ifDefined(onClick)}"
52
+ data-debug-block-type="${blockType}"
53
+ >
35
54
  ${repeat(children, (block) => renderBlock(block, newCtx))}
36
55
  </div>
37
56
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"renderTextBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderTextBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAkD,MAAM,gBAAgB,CAAC;AAWvF,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA4D9E"}
1
+ {"version":3,"file":"renderTextBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderTextBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAkD,MAAM,gBAAgB,CAAC;AAavF,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA+D9E"}
@@ -1,7 +1,7 @@
1
1
  import { nothing } from '@reddit/baseplate/html.js';
2
2
  import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
3
3
  import { BlockTextSize, BlockTextStyle, BlockTextWeight } from '@devvit/protos';
4
- import { colorStyle, onClickAction, sizingClass, textAlignClass, textOutlineClass, textSizeClass, textWeightClass, } from '../attributes.js';
4
+ import { colorStyle, defaultClasses, onClickAction, sizingClass, stackChildClass, textAlignClass, textOutlineClass, textSizeClass, textWeightClass, } from '../attributes.js';
5
5
  import { classMap } from './index.js';
6
6
  export function renderTextBlock(block, ctx) {
7
7
  const { html, styleMap, ifDefined } = getTemplateRenderingStrategy();
@@ -40,7 +40,9 @@ export function renderTextBlock(block, ctx) {
40
40
  ...colorStyle(textColor),
41
41
  };
42
42
  const classes = {
43
+ ...defaultClasses(block.type),
43
44
  ...baseStyle,
45
+ ...stackChildClass(ctx.stackDirection),
44
46
  ...sizingClass(block.size),
45
47
  ...textSizeClass(size),
46
48
  ...textAlignClass(alignment),
@@ -54,6 +56,7 @@ export function renderTextBlock(block, ctx) {
54
56
  class="${classMap(classes)}"
55
57
  style="${styleMap(styles)}"
56
58
  @click="${ifDefined(onClick)}"
59
+ data-debug-block-type="text"
57
60
  >${text}</span
58
61
  >`;
59
62
  }