fix(projects): precompile sample styles so they render offline (#584)

The three sample projects compiled Tailwind in the browser via the Play
CDN (cdn.tailwindcss.com), so without network they rendered unstyled,
and the CDN logged a "should not be used in production" warning on
every load. healthcare-dashboard also loaded chart.js unversioned from
jsDelivr, so its charts silently disappeared offline.

- Move each inline tailwind.config into tailwind.config.js and ship a
  precompiled, minified styles.css (Tailwind 3.4.19, matching the v3
  Play CDN). projects/build-styles.sh regenerates them.
- Vendor Chart.js 4.6.1 (MIT) as vendor/chart.umd.min.js.

Verified in Chromium at 1440px and 375px: every element's computed
style and bounding box matches the CDN build. Google Fonts are still
loaded remotely; offline they fall back to the declared system fonts.

Refs #573 (item A)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vaibhav375 2026-11-19 06:34:54 +05:30 committed by GitHub
parent 0fa6f35939
commit 2de1134dc4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 93 additions and 67 deletions

10
projects/build-styles.sh Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env sh
# Regenerates each sample's precompiled styles.css so the pages render offline.
# Run after editing a sample's index.html or tailwind.config.js.
set -e
cd "$(dirname "$0")"
for dir in */; do
[ -f "$dir/tailwind.config.js" ] || continue
# Pinned to Tailwind v3, the version the original Play CDN builds used.
(cd "$dir" && npx --yes tailwindcss@3.4.19 -c tailwind.config.js -o styles.css --minify)
done

View File

@ -4,34 +4,11 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HealthView - Analytics Dashboard</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" href="styles.css">
<script src="vendor/chart.umd.min.js"></script><!-- Chart.js 4.6.1, MIT -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#3B82F6',
secondary: '#60A5FA',
accent: '#F97316',
surface: '#F8FAFC',
text: '#1E293B',
success: '#10B981',
warning: '#F59E0B',
danger: '#EF4444',
},
fontFamily: {
heading: ['Fira Sans', 'sans-serif'],
body: ['Fira Sans', 'sans-serif'],
mono: ['Fira Code', 'monospace'],
}
}
}
}
</script>
<style>
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,23 @@
// Source for styles.css — regenerate with projects/build-styles.sh
module.exports = {
content: ['./index.html'],
theme: {
extend: {
colors: {
primary: '#3B82F6',
secondary: '#60A5FA',
accent: '#F97316',
surface: '#F8FAFC',
text: '#1E293B',
success: '#10B981',
warning: '#F59E0B',
danger: '#EF4444',
},
fontFamily: {
heading: ['Fira Sans', 'sans-serif'],
body: ['Fira Sans', 'sans-serif'],
mono: ['Fira Code', 'monospace'],
}
}
}
};

File diff suppressed because one or more lines are too long

View File

@ -4,31 +4,10 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alex Chen - Full Stack Developer</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="styles.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Archivo:wght@300;400;500;600;700&family=Space+Grotesk:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#3B82F6',
secondary: '#1E293B',
cta: '#2563EB',
background: '#0F172A',
surface: '#1E293B',
text: '#F1F5F9',
muted: '#94A3B8',
},
fontFamily: {
heading: ['Space Grotesk', 'sans-serif'],
body: ['Archivo', 'sans-serif'],
}
}
}
}
</script>
<style>
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,21 @@
// Source for styles.css — regenerate with projects/build-styles.sh
module.exports = {
content: ['./index.html'],
theme: {
extend: {
colors: {
primary: '#3B82F6',
secondary: '#1E293B',
cta: '#2563EB',
background: '#0F172A',
surface: '#1E293B',
text: '#F1F5F9',
muted: '#94A3B8',
},
fontFamily: {
heading: ['Space Grotesk', 'sans-serif'],
body: ['Archivo', 'sans-serif'],
}
}
}
};

View File

@ -4,29 +4,10 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SaaSify - Streamline Your Workflow</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="styles.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#3B82F6',
secondary: '#60A5FA',
cta: '#F97316',
background: '#F8FAFC',
text: '#1E293B',
},
fontFamily: {
heading: ['Poppins', 'sans-serif'],
body: ['Open Sans', 'sans-serif'],
}
}
}
}
</script>
<style>
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,19 @@
// Source for styles.css — regenerate with projects/build-styles.sh
module.exports = {
content: ['./index.html'],
theme: {
extend: {
colors: {
primary: '#3B82F6',
secondary: '#60A5FA',
cta: '#F97316',
background: '#F8FAFC',
text: '#1E293B',
},
fontFamily: {
heading: ['Poppins', 'sans-serif'],
body: ['Open Sans', 'sans-serif'],
}
}
}
};