diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..12ed7cb --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,52 @@ +name: PR — Ouverture automatique + +on: + push: + branches-ignore: [main] + workflow_dispatch: + +jobs: + create-pr: + runs-on: coeur-ua-pam + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Ouvrir (ou vérifier) la pull request + env: + GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }} + API: ${{ github.server_url }}/api/v1 + REPO: ${{ github.repository }} + BRANCH: ${{ github.ref_name }} + run: | + set -eu + if [ "$BRANCH" = "main" ]; then + echo "main est la base : aucune PR à ouvrir." + exit 0 + fi + title=$(git log -1 --pretty=%s) + body=$(git log -1 --pretty=%b) + [ -n "$body" ] || body="PR automatique de $BRANCH vers main." + + open=$(curl -fsS -H "Authorization: token $GITEA_TOKEN" \ + "$API/repos/$REPO/pulls?state=open&limit=50" \ + | python3 -c 'import json,os,sys; b=os.environ["BRANCH"]; print(sum(1 for p in json.load(sys.stdin) if p.get("head", {}).get("ref") == b))') + if [ "$open" -gt 0 ]; then + echo "Une PR est déjà ouverte pour $BRANCH." + exit 0 + fi + + python3 - "$BRANCH" "$title" "$body" <<'PY' | curl -fsS -X POST \ + -H "Authorization: token $GITEA_TOKEN" \ + -H "Content-Type: application/json" \ + --data-binary @- \ + "$API/repos/$REPO/pulls" + import json, sys + branch, title, body = sys.argv[1], sys.argv[2], sys.argv[3] + print(json.dumps({"base": "main", "head": branch, "title": title, "body": body})) + PY + echo "PR créée." diff --git a/index.html b/index.html index bbfe3c5..23ef9de 100644 --- a/index.html +++ b/index.html @@ -2,7 +2,10 @@ - + + + + Coeur UA PAM - Unis par le coeur + }> } /> diff --git a/src/components/AnimatedContent.tsx b/src/components/AnimatedContent.tsx index 79dc45f..07c6694 100644 --- a/src/components/AnimatedContent.tsx +++ b/src/components/AnimatedContent.tsx @@ -1,6 +1,7 @@ import React, { useRef, useEffect } from "react"; import { gsap } from "gsap"; import { ScrollTrigger } from "gsap/ScrollTrigger"; +import { runAfterTransition } from "../lib/transition"; gsap.registerPlugin(ScrollTrigger); @@ -96,15 +97,20 @@ const AnimatedContent: React.FC = ({ ease, }); + let stopWaiting = () => {}; + const st = ScrollTrigger.create({ trigger: el, scroller: scrollerTarget || window, start: `top ${startPct}%`, once: true, - onEnter: () => tl.play(), + onEnter: () => { + stopWaiting = runAfterTransition(() => tl.play()); + }, }); return () => { + stopWaiting(); st.kill(); tl.kill(); }; diff --git a/src/components/PageTransition.tsx b/src/components/PageTransition.tsx new file mode 100644 index 0000000..d78f306 --- /dev/null +++ b/src/components/PageTransition.tsx @@ -0,0 +1,131 @@ +import { useLayoutEffect, useRef } from "react"; +import { useLocation } from "react-router-dom"; +import logo from "/logo.png"; +import { markTransitionStart, markTransitionEnd } from "../lib/transition"; + +const HERO_IMAGES: Record = { + "/": "/hero-section/accueil.webp", + "/a-propos": "/hero-section/a-propos.webp", + "/notre-histoire": "/hero-section/historique.webp", + "/evenements": "/hero-section/evenements.webp", +}; + +const FADE_IN_MS = 220; +const BAR_MS = 750; +const MIN_VISIBLE_MS = 750; +const MAX_WAIT_MS = 2500; + +const PageTransition = () => { + const { pathname } = useLocation(); + const overlayRef = useRef(null); + const fillRef = useRef(null); + const textRef = useRef(null); + + useLayoutEffect(() => { + const overlay = overlayRef.current; + const fill = fillRef.current; + const text = textRef.current; + if (!overlay || !fill || !text) return; + + markTransitionStart(); + document.documentElement.classList.add("is-transitioning"); + + overlay.style.transition = "none"; + overlay.style.opacity = "0"; + overlay.style.visibility = "visible"; + overlay.style.pointerEvents = "auto"; + fill.style.transition = "none"; + fill.style.width = "0%"; + text.style.transition = "none"; + text.style.clipPath = "inset(0 100% 0 0)"; + void overlay.offsetWidth; + overlay.style.transition = `opacity ${FADE_IN_MS}ms ease-in-out`; + overlay.style.opacity = "1"; + fill.style.transition = `width ${BAR_MS}ms ease-out`; + fill.style.width = "100%"; + text.style.transition = `clip-path ${BAR_MS}ms ease-out`; + text.style.clipPath = "inset(0 0% 0 0)"; + + const startedAt = performance.now(); + let done = false; + + const reveal = () => { + if (done) return; + done = true; + markTransitionEnd(); + document.documentElement.classList.remove("is-transitioning"); + overlay.style.transition = "none"; + overlay.style.opacity = "0"; + overlay.style.visibility = "hidden"; + overlay.style.pointerEvents = "none"; + }; + + const finishAfterMinimum = () => { + const remaining = MIN_VISIBLE_MS - (performance.now() - startedAt); + window.setTimeout(reveal, Math.max(0, remaining)); + }; + + const maxTimer = window.setTimeout(reveal, MAX_WAIT_MS); + + const src = HERO_IMAGES[pathname]; + if (src) { + let handled = false; + const onReady = () => { + if (handled) return; + handled = true; + window.clearTimeout(maxTimer); + finishAfterMinimum(); + }; + const image = new Image(); + image.onload = onReady; + image.onerror = onReady; + image.src = src; + if (image.complete) onReady(); + } else { + window.clearTimeout(maxTimer); + finishAfterMinimum(); + } + + return () => { + window.clearTimeout(maxTimer); + document.documentElement.classList.remove("is-transitioning"); + }; + }, [pathname]); + + return ( +