Skip to content

Commit 11eef56

Browse files
authored
Merge pull request #18 from EntchenEric/development
v1.1.1
2 parents 87b3609 + 5e72b38 commit 11eef56

2 files changed

Lines changed: 8 additions & 25 deletions

File tree

app/bar/route.ts

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { NextRequest, NextResponse } from 'next/server';
33
export async function GET(request: NextRequest) {
44
const searchParams = request.nextUrl.searchParams;
55

6-
const color = searchParams.get('color') || '#2563eb';
6+
const color = searchParams.get('color') || '#3b82f6';
77
const colorGradient = searchParams.get('colorGradient');
8-
const backgroundColor = searchParams.get('backgroundColor') || '#f3f4f6';
9-
const progress = parseIntSafe(searchParams.get('progress'), 0);
10-
const height = Math.min(500, Math.max(5, parseIntSafe(searchParams.get('height'), 5)));
11-
const width = Math.min(3000, Math.max(10, parseIntSafe(searchParams.get('width'), 10)));
12-
const borderRadius = Math.min(1000, Math.max(0, parseIntSafe(searchParams.get('borderRadius'), 0)));
8+
const backgroundColor = searchParams.get('backgroundColor') || '#e5e7eb';
9+
const progress = parseIntSafe(searchParams.get('progress'), 65);
10+
const height = Math.min(500, Math.max(5, parseIntSafe(searchParams.get('height'), 24)));
11+
const width = Math.min(3000, Math.max(10, parseIntSafe(searchParams.get('width'), 400)));
12+
const borderRadius = Math.min(1000, Math.max(0, parseIntSafe(searchParams.get('borderRadius'), 12)));
1313
const striped = searchParams.get('striped') === 'true';
1414
const animated = searchParams.get('animated') === 'true';
1515
const animationSpeed = parseFloatSafe(searchParams.get('animationSpeed'), 0);
@@ -26,10 +26,8 @@ export async function GET(request: NextRequest) {
2626
const shouldAnimate = initialAnimationSpeed > 0;
2727
const initialAnimationDuration = (clampedProgress / 100) * (1 / initialAnimationSpeed);
2828

29-
// Helper function to create gradient definition
3029
const createGradientDef = () => {
3130
if (colorGradient) {
32-
// Extract colors and positions from gradient string
3331
const matches = colorGradient.match(/(#[A-Fa-f0-9]{6}|#[A-Fa-f0-9]{3}|rgba?\([^)]+\))/g) || [];
3432
if (matches.length >= 2) {
3533
return `
@@ -41,7 +39,6 @@ export async function GET(request: NextRequest) {
4139
`;
4240
}
4341
}
44-
// Fallback to default gradient using single color
4542
return `
4643
<linearGradient id="progressGradient" x1="0%" y1="0%" x2="100%" y2="0%">
4744
<stop offset="0%" style="stop-color:${color}; stop-opacity:1" />
@@ -76,7 +73,6 @@ export async function GET(request: NextRequest) {
7673
</filter>
7774
</defs>
7875
79-
<!-- Background -->
8076
<rect
8177
width="${width}"
8278
height="${height}"
@@ -85,10 +81,7 @@ export async function GET(request: NextRequest) {
8581
fill="${backgroundColor}"
8682
filter="url(#shadow)"
8783
/>
88-
89-
<!-- Progress bar -->
9084
<g clip-path="url(#progressClip)">
91-
<!-- Main fill -->
9285
<rect
9386
width="${width}"
9487
height="${height}"
@@ -98,7 +91,6 @@ export async function GET(request: NextRequest) {
9891
/>
9992
10093
${striped ? `
101-
<!-- Striped overlay -->
10294
<rect
10395
width="${progressWidth}"
10496
height="${height}"
@@ -108,7 +100,6 @@ export async function GET(request: NextRequest) {
108100
` : ''}
109101
</g>
110102
111-
<!-- Rounded corners overlay to ensure proper rounding -->
112103
<rect
113104
width="${width}"
114105
height="${height}"
@@ -120,7 +111,6 @@ export async function GET(request: NextRequest) {
120111
opacity="0.5"
121112
/>
122113
123-
<!-- Animation definitions -->
124114
<style>
125115
@keyframes progress-stripes {
126116
from { background-position: ${50 * safeAnimationSpeed}px 0; }
@@ -174,7 +164,6 @@ function adjustColor(color: string, amount: number): string {
174164
return `#${newR.toString(16).padStart(2, '0')}${newG.toString(16).padStart(2, '0')}${newB.toString(16).padStart(2, '0')}`;
175165
}
176166

177-
// Helper function to safely parse integers with fallback
178167
function parseIntSafe(value: string | null, defaultValue: number): number {
179168
if (value === null || value === undefined || value === '') {
180169
return defaultValue;
@@ -184,7 +173,6 @@ function parseIntSafe(value: string | null, defaultValue: number): number {
184173
return isNaN(parsed) ? defaultValue : parsed;
185174
}
186175

187-
// Helper function to safely parse floats with fallback
188176
function parseFloatSafe(value: string | null, defaultValue: number): number {
189177
if (value === null || value === undefined || value === '') {
190178
return defaultValue;

app/page.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export default function Home() {
3030
const [theme, setTheme] = useState<'light' | 'dark'>('light')
3131
const [highContrast, setHighContrast] = useState(false)
3232
const [showConfetti, setShowConfetti] = useState(false)
33-
const [iframeKey, setIframeKey] = useState(0)
3433
const [ariaMessage, setAriaMessage] = useState('')
3534

3635
useEffect(() => {
@@ -99,7 +98,6 @@ export default function Home() {
9998
setHighContrast(!highContrast)
10099
}
101100

102-
// High contrast color overrides
103101
const getHighContrastColors = (isLight: boolean) => {
104102
return {
105103
text: isLight ? 'text-black' : 'text-white',
@@ -110,7 +108,6 @@ export default function Home() {
110108
}
111109
}
112110

113-
// Helper function to get theme-based classes
114111
const getThemeClasses = (options: {
115112
light: string,
116113
dark: string,
@@ -899,7 +896,7 @@ export default function Home() {
899896
setParams({
900897
...params,
901898
animated: isChecked,
902-
striped: isChecked ? true : params.striped // Force striped to be true when animated is checked
899+
striped: isChecked ? true : params.striped
903900
});
904901
}}
905902
className={cn(
@@ -1025,7 +1022,6 @@ export default function Home() {
10251022
dark: "text-gray-400 hover:text-gray-200"
10261023
})
10271024
)}
1028-
onClick={() => setIframeKey(prev => prev + 1)}
10291025
aria-label="reload preview"
10301026
>
10311027
<RotateCw className="h-4 w-4" />
@@ -1065,8 +1061,7 @@ export default function Home() {
10651061
display: 'flex',
10661062
justifyContent: 'center'
10671063
}}>
1068-
<iframe
1069-
key={iframeKey}
1064+
<img
10701065
src={generateUrl()}
10711066
width={params.width}
10721067
height={params.height}

0 commit comments

Comments
 (0)