Skip to content

Commit 36a10c8

Browse files
authored
Implement build for interact for home page and improve viewEnter example (#158)
1 parent 22fc60b commit 36a10c8

8 files changed

Lines changed: 55 additions & 33 deletions

File tree

.github/workflows/interactdocs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ jobs:
4444
run: |
4545
NPQ_PKG_MGR=yarn npx npq install
4646
47+
- name: Build packages and landing page libs
48+
run: ./scripts/build-landing.sh
49+
4750
- name: Build docs app
4851
run: yarn workspace @wix/interact-docs build
4952
env:
@@ -64,7 +67,7 @@ jobs:
6467
mkdir -p _site/rules
6568
mkdir -p _site/assets
6669
67-
# Copy root landing page and assets
70+
# Copy root landing page and assets (includes assets/lib/ from build-landing.sh)
6871
cp index.html _site/
6972
cp -r assets/* _site/assets/
7073

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ node_modules
33
.env.*
44
dist/
55
build/
6+
assets/lib/*
7+
!assets/lib/.gitkeep
68
coverage/
79
.DS_Store
810
.idea/

assets/lib/.gitkeep

Whitespace-only changes.

assets/main.mjs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// WIX INTERACT RUNTIME
2-
import { Interact } from 'https://esm.sh/@wix/interact@2.0.2/dist/es/web.js';
3-
// import { Interact } from '../packages/interact/dist/es/web.js';
4-
import * as presets from 'https://esm.sh/@wix/motion-presets@latest/dist/es/motion-presets.js';
5-
// import * as presets from './packages/motion-presets/dist/es/motion-presets.js';
2+
import { Interact } from './lib/interact/es/web.js';
3+
import * as presets from './lib/motion-presets/motion-presets.js';
64

75
// =============================================================================
86
// FUNCTIONS & METHODS
@@ -723,7 +721,6 @@ const config = {
723721
{
724722
key: 'hitbox',
725723
trigger: 'viewEnter',
726-
727724
params: { type: 'alternate' },
728725
effects: [
729726
{
@@ -827,10 +824,12 @@ const config = {
827824

828825
// Entrance Interactions (Swirling Plus)
829826
{
830-
key: 'circle-top',
827+
key: 'entrance-card',
831828
trigger: 'viewEnter',
829+
params: { type: 'alternate', threshold: 0.8 },
832830
effects: [
833831
{
832+
key: 'circle-top',
834833
fill: 'both',
835834
keyframeEffect: {
836835
name: 'slideFromLeftToTop',
@@ -842,13 +841,8 @@ const config = {
842841
duration: ENTRANCE_DURATION,
843842
easing: ENTRANCE_EASING,
844843
},
845-
],
846-
},
847-
{
848-
key: 'circle-right',
849-
trigger: 'viewEnter',
850-
effects: [
851844
{
845+
key: 'circle-right',
852846
fill: 'both',
853847
keyframeEffect: {
854848
name: 'slideFromTopToRight',
@@ -861,13 +855,8 @@ const config = {
861855
easing: ENTRANCE_EASING,
862856
delay: 100,
863857
},
864-
],
865-
},
866-
{
867-
key: 'circle-bottom',
868-
trigger: 'viewEnter',
869-
effects: [
870858
{
859+
key: 'circle-bottom',
871860
fill: 'both',
872861
keyframeEffect: {
873862
name: 'slideFromRightToBottom',
@@ -880,13 +869,8 @@ const config = {
880869
easing: ENTRANCE_EASING,
881870
delay: 200,
882871
},
883-
],
884-
},
885-
{
886-
key: 'circle-left',
887-
trigger: 'viewEnter',
888-
effects: [
889872
{
873+
key: 'circle-left',
890874
fill: 'both',
891875
keyframeEffect: {
892876
name: 'slideFromBottomToLeft',

index.html

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,31 +393,31 @@ <h1 class="text-xl md:text-3xl font-light text-gray-600 leading-tight tracking-t
393393

394394
<!-- 3. ENTRANCE -->
395395
<div class="w-full h-auto lg:h-[500px] overflow-hidden flex flex-col lg:flex-row rounded-3xl">
396-
<div class="w-full lg:w-5/12 h-[400px] lg:h-full flex items-center justify-center p-6 lg:p-8 bg-white">
396+
<interact-element data-interact-key="entrance-card" class="w-full lg:w-5/12 h-[400px] lg:h-full flex items-center justify-center p-6 lg:p-8 bg-white">
397397
<div class="h-full aspect-square bg-[#000] relative overflow-hidden rounded-2xl">
398398

399399
<!-- Top Circle -->
400-
<interact-element data-interact-key="circle-top" data-interact-initial="true" class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-10">
400+
<interact-element data-interact-key="circle-top" class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-10">
401401
<div class="circle"><div class="fill-circle bg-transparent"></div></div>
402402
</interact-element>
403403

404404
<!-- Right Circle -->
405-
<interact-element data-interact-key="circle-right" data-interact-initial="true" class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-20">
405+
<interact-element data-interact-key="circle-right" class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-20">
406406
<div class="circle"><div class="fill-circle bg-transparent"></div></div>
407407
</interact-element>
408408

409409
<!-- Bottom Circle -->
410-
<interact-element data-interact-key="circle-bottom" data-interact-initial="true" class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-30">
410+
<interact-element data-interact-key="circle-bottom" class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-30">
411411
<div class="circle"><div class="fill-circle bg-transparent"></div></div>
412412
</interact-element>
413413

414414
<!-- Left Circle -->
415-
<interact-element data-interact-key="circle-left" data-interact-initial="true" class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-40">
415+
<interact-element data-interact-key="circle-left" class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-40">
416416
<div class="circle"><div class="fill-circle bg-transparent"></div></div>
417417
</interact-element>
418418

419419
</div>
420-
</div>
420+
</interact-element>
421421
<div class="w-full lg:w-7/12 flex flex-col p-6 lg:p-10 h-auto lg:h-full">
422422
<div class="mb-5 shrink-0">
423423
<h1 class="text-xl md:text-3xl font-light text-gray-600 leading-tight tracking-tight">View Enter (AKA Scroll Triggered Animations and Entrance Animations)</h1>
@@ -769,6 +769,13 @@ <h3 class="font-bold text-lg">Source Code</h3>
769769
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
770770
<script src="assets/modal.js"></script>
771771
<script src="assets/snippets.js"></script>
772+
<script type="importmap">
773+
{
774+
"imports": {
775+
"@wix/motion": "./assets/lib/motion/motion.js"
776+
}
777+
}
778+
</script>
772779
<script type="module" src="assets/main.mjs"></script>
773780
</body>
774781
</html>

packages/.gitkeep

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/interact/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"scripts": {
3333
"dev": "vite dev --open",
3434
"build": "rimraf dist && vite build && npm run build:types",
35+
"build:landing": "../../scripts/build-landing.sh",
3536
"build:types": "tsc -p tsconfig.build.json",
3637
"lint": "tsc --noEmit",
3738
"test": "vitest run",

scripts/build-landing.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
# Builds all packages and copies the dist files into assets/lib/
3+
# so that index.html can load Interact and Presets from local bundles.
4+
#
5+
# Usage:
6+
# yarn workspace @wix/interact build:landing (from anywhere in the repo)
7+
# ./scripts/build-landing.sh (from repo root)
8+
9+
set -euo pipefail
10+
11+
REPO_ROOT="$(git rev-parse --show-toplevel)"
12+
LIB_DIR="$REPO_ROOT/assets/lib"
13+
14+
yarn workspaces foreach --all --topological --include 'packages/*' run build
15+
16+
rm -rf "$LIB_DIR/interact" "$LIB_DIR/motion-presets" "$LIB_DIR/motion"
17+
18+
mkdir -p "$LIB_DIR/interact/es"
19+
mkdir -p "$LIB_DIR/motion-presets"
20+
mkdir -p "$LIB_DIR/motion"
21+
22+
cp "$REPO_ROOT/packages/interact/dist/es/web.js" "$LIB_DIR/interact/es/"
23+
cp "$REPO_ROOT/packages/interact/dist"/index-*.mjs "$LIB_DIR/interact/"
24+
cp "$REPO_ROOT/packages/motion-presets/dist/es/motion-presets.js" "$LIB_DIR/motion-presets/"
25+
cp "$REPO_ROOT/packages/motion/dist/es/motion.js" "$LIB_DIR/motion/"
26+
27+
echo "Landing page libraries copied to assets/lib/"

0 commit comments

Comments
 (0)