Skip to content

Commit b43f9ef

Browse files
authored
Merge pull request #601 from Stackla/feat/enable-storyline-and-shortvideos-to-use-new-expanded-view
feat: enable storyline and shortvideos to use new expanded view
2 parents 793f634 + 4f90800 commit b43f9ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2889
-322
lines changed

.prettierrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
{
1616
"files": "*.scss",
1717
"options": {
18-
"parser": "scss"
18+
"parser": "scss",
19+
"tabWidth": 2,
20+
"useTabs": false
1921
}
2022
}
2123
]

tests/e2e/assertions/expanded-tile.assert.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,26 @@ export async function shouldHaveTimestamps(page: Page, widgetType: string): Prom
5858

5959
export async function shouldHaveProductButtonWithValidURL(page: Page, widgetType: string): Promise<void> {
6060
await clickFirstWidgetTile(page, widgetType)
61-
const button = page.getByRole("link", { name: "Buy product: Kathmandu 1" }).first()
6261

63-
await expect(button).toHaveAttribute(
64-
"href",
65-
"/development/products/asus-tuf-f15-15-6-fhd-144hz-gaming-laptop-1tbgeforce-rtx-3050"
66-
)
67-
68-
// Listen for new tab
69-
const [newPage] = await Promise.all([page.context().waitForEvent("page"), button.click()])
70-
71-
// Wait for the new page to load
72-
await newPage.waitForLoadState()
62+
//data-testid="ugc-add-to-cart-button"
63+
const button = page.getByTestId("ugc-add-to-cart-button").first()
64+
65+
await page.pause()
66+
67+
// Wait for the POST request after clicking the button
68+
const [request] = await Promise.all([
69+
page.waitForRequest(
70+
req =>
71+
req.url().includes("/cart/add.js") &&
72+
req.method() === "POST" &&
73+
req.postData() === JSON.stringify({ items: [{ id: 39531616370889, quantity: 1 }] })
74+
),
75+
button.click()
76+
])
77+
78+
expect(request.url()).toContain("/cart/add.js")
79+
expect(request.method()).toBe("POST")
80+
expect(request.postData()).toBe(JSON.stringify({ items: [{ id: 39531616370889, quantity: 1 }] }))
7381
}
7482

7583
export async function shouldHaveAvatars(page: Page, widgetType: string): Promise<void> {

widgets/carousel/widget.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { initializeInlineSwiperListeners } from "./inline-carousel-swiper.loader
77

88
loadWidget(sdk, {
99
features: {
10+
addNewTilesAutomatically: false,
1011
handleLoadMore: false,
1112
cssVariables: {
1213
"--navigation-arrow-display": sdk.isPaginationEnabled() && !sdk.isScrollWidget() ? "flex" : "none"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
:host {
2+
--color-primary: #000;
3+
--color-secondary: rgb(50 45 45 / 80%);
4+
--color-white: #fff;
5+
--color-grey: #8D8D8D;
6+
--title-font-size: 16px;
7+
--paragraph-font-size: 15px;
8+
--paragraph-font-weight-small: 300;
9+
--paragraph-font-weight-normal: 400;
10+
--paragraph-font-weight-medium: 500;
11+
--paragraph-font-weight-bold: 700;
12+
--font-default: helveticaneueltpro, sans-serif;
13+
--product-title-font-size: clamp(0.875rem, 1vw, 1rem);
14+
--quick-add-font-size: clamp(1.2rem, 1vw, 1.5rem);
15+
--quick-add-variant-button-font-size: calc(var(--quick-add-font-size) * 0.8);
16+
--color-atc-button-border: #D9D9D9;
17+
--atc-variant-font-size: calc(var(--paragraph-font-size) * 0.8);
18+
--inline-user-handle: 14px;
19+
--lookup-icon-size: 36px;
20+
--title-line-height: 1.1;
21+
--title-margin-bottom: 5px;
22+
--description-size: 14px;
23+
--description-line-height: 1.4286;
24+
--description-margin-bottom: 10px;
25+
--username-font-weight: 700;
26+
--username-font-size: clamp(1.5rem, 1vw, 3rem);
27+
--user-handle-font-size: clamp(0.875rem, 1vw, 1.25rem);
28+
--user-handle-font-weight: 300;
29+
--title-size: 20px;
30+
31+
@media (min-width: 1370px) {
32+
--title-size: 28px;
33+
}
34+
35+
.font-grey {
36+
color: var(--color-grey) !important;
37+
}
38+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import type { ISdk } from "@stackla/widget-utils"
2+
import { StoryExpandedTile } from "./tile.template"
3+
import { createElement } from "@stackla/widget-utils"
4+
5+
export function StoryExpandedTiles(sdk: ISdk) {
6+
const tiles = sdk.getTiles()
7+
const { show_nav } = sdk.getExpandedTileConfig()
8+
const navigationArrowsEnabled = show_nav
9+
10+
return (
11+
<div class="expanded-tile-wrapper" variation="story">
12+
<div class="swiper swiper-expanded story-expanded">
13+
<div class="align-center">
14+
<div class="swiper-expanded-button-wrapper">
15+
<div
16+
class="swiper-expanded-button-prev swiper-button-prev btn-lg"
17+
style={{ display: navigationArrowsEnabled ? "flex" : "none" }}>
18+
<span class="chevron-left" alt="Previous arrow" />
19+
</div>
20+
<div
21+
class="swiper-expanded-button-next swiper-button-next btn-lg"
22+
style={{ display: navigationArrowsEnabled ? "flex" : "none" }}>
23+
<span class="chevron-right" alt="Next arrow" />
24+
</div>
25+
</div>
26+
</div>
27+
<div class="swiper-wrapper ugc-tiles">
28+
{tiles.map(tile => (
29+
<div
30+
class="ugc-tile swiper-slide"
31+
data-id={tile.id}
32+
data-yt-id={tile.youtube_id || ""}
33+
data-tiktok-id={tile.tiktok_id || ""}>
34+
<StoryExpandedTile sdk={sdk} tile={tile} />
35+
</div>
36+
))}
37+
</div>
38+
</div>
39+
</div>
40+
)
41+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import type { Sdk, UserConfig } from "@stackla/widget-utils"
2+
3+
declare const sdk: Sdk
4+
5+
const tilesLength = sdk.querySelectorAll(".ugc-tile")?.length ?? 0
6+
7+
export const config: UserConfig = {
8+
components: {
9+
inline_products: {
10+
swiper_options: {
11+
allowTouchMove: true
12+
}
13+
}
14+
},
15+
style: {
16+
cta_btn_background: "#000000",
17+
cta_btn_font_color: "#ffffff",
18+
cta_btn_font_size: "14",
19+
// The background color of the widget, uses var(--widget-background) in css-variables.ts
20+
widget_background: "#ffffff",
21+
// The background color of the tile, uses var(--text-tile-background) in css-variables.ts
22+
text_tile_background: "#ffffff",
23+
// The font color of the tiles, uses var(--text-tile-font-color) in css-variables.ts
24+
text_tile_font_color: "#000000",
25+
// The font color of the user handle, uses var(--text-tile-user-handle-font-color) in css-variables.ts
26+
text_tile_user_handle_font_color: "#636062",
27+
// The font color of the user name, uses var(--text-tile-user-name-font-color) in css-variables.ts
28+
text_tile_user_name_font_color: "#ffffff",
29+
// The font size of the tile contents, uses var(--text-tile-font-size) in css-variables.ts
30+
text_tile_font_size: "10",
31+
// The font size of the user handle, uses var(--text-tile-user-handle-font-size) in css-variables.ts
32+
text_tile_user_handle_font_size: "14",
33+
// The font size of the user name, uses var(--text-tile-user-name-font-size) in css-variables.ts
34+
text_tile_user_name_font_size: "14",
35+
// The margin of the widget, and gap between tiles, uses var(--margin) in css-variables.ts
36+
margin: "10",
37+
// The mode of what happens when a tile is clicked, options: [EXPAND], [ORIGINAL_URL] or [CUSTOM]
38+
// [EXPAND] will expand the tile, [ORIGINAL_URL] will open the original URL associated with a social media image, [CUSTOM] will open a custom URL (not implemented)
39+
click_through_url: "[EXPAND]",
40+
// The background image of the icon, uses var(--shopspot-icon) in css-variables.ts, defaults to #000
41+
shopspot_icon: "",
42+
// Whether the tile should automatically pull new tiles or not
43+
auto_refresh: "true",
44+
// Whether the widget should only load x amount of tiles per page
45+
tiles_per_page: "",
46+
enable_custom_tiles_per_page: true,
47+
// Whether the widget should load more tiles on scroll, button or static
48+
load_more_type: "static",
49+
// The name of the widget
50+
name: "Blank Canvas",
51+
// The link color of the tile, uses var(--text-tile-link-color) in css-variables.ts
52+
text_tile_link_color: "",
53+
// The minimum amount of tiles required to show the widget
54+
minimal_tiles: "6",
55+
// Tile size: small, medium, large
56+
inline_tile_size: "medium",
57+
// The border radius of the inline tile, uses var(--inline-tile-border-radius) in css-variables.ts
58+
inline_tile_border_radius: "5",
59+
// The border radius of the expanded tile, uses var(--expanded-tile-border-radius) in css-variables.ts
60+
expanded_tile_border_radius: "5"
61+
},
62+
expandedTile: {
63+
swiper_options: {
64+
slidesPerView: 1,
65+
direction: "vertical",
66+
loop: tilesLength > 4
67+
},
68+
// Whether to show the caption of the tile
69+
show_caption: true,
70+
// Whether to show the timestamp of the tile
71+
show_timestamp: true,
72+
// Whether to show the navigation options of the tile
73+
show_nav: true,
74+
// Whether to show the sharing options of the tile
75+
show_sharing: true,
76+
// Whether to show the shopspots of the tile
77+
show_shopspots: true,
78+
// Whether to show the products of the tile
79+
show_products: true,
80+
// Whether to show the tags of the tile
81+
show_tags: true,
82+
// Whether to show the votes of the tile
83+
show_votes: true,
84+
// Whether to show the cross sellers of the tile
85+
show_cross_sellers: false,
86+
// Whether to show the add to cart
87+
show_add_to_cart: true,
88+
// Whether to show the carousel grouping
89+
show_carousel_grouping: true
90+
},
91+
inlineTile: {
92+
// Whether to show the navigation options of the tile
93+
show_nav: true,
94+
// Whether to show the sharing options of the tile
95+
show_sharing: true,
96+
// Whether to show the shopspots
97+
show_shopspots: true,
98+
// Whether to show the tags of the tile
99+
show_tags: true,
100+
// Whether to show the timestamp of the tile
101+
show_timestamp: true,
102+
// Whether to show the caption of the tile
103+
show_caption: true,
104+
// Whether to show the products of the tile
105+
show_products: true,
106+
// Whether to show the add to cart functionality
107+
show_add_to_cart: true,
108+
// Whether to auto play the video
109+
auto_play_video: false,
110+
// Whether to show the inline tiles
111+
show_inline_tiles: true,
112+
// Whether to show the carousel
113+
show_carousel: false
114+
}
115+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { stripMetaCurrencySymbols } from "./inline-products.template"
2+
3+
describe("should test stripMetaCurrencySymbols", () => {
4+
test("should return empty string for empty string input", () => {
5+
expect(stripMetaCurrencySymbols("")).toBe("")
6+
})
7+
test("should keep currency symbols and numbers", () => {
8+
expect(stripMetaCurrencySymbols("$100")).toBe("$100")
9+
expect(stripMetaCurrencySymbols("€200.50")).toBe("€200.50")
10+
expect(stripMetaCurrencySymbols("£300,00")).toBe("£300,00")
11+
expect(stripMetaCurrencySymbols("¥400")).toBe("¥400")
12+
})
13+
test("should remove non-currency characters", () => {
14+
expect(stripMetaCurrencySymbols("Price: $100")).toBe("$100")
15+
expect(stripMetaCurrencySymbols("Total: €200.50")).toBe("€200.50")
16+
expect(stripMetaCurrencySymbols("Cost: £300,00")).toBe("£300,00")
17+
expect(stripMetaCurrencySymbols("Amount: ¥400")).toBe("¥400")
18+
})
19+
test("should handle multiple currency symbols", () => {
20+
expect(stripMetaCurrencySymbols("$100€200")).toBe("$100€200")
21+
expect(stripMetaCurrencySymbols("£300,00¥400")).toBe("£300,00¥400")
22+
})
23+
test("should remove GBP symbol but keep the number", () => {
24+
expect(stripMetaCurrencySymbols("GBP£300,00")).toBe("£300,00")
25+
})
26+
})

0 commit comments

Comments
 (0)