@cntrl-site/sdk-nextjs 1.9.40 → 1.9.41-12
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.
|
@@ -29,6 +29,7 @@ const useItemPointerEvents_1 = require("./useItemPointerEvents");
|
|
|
29
29
|
const useItemArea_1 = require("./useItemArea");
|
|
30
30
|
const useDraggable_1 = require("./useDraggable");
|
|
31
31
|
const ItemGeometryContext_1 = require("../../ItemGeometry/ItemGeometryContext");
|
|
32
|
+
const ItemArea_1 = require("@cntrl-site/sdk/lib/types/article/ItemArea");
|
|
32
33
|
const stickyFix = `
|
|
33
34
|
-webkit-transform: translate3d(0, 0, 0);
|
|
34
35
|
transform: translate3d(0, 0, 0);
|
|
@@ -117,6 +118,9 @@ const Item = ({ item, sectionId, articleHeight, isParentVisible = true, isInGrou
|
|
|
117
118
|
};
|
|
118
119
|
const isRichText = (0, isItemType_1.isItemType)(item, sdk_1.ArticleItemType.RichText);
|
|
119
120
|
const anchorSide = layout ? item.area[layout].anchorSide : sdk_1.AnchorSide.Top;
|
|
121
|
+
const dimensionsType = layout ? item.area[layout].dimensionsType : ItemArea_1.DimensionsType.PixelsBased;
|
|
122
|
+
const itemInnerHeight = dimensionsType === ItemArea_1.DimensionsType.PercentageBased ? `${height}vh` : `${height * 100}vw`;
|
|
123
|
+
const itemInnerWidth = dimensionsType === ItemArea_1.DimensionsType.PercentageBased ? `${width}vw` : isRichText ? `${width * exemplary}px` : `${width * 100}vw`;
|
|
120
124
|
const positionType = layout ? item.area[layout].positionType : sdk_1.PositionType.ScreenBased;
|
|
121
125
|
const isScreenBasedBottom = positionType === sdk_1.PositionType.ScreenBased && anchorSide === sdk_1.AnchorSide.Bottom;
|
|
122
126
|
const scale = (_h = (_g = innerStateProps === null || innerStateProps === void 0 ? void 0 : innerStateProps.styles) === null || _g === void 0 ? void 0 : _g.scale) !== null && _h !== void 0 ? _h : itemScale;
|
|
@@ -131,12 +135,8 @@ const Item = ({ item, sectionId, articleHeight, isParentVisible = true, isInGrou
|
|
|
131
135
|
height: isRichText && itemHeight !== undefined ? `${itemHeight * 100}vw` : 'unset'
|
|
132
136
|
}, children: (0, jsx_runtime_1.jsx)(RichTextWrapper_1.RichTextWrapper, { isRichText: isRichText, children: (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `item-${item.id}-inner`, ref: itemInnerRef, style: Object.assign(Object.assign(Object.assign({ top: `${position.y}px`, left: `${position.x}px` }, ((width !== undefined && height !== undefined)
|
|
133
137
|
? {
|
|
134
|
-
width: `${sizingAxis.x === 'manual'
|
|
135
|
-
|
|
136
|
-
? `${width * exemplary}px`
|
|
137
|
-
: `${width * 100}vw`
|
|
138
|
-
: 'max-content'}`,
|
|
139
|
-
height: `${sizingAxis.y === 'manual' ? `${height * 100}vw` : 'unset'}`
|
|
138
|
+
width: `${sizingAxis.x === 'manual' ? itemInnerWidth : 'max-content'}`,
|
|
139
|
+
height: `${sizingAxis.y === 'manual' ? itemInnerHeight : 'unset'}` // here
|
|
140
140
|
}
|
|
141
141
|
: {})), (scale !== undefined ? { transform: `scale(${scale})`, WebkitTransform: `scale(${scale})` } : {})), { transition: (_l = innerStateProps === null || innerStateProps === void 0 ? void 0 : innerStateProps.transition) !== null && _l !== void 0 ? _l : 'none', cursor: isDraggingActive
|
|
142
142
|
? 'grabbing'
|
|
@@ -149,6 +149,7 @@ const Item = ({ item, sectionId, articleHeight, isParentVisible = true, isInGrou
|
|
|
149
149
|
const sizingAxis = (0, useSizing_1.parseSizing)(layoutParams.sizing);
|
|
150
150
|
const isScreenBasedBottom = area.positionType === sdk_1.PositionType.ScreenBased && area.anchorSide === sdk_1.AnchorSide.Bottom;
|
|
151
151
|
const scaleAnchor = area.scaleAnchor;
|
|
152
|
+
const innerHeight = (area === null || area === void 0 ? void 0 : area.dimensionsType) && (area === null || area === void 0 ? void 0 : area.dimensionsType) === ItemArea_1.DimensionsType.PercentageBased ? `${area.height}vh` : `${area.height * 100}vw`;
|
|
152
153
|
return (`
|
|
153
154
|
.item-${item.id} {
|
|
154
155
|
position: ${sticky ? 'sticky' : 'absolute'};
|
|
@@ -162,7 +163,7 @@ const Item = ({ item, sectionId, articleHeight, isParentVisible = true, isInGrou
|
|
|
162
163
|
width: ${sizingAxis.x === 'manual'
|
|
163
164
|
? `${area.width * 100}vw`
|
|
164
165
|
: 'max-content'};
|
|
165
|
-
height: ${sizingAxis.y === 'manual' ?
|
|
166
|
+
height: ${sizingAxis.y === 'manual' ? innerHeight : 'unset'};
|
|
166
167
|
transform-origin: ${ScaleAnchorMap_1.ScaleAnchorMap[scaleAnchor]};
|
|
167
168
|
transform: scale(${area.scale});
|
|
168
169
|
position: relative;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getItemTopStyle = void 0;
|
|
4
4
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
5
|
function getItemTopStyle(top, anchorSide) {
|
|
6
|
+
console.log('getItemTopStyle', top);
|
|
6
7
|
const defaultValue = `${top * 100}vw`;
|
|
7
8
|
if (!anchorSide)
|
|
8
9
|
return defaultValue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cntrl-site/sdk-nextjs",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.41-12",
|
|
4
4
|
"description": "SDK for Next.js",
|
|
5
5
|
"author": "arsen@momdesign.nyc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@cntrl-site/color": "^1.0.0",
|
|
33
33
|
"@cntrl-site/components": "^0.1.28",
|
|
34
34
|
"@cntrl-site/effects": "^1.4.0",
|
|
35
|
-
"@cntrl-site/sdk": "^1.25.
|
|
35
|
+
"@cntrl-site/sdk": "^1.25.7",
|
|
36
36
|
"@types/vimeo__player": "^2.18.0",
|
|
37
37
|
"@vimeo/player": "^2.25.0",
|
|
38
38
|
"html-react-parser": "^3.0.1",
|
|
@@ -36,6 +36,7 @@ import { useItemPointerEvents } from './useItemPointerEvents';
|
|
|
36
36
|
import { useItemArea } from './useItemArea';
|
|
37
37
|
import { useDraggable } from './useDraggable';
|
|
38
38
|
import { ItemGeometryContext } from '../../ItemGeometry/ItemGeometryContext';
|
|
39
|
+
import { DimensionsType } from '@cntrl-site/sdk/lib/types/article/ItemArea';
|
|
39
40
|
|
|
40
41
|
export interface ItemProps<I extends ItemAny> {
|
|
41
42
|
item: I;
|
|
@@ -146,6 +147,9 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isP
|
|
|
146
147
|
|
|
147
148
|
const isRichText = isItemType(item, ArticleItemType.RichText);
|
|
148
149
|
const anchorSide = layout ? item.area[layout].anchorSide : AnchorSide.Top;
|
|
150
|
+
const dimensionsType = layout ? item.area[layout].dimensionsType : DimensionsType.PixelsBased;
|
|
151
|
+
const itemInnerHeight = dimensionsType === DimensionsType.PercentageBased ? `${height}vh` : `${height! * 100}vw`;
|
|
152
|
+
const itemInnerWidth = dimensionsType === DimensionsType.PercentageBased ? `${width}vw` : isRichText ? `${width! * exemplary}px` : `${width! * 100}vw`;
|
|
149
153
|
const positionType = layout ? item.area[layout].positionType : PositionType.ScreenBased;
|
|
150
154
|
const isScreenBasedBottom = positionType === PositionType.ScreenBased && anchorSide === AnchorSide.Bottom;
|
|
151
155
|
const scale = innerStateProps?.styles?.scale ?? itemScale;
|
|
@@ -185,12 +189,8 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isP
|
|
|
185
189
|
left: `${position.x}px`,
|
|
186
190
|
...((width !== undefined && height !== undefined)
|
|
187
191
|
? {
|
|
188
|
-
width: `${sizingAxis.x === 'manual'
|
|
189
|
-
|
|
190
|
-
? `${width * exemplary}px`
|
|
191
|
-
: `${width * 100}vw`
|
|
192
|
-
: 'max-content'}`,
|
|
193
|
-
height: `${sizingAxis.y === 'manual' ? `${height * 100}vw` : 'unset'}`
|
|
192
|
+
width: `${sizingAxis.x === 'manual' ? itemInnerWidth : 'max-content'}`,
|
|
193
|
+
height: `${sizingAxis.y === 'manual' ? itemInnerHeight : 'unset'}` // here
|
|
194
194
|
}
|
|
195
195
|
: {}),
|
|
196
196
|
...(scale !== undefined ? { transform: `scale(${scale})`, WebkitTransform: `scale(${scale})` } : {}),
|
|
@@ -226,6 +226,7 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isP
|
|
|
226
226
|
const sizingAxis = parseSizing(layoutParams.sizing);
|
|
227
227
|
const isScreenBasedBottom = area.positionType === PositionType.ScreenBased && area.anchorSide === AnchorSide.Bottom;
|
|
228
228
|
const scaleAnchor = area.scaleAnchor as AreaAnchor;
|
|
229
|
+
const innerHeight = area?.dimensionsType && area?.dimensionsType === DimensionsType.PercentageBased ? `${area.height}vh` : `${area.height * 100}vw`;
|
|
229
230
|
return (`
|
|
230
231
|
.item-${item.id} {
|
|
231
232
|
position: ${sticky ? 'sticky' : 'absolute'};
|
|
@@ -239,7 +240,7 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isP
|
|
|
239
240
|
width: ${sizingAxis.x === 'manual'
|
|
240
241
|
? `${area.width * 100}vw`
|
|
241
242
|
: 'max-content'};
|
|
242
|
-
height: ${sizingAxis.y === 'manual' ?
|
|
243
|
+
height: ${sizingAxis.y === 'manual' ? innerHeight : 'unset'};
|
|
243
244
|
transform-origin: ${ScaleAnchorMap[scaleAnchor]};
|
|
244
245
|
transform: scale(${area.scale});
|
|
245
246
|
position: relative;
|
|
Binary file
|