@devvit/ui-renderer 0.10.7-next-2023-10-09-102a57871.0 → 0.10.7-next-2023-10-09-14cdd70d8.0
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/blocks/attributes.d.ts +5 -4
- package/blocks/attributes.d.ts.map +1 -1
- package/blocks/attributes.js +19 -8
- package/blocks/templates/renderAnimationBlock.d.ts.map +1 -1
- package/blocks/templates/renderAnimationBlock.js +3 -6
- package/blocks/templates/renderAvatarBlock.d.ts.map +1 -1
- package/blocks/templates/renderAvatarBlock.js +3 -6
- package/blocks/templates/renderButtonBlock.d.ts.map +1 -1
- package/blocks/templates/renderButtonBlock.js +3 -6
- package/blocks/templates/renderFullSnooBlock.d.ts.map +1 -1
- package/blocks/templates/renderFullSnooBlock.js +3 -6
- package/blocks/templates/renderIconBlock.d.ts.map +1 -1
- package/blocks/templates/renderIconBlock.js +6 -9
- package/blocks/templates/renderImageBlock.d.ts.map +1 -1
- package/blocks/templates/renderImageBlock.js +3 -6
- package/blocks/templates/renderSpacerBlock.d.ts.map +1 -1
- package/blocks/templates/renderSpacerBlock.js +3 -5
- package/blocks/templates/renderStackBlock.d.ts.map +1 -1
- package/blocks/templates/renderStackBlock.js +3 -6
- package/blocks/templates/renderTextBlock.d.ts.map +1 -1
- package/blocks/templates/renderTextBlock.js +6 -9
- package/blocks/templates/renderWebViewBlock.d.ts.map +1 -1
- package/blocks/templates/renderWebViewBlock.js +3 -5
- package/blocks/templates/util.d.ts +8 -1
- package/blocks/templates/util.d.ts.map +1 -1
- package/blocks/templates/util.js +36 -1
- package/package.json +6 -6
package/blocks/attributes.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
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, BlockColor, BlockFullSnooSize, BlockGap, BlockIconSize, BlockImageResizeMode, BlockPadding, BlockRadius,
|
|
4
|
+
import { Block, BlockAlignment, BlockAvatarFacing, BlockAvatarSize, BlockBorder, BlockButtonAppearance, BlockButtonSize, BlockColor, BlockFullSnooSize, BlockGap, BlockIconSize, BlockImageResizeMode, BlockPadding, BlockRadius, BlockSizes, BlockSpacerShape, BlockSpacerSize, BlockStackDirection, BlockTextOutline, BlockTextSize, BlockTextWeight } from '@devvit/protos';
|
|
5
5
|
import { RenderContext } from './templates/renderContext.js';
|
|
6
6
|
import { ref as clientRef } from 'lit/directives/ref.js';
|
|
7
7
|
export interface AttributeOverrides {
|
|
8
8
|
styles?: StyleInfo | undefined;
|
|
9
9
|
classes?: ClassInfo | undefined;
|
|
10
10
|
}
|
|
11
|
-
export declare function defaultClasses(
|
|
11
|
+
export declare function defaultClasses(block: Block, ctx: RenderContext): ClassInfo;
|
|
12
|
+
export declare function defaultStyles(block: Block): StyleInfo;
|
|
12
13
|
export declare function stackDirectionClass(direction: BlockStackDirection, reverse: boolean | undefined): ClassInfo;
|
|
13
14
|
export declare function stackChildClass(parentDirection: BlockStackDirection): ClassInfo;
|
|
14
|
-
export declare function sizingClass(sizing:
|
|
15
|
-
export declare function sizingStyle(sizing:
|
|
15
|
+
export declare function sizingClass(sizing: BlockSizes | undefined): ClassInfo;
|
|
16
|
+
export declare function sizingStyle(sizing: BlockSizes | undefined): StyleInfo;
|
|
16
17
|
export declare function paddingClass(padding: BlockPadding | undefined): ClassInfo;
|
|
17
18
|
export declare function gapClass(spacing: BlockGap | undefined): ClassInfo;
|
|
18
19
|
export declare function alignmentClass(direction: BlockStackDirection, align: BlockAlignment | undefined): ClassInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../library/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,UAAU,EACV,iBAAiB,EACjB,QAAQ,EAER,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,WAAW,
|
|
1
|
+
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../library/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,UAAU,EACV,iBAAiB,EACjB,QAAQ,EAER,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,WAAW,EAEX,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,eAAe,EAGhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,GAAG,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAazD,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACjC;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,SAAS,CAU1E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,CAC5B,SAAS,EAAE,gBAAgB,GAAG,SAAS,GACtC,UAAU,CAAC,OAAO,SAAS,CAAC,CAmC9B"}
|
package/blocks/attributes.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { ButtonSize } from '@reddit/faceplate-ui/templates/button.js';
|
|
2
2
|
import { BlockActionType, BlockAvatarFacing, BlockAvatarSize, BlockBorderWidth, BlockButtonAppearance, BlockButtonSize, BlockFullSnooSize, BlockGap, BlockHorizontalAlignment, BlockIconSize, BlockImageResizeMode, BlockPadding, BlockRadius, BlockSpacerShape, BlockSpacerSize, BlockStackDirection, BlockTextOutline, BlockTextSize, BlockTextWeight, BlockType, BlockVerticalAlignment, } from '@devvit/protos';
|
|
3
|
-
import {
|
|
3
|
+
import { getSizes, isHTMLElement, parseDimension, ref, resolveColors, sanitizeStyleInfo, } from './templates/util.js';
|
|
4
4
|
import { nothing } from 'lit';
|
|
5
5
|
import { brightnessByColor } from './templates/color.js';
|
|
6
|
-
export function defaultClasses(
|
|
6
|
+
export function defaultClasses(block, ctx) {
|
|
7
|
+
const type = block.type;
|
|
7
8
|
return {
|
|
8
9
|
'box-border': true,
|
|
9
10
|
'overflow-hidden': type === BlockType.BLOCK_ROOT || type === BlockType.BLOCK_STACK,
|
|
10
11
|
'm-0': type === BlockType.BLOCK_IMAGE,
|
|
12
|
+
...stackChildClass(ctx.stackDirection),
|
|
13
|
+
...sizingClass(getSizes(block)),
|
|
14
|
+
...cursorClass(block),
|
|
11
15
|
};
|
|
12
16
|
}
|
|
17
|
+
export function defaultStyles(block) {
|
|
18
|
+
return sanitizeStyleInfo({
|
|
19
|
+
...sizingStyle(getSizes(block)),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
13
22
|
export function stackDirectionClass(direction, reverse) {
|
|
14
23
|
const vstack = direction === BlockStackDirection.STACK_VERTICAL;
|
|
15
24
|
const hstack = direction === BlockStackDirection.STACK_HORIZONTAL;
|
|
@@ -36,16 +45,18 @@ export function sizingClass(sizing) {
|
|
|
36
45
|
return {
|
|
37
46
|
'col-start-1': sizing?.grow === true,
|
|
38
47
|
'row-start-1': sizing?.grow === true,
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
shrink: sizing?.grow === true,
|
|
49
|
+
grow: sizing?.grow === true,
|
|
41
50
|
};
|
|
42
51
|
}
|
|
43
52
|
export function sizingStyle(sizing) {
|
|
44
53
|
return sanitizeStyleInfo({
|
|
45
|
-
width: sizing?.width
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
width: parseDimension(sizing?.width?.value),
|
|
55
|
+
minWidth: parseDimension(sizing?.width?.min),
|
|
56
|
+
maxWidth: parseDimension(sizing?.width?.max),
|
|
57
|
+
height: parseDimension(sizing?.height?.value),
|
|
58
|
+
minHeight: parseDimension(sizing?.height?.min),
|
|
59
|
+
maxHeight: parseDimension(sizing?.height?.max),
|
|
49
60
|
});
|
|
50
61
|
}
|
|
51
62
|
export function paddingClass(padding) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderAnimationBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderAnimationBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderAnimationBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderAnimationBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAKvC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAY,YAAY,EAAE,MAAM,WAAW,CAAC;AAEnD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA2BnF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nothing } from 'lit';
|
|
2
2
|
import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
|
|
3
|
-
import {
|
|
3
|
+
import { defaultClasses, defaultStyles, onClickAction } from '../attributes.js';
|
|
4
4
|
import { classMap } from './util.js';
|
|
5
5
|
export function renderAnimationBlock(block, ctx) {
|
|
6
6
|
const { html, styleMap, ifDefined } = getTemplateRenderingStrategy();
|
|
@@ -10,13 +10,10 @@ export function renderAnimationBlock(block, ctx) {
|
|
|
10
10
|
}
|
|
11
11
|
const { url, type } = block.config.animationConfig;
|
|
12
12
|
const classes = {
|
|
13
|
-
...defaultClasses(block
|
|
14
|
-
...stackChildClass(ctx.stackDirection),
|
|
15
|
-
...sizingClass(block.size),
|
|
16
|
-
...cursorClass(block),
|
|
13
|
+
...defaultClasses(block, ctx),
|
|
17
14
|
};
|
|
18
15
|
const styles = {
|
|
19
|
-
...
|
|
16
|
+
...defaultStyles(block),
|
|
20
17
|
};
|
|
21
18
|
const onClick = onClickAction(block, ctx);
|
|
22
19
|
return html `<devvit-animation-player
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderAvatarBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderAvatarBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderAvatarBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderAvatarBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAWvC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAY,YAAY,EAAE,MAAM,WAAW,CAAC;AAEnD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA2BhF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nothing } from 'lit';
|
|
2
2
|
import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
|
|
3
|
-
import { avatarSizeClass,
|
|
3
|
+
import { avatarSizeClass, defaultClasses, defaultStyles, facingClass, onClickAction, } from '../attributes.js';
|
|
4
4
|
import { classMap } from './util.js';
|
|
5
5
|
export function renderAvatarBlock(block, ctx) {
|
|
6
6
|
const { html, styleMap, ifDefined } = getTemplateRenderingStrategy();
|
|
@@ -10,15 +10,12 @@ export function renderAvatarBlock(block, ctx) {
|
|
|
10
10
|
}
|
|
11
11
|
const { thingId, facing, size, background } = block.config.avatarConfig;
|
|
12
12
|
const classes = {
|
|
13
|
-
...defaultClasses(block
|
|
14
|
-
...stackChildClass(ctx.stackDirection),
|
|
15
|
-
...sizingClass(block.size),
|
|
13
|
+
...defaultClasses(block, ctx),
|
|
16
14
|
...avatarSizeClass(size),
|
|
17
15
|
...facingClass(facing),
|
|
18
|
-
...cursorClass(block),
|
|
19
16
|
};
|
|
20
17
|
const styles = {
|
|
21
|
-
...
|
|
18
|
+
...defaultStyles(block),
|
|
22
19
|
};
|
|
23
20
|
const onClick = onClickAction(block, ctx);
|
|
24
21
|
return html `<div
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderButtonBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderButtonBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAA6C,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderButtonBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderButtonBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAA6C,MAAM,gBAAgB,CAAC;AAUlF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAY,YAAY,EAAE,MAAM,WAAW,CAAC;AAInD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAgEhF"}
|
|
@@ -2,7 +2,7 @@ import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUICo
|
|
|
2
2
|
import { button } from '@reddit/faceplate-ui/templates/button.js';
|
|
3
3
|
import { styleMap } from '@reddit/faceplate-ui/templateUtils/styleMap.js';
|
|
4
4
|
import { BlockButtonSize, BlockIconSize, BlockType } from '@devvit/protos';
|
|
5
|
-
import { buttonAppearance, buttonSize,
|
|
5
|
+
import { buttonAppearance, buttonSize, defaultClasses, defaultStyles, onClickAction, textColorStyle, } from '../attributes.js';
|
|
6
6
|
import { classMap } from './util.js';
|
|
7
7
|
import { renderIconBlock } from './renderIconBlock.js';
|
|
8
8
|
import { nothing } from 'lit';
|
|
@@ -14,15 +14,12 @@ export function renderButtonBlock(block, ctx) {
|
|
|
14
14
|
}
|
|
15
15
|
const { icon, disabled, textColor, textColors } = block.config.buttonConfig;
|
|
16
16
|
const classes = {
|
|
17
|
-
...defaultClasses(block
|
|
18
|
-
...stackChildClass(ctx.stackDirection),
|
|
19
|
-
...sizingClass(block.size),
|
|
20
|
-
...cursorClass(block),
|
|
17
|
+
...defaultClasses(block, ctx),
|
|
21
18
|
textColor: Boolean(textColor || textColors),
|
|
22
19
|
};
|
|
23
20
|
const styles = {
|
|
21
|
+
...defaultStyles(block),
|
|
24
22
|
...textColorStyle(textColors, textColor),
|
|
25
|
-
...sizingStyle(block.size),
|
|
26
23
|
// not available in all platforms yet
|
|
27
24
|
// ...backgroundStyle(block.config?.buttonConfig?.backgroundColor),
|
|
28
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderFullSnooBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderFullSnooBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderFullSnooBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderFullSnooBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AASvC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAY,YAAY,EAAE,MAAM,WAAW,CAAC;AAEnD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA2BlF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nothing } from 'lit';
|
|
2
2
|
import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
|
|
3
|
-
import {
|
|
3
|
+
import { defaultClasses, defaultStyles, facingClass, fullSnooSizeClass, onClickAction, } from '../attributes.js';
|
|
4
4
|
import { classMap } from './util.js';
|
|
5
5
|
export function renderFullSnooBlock(block, ctx) {
|
|
6
6
|
const { html, styleMap, ifDefined } = getTemplateRenderingStrategy();
|
|
@@ -10,15 +10,12 @@ export function renderFullSnooBlock(block, ctx) {
|
|
|
10
10
|
}
|
|
11
11
|
const { userId, size, facing } = block.config.fullsnooConfig;
|
|
12
12
|
const classes = {
|
|
13
|
-
...defaultClasses(block
|
|
14
|
-
...stackChildClass(ctx.stackDirection),
|
|
15
|
-
...sizingClass(block.size),
|
|
13
|
+
...defaultClasses(block, ctx),
|
|
16
14
|
...fullSnooSizeClass(size),
|
|
17
15
|
...facingClass(facing),
|
|
18
|
-
...cursorClass(block),
|
|
19
16
|
};
|
|
20
17
|
const styles = {
|
|
21
|
-
...
|
|
18
|
+
...defaultStyles(block),
|
|
22
19
|
};
|
|
23
20
|
const onClick = onClickAction(block, ctx);
|
|
24
21
|
return html `<div
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderIconBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderIconBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderIconBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderIconBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAUvC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAyB,YAAY,EAAE,MAAM,WAAW,CAAC;AAGhE,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAgC9E"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nothing } from 'lit';
|
|
2
2
|
import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
|
|
3
|
-
import {
|
|
3
|
+
import { defaultClasses, defaultStyles, iconSizeClass, onClickAction, textColorClass, textColorStyle, } from '../attributes.js';
|
|
4
4
|
import { classMap, resolveIcon } from './util.js';
|
|
5
5
|
import { resolveStyleColor } from './color.js';
|
|
6
6
|
export function renderIconBlock(block, ctx) {
|
|
@@ -10,17 +10,14 @@ export function renderIconBlock(block, ctx) {
|
|
|
10
10
|
return nothing;
|
|
11
11
|
}
|
|
12
12
|
const { icon, size, color, colors } = block.config.iconConfig;
|
|
13
|
-
const styles = {
|
|
14
|
-
...textColorStyle(colors, color ?? 'neutral-content'),
|
|
15
|
-
...sizingStyle(block.size),
|
|
16
|
-
};
|
|
17
13
|
const classes = {
|
|
18
|
-
...defaultClasses(block
|
|
19
|
-
...stackChildClass(ctx.stackDirection),
|
|
20
|
-
...sizingClass(block.size),
|
|
14
|
+
...defaultClasses(block, ctx),
|
|
21
15
|
...textColorClass(),
|
|
22
16
|
...iconSizeClass(size),
|
|
23
|
-
|
|
17
|
+
};
|
|
18
|
+
const styles = {
|
|
19
|
+
...defaultStyles(block),
|
|
20
|
+
...textColorStyle(colors, color ?? 'neutral-content'),
|
|
24
21
|
};
|
|
25
22
|
const onClick = onClickAction(block, ctx);
|
|
26
23
|
return html `<div
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderImageBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderImageBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderImageBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderImageBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAA6B,YAAY,EAAE,MAAM,WAAW,CAAC;AAKpE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAyC/E"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nothing } from 'lit';
|
|
2
2
|
import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
|
|
3
|
-
import {
|
|
3
|
+
import { defaultClasses, defaultStyles, onClickAction, resizeModeClass } from '../attributes.js';
|
|
4
4
|
import { classMap, isValidImageURL } from './util.js';
|
|
5
5
|
import { VerifiedPublicImageHosts } from './constants.js';
|
|
6
6
|
const FALLBACK_IMG_URL = 'https://i.redd.it/p1vmc5ulmpib1.png';
|
|
@@ -18,14 +18,11 @@ export function renderImageBlock(block, ctx) {
|
|
|
18
18
|
imageUrl = FALLBACK_IMG_URL;
|
|
19
19
|
}
|
|
20
20
|
const classes = {
|
|
21
|
-
...defaultClasses(block
|
|
22
|
-
...stackChildClass(ctx.stackDirection),
|
|
23
|
-
...sizingClass(block.size),
|
|
21
|
+
...defaultClasses(block, ctx),
|
|
24
22
|
...resizeModeClass(resizeMode),
|
|
25
|
-
...cursorClass(block),
|
|
26
23
|
};
|
|
27
24
|
const styles = {
|
|
28
|
-
...
|
|
25
|
+
...defaultStyles(block),
|
|
29
26
|
};
|
|
30
27
|
const onClick = onClickAction(block, ctx);
|
|
31
28
|
return html `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderSpacerBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderSpacerBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderSpacerBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderSpacerBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAY,YAAY,EAAE,MAAM,WAAW,CAAC;AAEnD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAqBhF"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
|
|
2
|
-
import { defaultClasses,
|
|
2
|
+
import { defaultClasses, defaultStyles, spacerSizeClass } from '../attributes.js';
|
|
3
3
|
import { classMap } from './util.js';
|
|
4
4
|
export function renderSpacerBlock(block, ctx) {
|
|
5
5
|
const { html, styleMap } = getTemplateRenderingStrategy();
|
|
6
6
|
const classes = {
|
|
7
|
-
...defaultClasses(block
|
|
8
|
-
...stackChildClass(ctx.stackDirection),
|
|
9
|
-
...sizingClass(block.size),
|
|
7
|
+
...defaultClasses(block, ctx),
|
|
10
8
|
...spacerSizeClass(block.config?.spacerConfig?.size, block.config?.spacerConfig?.shape, ctx.stackDirection),
|
|
11
9
|
};
|
|
12
10
|
const styles = {
|
|
13
|
-
...
|
|
11
|
+
...defaultStyles(block),
|
|
14
12
|
};
|
|
15
13
|
return html `<div
|
|
16
14
|
class="${classMap(classes)}"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderStackBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderStackBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAuB,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAEL,kBAAkB,
|
|
1
|
+
{"version":3,"file":"renderStackBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderStackBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAuB,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAEL,kBAAkB,EAiBnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAY,YAAY,EAAE,MAAM,WAAW,CAAC;AAGnD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,EACZ,GAAG,2BAAsE,EACzE,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,KAAK,YAAY,EAC/D,kBAAkB,GAAE,kBAAkB,GAAG,SAAqB,GAC7D,YAAY,CAgFd"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { nothing } from 'lit';
|
|
2
2
|
import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
|
|
3
3
|
import { BlockStackDirection } from '@devvit/protos';
|
|
4
|
-
import { alignmentClass, backgroundClass, backgroundStyle, borderClass, borderStyle,
|
|
4
|
+
import { alignmentClass, backgroundClass, backgroundStyle, borderClass, borderStyle, defaultClasses, defaultStyles, gapClass, onClickAction, paddingClass, pointerEventsClass, radiusClass, stackDirectionClass, } from '../attributes.js';
|
|
5
5
|
import { classMap } from './util.js';
|
|
6
6
|
import { resolveStyleColor } from './color.js';
|
|
7
7
|
export function renderStackBlock(block, ctx = { stackDirection: BlockStackDirection.UNRECOGNIZED }, renderBlock, attributeOverrides = undefined) {
|
|
@@ -17,22 +17,19 @@ export function renderStackBlock(block, ctx = { stackDirection: BlockStackDirect
|
|
|
17
17
|
// capture mouse events on a stack if there are actions associated or there's a background color
|
|
18
18
|
const pointerEvents = !!block.actions.length || hasBGColor;
|
|
19
19
|
const classes = {
|
|
20
|
-
...defaultClasses(block
|
|
20
|
+
...defaultClasses(block, ctx),
|
|
21
21
|
...backgroundClass(!!backgroundColors || !!backgroundColor),
|
|
22
22
|
...stackDirectionClass(direction, reverse),
|
|
23
|
-
...stackChildClass(ctx.stackDirection),
|
|
24
|
-
...sizingClass(block.size),
|
|
25
23
|
...paddingClass(padding),
|
|
26
24
|
...gapClass(gap),
|
|
27
25
|
...alignmentClass(direction, alignment),
|
|
28
26
|
...borderClass(border),
|
|
29
27
|
...radiusClass(cornerRadius),
|
|
30
|
-
...cursorClass(block),
|
|
31
28
|
...pointerEventsClass(pointerEvents),
|
|
32
29
|
...attributeOverrides?.classes,
|
|
33
30
|
};
|
|
34
31
|
const styles = {
|
|
35
|
-
...
|
|
32
|
+
...defaultStyles(block),
|
|
36
33
|
...backgroundStyle(backgroundColors, backgroundColor),
|
|
37
34
|
...borderStyle(border),
|
|
38
35
|
...attributeOverrides?.styles,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderTextBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderTextBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAkD,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderTextBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderTextBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAkD,MAAM,gBAAgB,CAAC;AAgBvF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAY,YAAY,EAAE,MAAM,WAAW,CAAC;AAGnD,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA8D9E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { nothing } from 'lit';
|
|
2
2
|
import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
|
|
3
3
|
import { BlockTextSize, BlockTextStyle, BlockTextWeight } from '@devvit/protos';
|
|
4
|
-
import {
|
|
4
|
+
import { defaultClasses, defaultStyles, onClickAction, setTextOutline, textAlignClass, textColorClass, textColorStyle, textSelectClass, textSizeClass, textTruncateClass, textWeightClass, } from '../attributes.js';
|
|
5
5
|
import { classMap } from './util.js';
|
|
6
6
|
import { resolveStyleColor } from './color.js';
|
|
7
7
|
export function renderTextBlock(block, ctx) {
|
|
@@ -35,21 +35,18 @@ export function renderTextBlock(block, ctx) {
|
|
|
35
35
|
}
|
|
36
36
|
textSize = size ?? textSize;
|
|
37
37
|
textWeight = weight ?? textWeight;
|
|
38
|
-
const styles = {
|
|
39
|
-
...textColorStyle(colors, color ?? textColor),
|
|
40
|
-
...sizingStyle(block.size),
|
|
41
|
-
};
|
|
42
38
|
const classes = {
|
|
43
|
-
...defaultClasses(block
|
|
44
|
-
...stackChildClass(ctx.stackDirection),
|
|
45
|
-
...sizingClass(block.size),
|
|
39
|
+
...defaultClasses(block, ctx),
|
|
46
40
|
...textColorClass(),
|
|
47
41
|
...textSizeClass(textSize),
|
|
48
42
|
...textTruncateClass(),
|
|
49
43
|
...textAlignClass(alignment),
|
|
50
44
|
...textWeightClass(textWeight),
|
|
51
45
|
...textSelectClass(selectable),
|
|
52
|
-
|
|
46
|
+
};
|
|
47
|
+
const styles = {
|
|
48
|
+
...defaultStyles(block),
|
|
49
|
+
...textColorStyle(colors, color ?? textColor),
|
|
53
50
|
};
|
|
54
51
|
const onClick = onClickAction(block, ctx);
|
|
55
52
|
return html `<span
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderWebViewBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderWebViewBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAY,YAAY,EAAE,MAAM,WAAW,CAAC;AAEnD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"renderWebViewBlock.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/renderWebViewBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAY,YAAY,EAAE,MAAM,WAAW,CAAC;AAEnD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAyBjF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nothing } from 'lit';
|
|
2
2
|
import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
|
|
3
|
-
import { defaultClasses,
|
|
3
|
+
import { defaultClasses, defaultStyles } from '../attributes.js';
|
|
4
4
|
import { classMap } from './util.js';
|
|
5
5
|
export function renderWebViewBlock(block, ctx) {
|
|
6
6
|
const { html, styleMap } = getTemplateRenderingStrategy();
|
|
@@ -10,12 +10,10 @@ export function renderWebViewBlock(block, ctx) {
|
|
|
10
10
|
}
|
|
11
11
|
const { url } = block.config.webviewConfig;
|
|
12
12
|
const classes = {
|
|
13
|
-
...defaultClasses(block
|
|
14
|
-
...stackChildClass(ctx.stackDirection),
|
|
15
|
-
...sizingClass(block.size),
|
|
13
|
+
...defaultClasses(block, ctx),
|
|
16
14
|
};
|
|
17
15
|
const styles = {
|
|
18
|
-
...
|
|
16
|
+
...defaultStyles(block),
|
|
19
17
|
};
|
|
20
18
|
return html `<devvit-blocks-webview
|
|
21
19
|
src="${url}"
|
|
@@ -4,7 +4,7 @@ import { ref as clientRef, RefOrCallback } from 'lit/directives/ref.js';
|
|
|
4
4
|
import { StyleInfo } from 'lit/directives/style-map.js';
|
|
5
5
|
import { nothing, TemplateResult } from 'lit';
|
|
6
6
|
import type { UnsafeString } from '@reddit/baseplate/html.js';
|
|
7
|
-
import { BlockColor, BlockSizeUnit } from '@devvit/protos';
|
|
7
|
+
import { Block, BlockColor, BlockSizes, BlockSizes_Dimension_Value, BlockSizeUnit } from '@devvit/protos';
|
|
8
8
|
export type TemplateLike = TemplateResult | typeof nothing;
|
|
9
9
|
export declare function classMap(classInfo: ClassInfo, forceString?: boolean): string | ReturnType<typeof clientClassMap>;
|
|
10
10
|
export declare function unsafeHTML(input: string): DirectiveResult<DirectiveClass> | UnsafeString;
|
|
@@ -17,6 +17,13 @@ export declare function resolveIcon(name: string): TemplateResult;
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function sanitizeStyleInfo(styleInfo: StyleInfo): StyleInfo;
|
|
19
19
|
export declare function isValidImageURL(imageUrl: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Returns a BlockSizes object either directly from the block or constructs
|
|
22
|
+
* one from the legacy `size` field
|
|
23
|
+
* @param block
|
|
24
|
+
*/
|
|
25
|
+
export declare function getSizes(block: Block): BlockSizes | undefined;
|
|
26
|
+
export declare function parseDimension(value: BlockSizes_Dimension_Value | undefined): string | undefined;
|
|
20
27
|
export declare function getSizeUnits(unit: BlockSizeUnit | undefined): string;
|
|
21
28
|
/**
|
|
22
29
|
* Extracts the light and dark colors from a BlockColor object with an optional
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../library/src/blocks/templates/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAEpF,OAAO,EAAE,GAAG,IAAI,SA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AO,GAAG,SAAS,GAAG,EAAE,IAAI,WAAW,CAEtF;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAiBxD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CASjE;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAWzD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,UAAU,GAAG,SAAS,CA2B7D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,0BAA0B,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAKhG;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,GAAG,MAAM,CAUpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,GAC/B,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,CAIzD"}
|
package/blocks/templates/util.js
CHANGED
|
@@ -5,7 +5,7 @@ import { unsafeHTML as serverUnsafeHTML } from '@reddit/baseplate/html.js';
|
|
|
5
5
|
import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
|
|
6
6
|
import faceplateIcons from '@reddit/faceplate-ui/svgs/svg-manifest.js';
|
|
7
7
|
import { REDD_IT, VerifiedImageHosts } from './constants.js';
|
|
8
|
-
import { BlockSizeUnit } from '@devvit/protos';
|
|
8
|
+
import { BlockSizeUnit, } from '@devvit/protos';
|
|
9
9
|
export function classMap(classInfo, forceString) {
|
|
10
10
|
const { getType } = getTemplateRenderingStrategy();
|
|
11
11
|
if (getType() === 'client' && forceString !== true) {
|
|
@@ -79,6 +79,41 @@ export function isValidImageURL(imageUrl) {
|
|
|
79
79
|
return false;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns a BlockSizes object either directly from the block or constructs
|
|
84
|
+
* one from the legacy `size` field
|
|
85
|
+
* @param block
|
|
86
|
+
*/
|
|
87
|
+
export function getSizes(block) {
|
|
88
|
+
return (block.sizes ??
|
|
89
|
+
(block.size
|
|
90
|
+
? {
|
|
91
|
+
width: block.size.width != undefined
|
|
92
|
+
? {
|
|
93
|
+
value: {
|
|
94
|
+
value: block.size.width,
|
|
95
|
+
unit: block.size.widthUnit ?? BlockSizeUnit.SIZE_UNIT_PERCENT,
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
: undefined,
|
|
99
|
+
height: block.size.height != undefined
|
|
100
|
+
? {
|
|
101
|
+
value: {
|
|
102
|
+
value: block.size.height,
|
|
103
|
+
unit: block.size.heightUnit ?? BlockSizeUnit.SIZE_UNIT_PERCENT,
|
|
104
|
+
},
|
|
105
|
+
}
|
|
106
|
+
: undefined,
|
|
107
|
+
grow: block.size.grow,
|
|
108
|
+
}
|
|
109
|
+
: undefined));
|
|
110
|
+
}
|
|
111
|
+
export function parseDimension(value) {
|
|
112
|
+
if (!value) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
return `${value.value}${getSizeUnits(value.unit)}`;
|
|
116
|
+
}
|
|
82
117
|
export function getSizeUnits(unit) {
|
|
83
118
|
switch (unit) {
|
|
84
119
|
case BlockSizeUnit.SIZE_UNIT_PIXELS:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/ui-renderer",
|
|
3
|
-
"version": "0.10.7-next-2023-10-09-
|
|
3
|
+
"version": "0.10.7-next-2023-10-09-14cdd70d8.0",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
},
|
|
53
53
|
"types": "./index.d.ts",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@devvit/protos": "0.10.7-next-2023-10-09-
|
|
56
|
-
"@devvit/runtime-lite": "0.10.7-next-2023-10-09-
|
|
57
|
-
"@devvit/runtimes": "0.10.7-next-2023-10-09-
|
|
55
|
+
"@devvit/protos": "0.10.7-next-2023-10-09-14cdd70d8.0",
|
|
56
|
+
"@devvit/runtime-lite": "0.10.7-next-2023-10-09-14cdd70d8.0",
|
|
57
|
+
"@devvit/runtimes": "0.10.7-next-2023-10-09-14cdd70d8.0",
|
|
58
58
|
"@lottiefiles/lottie-player": "1.7.1",
|
|
59
59
|
"p-queue": "7.3.4",
|
|
60
60
|
"rxjs": "7.5.7"
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@devvit/eslint-config": "0.10.6",
|
|
83
83
|
"@devvit/repo-tools": "0.10.6",
|
|
84
|
-
"@devvit/tsconfig": "0.10.7-next-2023-10-09-
|
|
84
|
+
"@devvit/tsconfig": "0.10.7-next-2023-10-09-14cdd70d8.0",
|
|
85
85
|
"@lit/localize": "0.11.4",
|
|
86
86
|
"@open-wc/testing-helpers": "2.3.0",
|
|
87
87
|
"@reddit/baseplate": "0.14.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"directory": "dist"
|
|
111
111
|
},
|
|
112
112
|
"source": "./src/index.ts",
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "7b5d8500a569bc3a02dacad8fe1d5432a3913e80"
|
|
114
114
|
}
|