Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
},
"scripts": {
"dev": "react-scripts start",
"start:nolint": "npx --yes create-react-play@latest -p && react-scripts start",
"start": "npx --yes create-react-play@latest -p && npm run lint && react-scripts start",
"build": "npx --yes create-react-play@latest -p && react-scripts build",
"start:nolint": "npx --yes create-react-play@latest -p && node scripts/sanitize-play-exports.cjs && react-scripts start",
"start": "npx --yes create-react-play@latest -p && node scripts/sanitize-play-exports.cjs && npm run lint && react-scripts start",
"build": "npx --yes create-react-play@latest -p && node scripts/sanitize-play-exports.cjs && react-scripts build",
"snap": "react-snap",
"test": "react-scripts test",
"eject": "react-scripts eject",
Expand Down Expand Up @@ -157,6 +157,6 @@
"react-snap": "^1.23.0",
"tailwind-scrollbar": "^2.1.0",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.9.3"
}
}
86 changes: 86 additions & 0 deletions scripts/sanitize-play-exports.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env node
'use strict';

const fs = require('fs');
const path = require('path');

const indexPath = path.join(process.cwd(), 'src', 'plays', 'index.js');

if (!fs.existsSync(indexPath)) {
console.warn(`[sanitize-play-exports] Skipped: file not found at ${indexPath}`);
process.exit(0);
}

const source = fs.readFileSync(indexPath, 'utf8');
const newline = source.includes('\r\n') ? '\r\n' : '\n';
const hasTrailingNewline = source.endsWith('\n');
const lines = source.split(/\r?\n/);
Comment on lines +14 to +17

Copilot AI Feb 15, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source.split(/\r?\n/) preserves a trailing empty string when the file ends with a newline. Combined with later join(newline), this already reproduces the trailing newline, so any separate “re-add trailing newline” step will introduce an extra blank line each run.

Copilot uses AI. Check for mistakes.

const exportLinePattern = /^(\s*export\s*\{\s*default\s+as\s+)([^}]+?)(\s*\}\s*from\s*['"][^'"]+['"]\s*;?\s*)$/;
const isValidIdentifier = (value) => /^[$A-Z_a-z][$0-9A-Z_a-z]*$/.test(value);

const toPascalCase = (value) => {
const chunks = value
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
.split(/[^0-9A-Z_a-z$]+/)
.filter(Boolean);

let identifier = chunks
.map((chunk) => chunk.charAt(0).toUpperCase() + chunk.slice(1))
.join('');

if (identifier.length === 0) {
identifier = 'Play';
}

if (!/^[$A-Z_a-z]/.test(identifier)) {
identifier = `Play${identifier}`;
}

return identifier;
};

const usedAliases = new Set();
let updateCount = 0;

const nextLines = lines.map((line) => {
const match = line.match(exportLinePattern);
if (match == null) {
return line;
}

const [, prefix, rawAlias, suffix] = match;
const currentAlias = rawAlias.trim();
let nextAlias = currentAlias;

if (!isValidIdentifier(currentAlias)) {
nextAlias = toPascalCase(currentAlias);
}

const aliasBase = nextAlias;
let duplicateIndex = 2;
while (usedAliases.has(nextAlias)) {
nextAlias = `${aliasBase}${duplicateIndex}`;
duplicateIndex += 1;
}
usedAliases.add(nextAlias);

if (nextAlias !== currentAlias) {
updateCount += 1;
return `${prefix}${nextAlias}${suffix}`;
}

return line;
});

let nextSource = nextLines.join(newline);
if (hasTrailingNewline) {
nextSource += newline;
}
Comment on lines +76 to +79

Copilot AI Feb 15, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block will append an extra newline every time the script runs (because join(newline) already retains the trailing newline from the split). Suggest removing this conditional append, or trimming the trailing empty line before join and then re-adding exactly one newline.

Copilot uses AI. Check for mistakes.

if (nextSource !== source) {
fs.writeFileSync(indexPath, nextSource, 'utf8');
console.log(`[sanitize-play-exports] Updated ${updateCount} export alias(es).`);
} else {
console.log('[sanitize-play-exports] No invalid aliases found.');
}
5 changes: 4 additions & 1 deletion src/common/Testimonial/TestimonialCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ const TestimonialCard = ({ home, quote, name, avatarUrl, category, created_at, e
</div>

<div className="mx-2 mt-4">
<blockquote className={`${home && 'h-32'} max-h-32 px-6 overflow-y-auto`}>
<blockquote
className={`${home ? 'h-32' : ''} max-h-32 px-6 overflow-y-auto`}
style={{ touchAction: 'pan-y' }}
>
<p
className="leading-relaxed text-gray-700"
dangerouslySetInnerHTML={{ __html: replaceWithBr() }}
Expand Down
11 changes: 9 additions & 2 deletions src/common/Testimonial/TestimonialSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ function TestimonialSection() {
const [testimonials, setTestimonials] = useState([]);

const fetchTestimonials = async () => {
const res = await submit(fetchTestimonialsHomePage());
setTestimonials(res);
try {
const res = await submit(fetchTestimonialsHomePage());
setTestimonials(res || []);
} catch (error) {
console.warn('Failed to fetch testimonials:', error.message);
setTestimonials([]);
}
};

useEffect(() => {
Expand All @@ -30,6 +35,7 @@ function TestimonialSection() {
<>
<div className="mx-5 lg:mx-20 h-72 mt-16 sm:mt-20">
<Swiper
grabCursor
rewind
autoplay={{
delay: 2500,
Expand All @@ -56,6 +62,7 @@ function TestimonialSection() {
}}
slidesPerView={1}
spaceBetween={10}
touchEventsTarget="container"
>
{testimonials &&
testimonials.map((testimonial) => (
Expand Down
9 changes: 7 additions & 2 deletions src/common/Testimonial/Testimonials.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ const Testimonials = () => {
const isAuthenticated = useAuthenticated();

const fetchTestimonials = async () => {
const res = await submit(fetchAllTestimonials());
setTestimonials(res);
try {
const res = await submit(fetchAllTestimonials());
setTestimonials(res || []);
} catch (error) {
console.warn('Failed to fetch testimonials:', error.message);
setTestimonials([]);
}
};

const handleLogin = (value) => {
Expand Down
23 changes: 22 additions & 1 deletion src/common/header/HeaderNav.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useState, useEffect, useRef } from 'react';
import { Link } from 'react-router-dom';
import { BsGithub, BsTrophyFill } from 'react-icons/bs';
import { FaLightbulb } from 'react-icons/fa';
Expand All @@ -16,6 +16,26 @@ const HeaderNav = ({ showBrowse }) => {
const { showShareModal, setShowShareModal } = useSearchContext();

const [showToggleMenu, setShowToggleMenu] = useState(false);
const menuRef = useRef(null);

// Close drawer when clicking outside the menu panel
useEffect(() => {
if (!showToggleMenu) return;

const handleClickOutside = (event) => {
if (menuRef.current && !menuRef.current.contains(event.target)) {
setShowToggleMenu(false);
}
};

document.addEventListener('mousedown', handleClickOutside);
document.addEventListener('touchstart', handleClickOutside);

return () => {
document.removeEventListener('mousedown', handleClickOutside);
document.removeEventListener('touchstart', handleClickOutside);
};
}, [showToggleMenu]);

const [anchorEl, setAnchorEl] = useState(null);

Expand Down Expand Up @@ -129,6 +149,7 @@ const HeaderNav = ({ showBrowse }) => {
<ul
className="header-links"
data-testid="header-links-container"
ref={menuRef}
onClick={(e) => e.stopPropagation()}
>
<li className="menu-closer">
Expand Down
7 changes: 6 additions & 1 deletion src/common/header/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
}

.nav--visible {
transform: translateY(0);
transform: none;
}

/* Push page content below the fixed header, but not the footer */
.nav-wrapper ~ *:not(footer) {
padding-top: 64px;
}


Expand Down
1 change: 1 addition & 0 deletions src/common/home/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
width: 100%;
overflow-x: hidden;
min-height: 100vh;
padding-top: 32px; /* extra offset for activity banner on home page */
}

.app-home-body .app-home-body-content {
Expand Down
3 changes: 2 additions & 1 deletion src/common/playleaderboard/LeaderBoard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import TopPlayCreators from './TopPlayCreators';
import { Watch } from 'react-loader-spinner';
import { groupBy } from 'lodash';
import { format, lastDayOfMonth } from 'date-fns';
import './leaderBoard.css';

const LeaderBoard = () => {
const [top10Contributors, updateTop10Contributors] = useState([]);
Expand Down Expand Up @@ -69,7 +70,7 @@ const LeaderBoard = () => {
}, [publishedPlays]);

return (
<main className="app-body app-body-overflow-hidden">
<main className="app-body">
{publishedPlays.length && (topContributorOfTheMonth || top10Contributors) ? (
<div className=" overflow-auto lg:flex flex-row justify-center">
{topContributorOfTheMonth && (
Expand Down
7 changes: 7 additions & 0 deletions src/common/playleaderboard/leaderBoard.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
height: 100vh;
} */

.leaderboard-loader {
display: flex;
align-items: center;
justify-content: center;
min-height: calc(100vh - 160px);
}

.leaderboard-wrapper {
background-color: #ffffff;
border-radius: 16px;
Expand Down
Loading