Update src/App.jsx
Browse files- src/App.jsx +135 -9
src/App.jsx
CHANGED
|
@@ -42,7 +42,8 @@ const QRGeneratorTab = ({
|
|
| 42 |
qrStyles.forEach((style, index) => {
|
| 43 |
const canvas = styleCanvasRefs.current[index];
|
| 44 |
// Use a generic sample for style previews, not actual content
|
| 45 |
-
|
|
|
|
| 46 |
});
|
| 47 |
}, [qrStyles, drawQrCode, styleCanvasRefs]);
|
| 48 |
|
|
@@ -144,7 +145,7 @@ const QRGeneratorTab = ({
|
|
| 144 |
{/* Right Panel: Style Selection */}
|
| 145 |
<div className={`w-full lg:w-1/4 p-6 rounded-2xl shadow-2xl border ${currentThemeClasses.glassBorder} ${currentThemeClasses.glassBg} ${currentThemeClasses.text} flex flex-col transform transition-all duration-500 ease-in-out`}>
|
| 146 |
<label className={`mb-4 font-semibold ${currentThemeClasses.labelColor} font-inter`}>Choose Style:</label>
|
| 147 |
-
<div className={`overflow-y-auto flex-grow rounded-xl p-2 ${currentThemeClasses.cardBg} custom-scrollbar`}>
|
| 148 |
<div className="grid grid-cols-2 gap-4">
|
| 149 |
{qrStyles.map((style, index) => (
|
| 150 |
<div
|
|
@@ -741,7 +742,7 @@ const App = () => {
|
|
| 741 |
"π§ββοΈπ‘ Stress Management Techniques",
|
| 742 |
"π§ββοΈβ¨ Mindfulness Exercises",
|
| 743 |
"π§ββοΈπ± Meditation Apps",
|
| 744 |
-
"π΄π‘ Sleep
|
| 745 |
"ππ Healthy Eating Guide",
|
| 746 |
"πͺποΈ Exercise Routines",
|
| 747 |
"ποΈββοΈπ Personal Trainer Contact",
|
|
@@ -876,7 +877,7 @@ const App = () => {
|
|
| 876 |
|
| 877 |
// Define QR code styles (remains in App as it's static data used by QRGeneratorTab)
|
| 878 |
const qrStyles = [
|
| 879 |
-
{ name: "Classic", fg: "#
|
| 880 |
{ name: "Neon Green", fg: "#39FF14" }, // Vibrant Neon Green
|
| 881 |
{ name: "Electric Blue", fg: "#00BFFF" }, // Bright Sky Blue
|
| 882 |
{ name: "Radiant Pink", fg: "#FF007F" }, // Hot Pink
|
|
@@ -888,6 +889,126 @@ const App = () => {
|
|
| 888 |
{ name: "Lime Zing", fg: "#7FFF00" }, // Chartreuse
|
| 889 |
{ name: "Deep Teal", fg: "#008080" }, // Teal
|
| 890 |
{ name: "Violet Ray", fg: "#8A2BE2" }, // Blue-Violet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 891 |
];
|
| 892 |
|
| 893 |
// Define themes (remains in App)
|
|
@@ -1059,7 +1180,8 @@ const App = () => {
|
|
| 1059 |
};
|
| 1060 |
|
| 1061 |
// Callback to generate QR code on a given canvas
|
| 1062 |
-
|
|
|
|
| 1063 |
if (!canvas) {
|
| 1064 |
console.warn("Canvas element is null, cannot draw QR code.");
|
| 1065 |
return;
|
|
@@ -1077,13 +1199,16 @@ const App = () => {
|
|
| 1077 |
const context = canvas.getContext('2d');
|
| 1078 |
context.clearRect(0, 0, canvas.width, canvas.height);
|
| 1079 |
|
|
|
|
|
|
|
|
|
|
| 1080 |
if (text.trim() !== '') {
|
| 1081 |
QRCode.toCanvas(canvas, text, {
|
| 1082 |
errorCorrectionLevel: errorLevel,
|
| 1083 |
width: size,
|
| 1084 |
color: {
|
| 1085 |
dark: color,
|
| 1086 |
-
light:
|
| 1087 |
}
|
| 1088 |
}, function (error) {
|
| 1089 |
if (error) console.error("QR Code drawing error:", error);
|
|
@@ -1103,14 +1228,15 @@ const App = () => {
|
|
| 1103 |
tempCanvas.width = downloadResolution;
|
| 1104 |
tempCanvas.height = downloadResolution;
|
| 1105 |
|
| 1106 |
-
//
|
| 1107 |
-
|
|
|
|
| 1108 |
QRCode.toCanvas(tempCanvas, content, {
|
| 1109 |
errorCorrectionLevel: errorLevel,
|
| 1110 |
width: downloadResolution,
|
| 1111 |
color: {
|
| 1112 |
dark: qrColor,
|
| 1113 |
-
light:
|
| 1114 |
}
|
| 1115 |
}, function (error) {
|
| 1116 |
if (error) console.error("QR Code drawing error for download:", error);
|
|
|
|
| 42 |
qrStyles.forEach((style, index) => {
|
| 43 |
const canvas = styleCanvasRefs.current[index];
|
| 44 |
// Use a generic sample for style previews, not actual content
|
| 45 |
+
// For style previews, the 'light' color should always be black for contrast with the style's fg color
|
| 46 |
+
drawQrCode(canvas, "Sample", style.fg, 'H', 80, '#000000');
|
| 47 |
});
|
| 48 |
}, [qrStyles, drawQrCode, styleCanvasRefs]);
|
| 49 |
|
|
|
|
| 145 |
{/* Right Panel: Style Selection */}
|
| 146 |
<div className={`w-full lg:w-1/4 p-6 rounded-2xl shadow-2xl border ${currentThemeClasses.glassBorder} ${currentThemeClasses.glassBg} ${currentThemeClasses.text} flex flex-col transform transition-all duration-500 ease-in-out`}>
|
| 147 |
<label className={`mb-4 font-semibold ${currentThemeClasses.labelColor} font-inter`}>Choose Style:</label>
|
| 148 |
+
<div className={`overflow-y-auto flex-grow rounded-xl p-2 ${currentThemeClasses.cardBg} custom-scrollbar max-h-[600px] lg:max-h-full`}> {/* Added max-h for explicit scrolling */}
|
| 149 |
<div className="grid grid-cols-2 gap-4">
|
| 150 |
{qrStyles.map((style, index) => (
|
| 151 |
<div
|
|
|
|
| 742 |
"π§ββοΈπ‘ Stress Management Techniques",
|
| 743 |
"π§ββοΈβ¨ Mindfulness Exercises",
|
| 744 |
"π§ββοΈπ± Meditation Apps",
|
| 745 |
+
"π΄π‘ Sleep Hygiene Tips",
|
| 746 |
"ππ Healthy Eating Guide",
|
| 747 |
"πͺποΈ Exercise Routines",
|
| 748 |
"ποΈββοΈπ Personal Trainer Contact",
|
|
|
|
| 877 |
|
| 878 |
// Define QR code styles (remains in App as it's static data used by QRGeneratorTab)
|
| 879 |
const qrStyles = [
|
| 880 |
+
{ name: "Classic", fg: "#FFFFFF" }, // Changed to white for visibility
|
| 881 |
{ name: "Neon Green", fg: "#39FF14" }, // Vibrant Neon Green
|
| 882 |
{ name: "Electric Blue", fg: "#00BFFF" }, // Bright Sky Blue
|
| 883 |
{ name: "Radiant Pink", fg: "#FF007F" }, // Hot Pink
|
|
|
|
| 889 |
{ name: "Lime Zing", fg: "#7FFF00" }, // Chartreuse
|
| 890 |
{ name: "Deep Teal", fg: "#008080" }, // Teal
|
| 891 |
{ name: "Violet Ray", fg: "#8A2BE2" }, // Blue-Violet
|
| 892 |
+
{ name: "Emerald", fg: "#00C957" }, // Deep Green
|
| 893 |
+
{ name: "Sapphire", fg: "#082567" }, // Deep Blue
|
| 894 |
+
{ name: "Ruby", fg: "#E0115F" }, // Deep Red
|
| 895 |
+
{ name: "Amethyst", fg: "#9966CC" }, // Medium Purple
|
| 896 |
+
{ name: "Sunshine", fg: "#FFD300" }, // Bright Yellow
|
| 897 |
+
{ name: "Ocean Wave", fg: "#007FFF" }, // Medium Blue
|
| 898 |
+
{ name: "Forest Mist", fg: "#A8C3BC" }, // Light Greenish-Gray
|
| 899 |
+
{ name: "Crimson Tide", fg: "#DC143C" }, // Crimson
|
| 900 |
+
{ name: "Midnight Blue", fg: "#191970" }, // Dark Blue
|
| 901 |
+
{ name: "Rose Gold", fg: "#B76E79" }, // Rose Gold
|
| 902 |
+
{ name: "Spring Green", fg: "#00FF7F" }, // Spring Green
|
| 903 |
+
{ name: "Royal Purple", fg: "#7851A9" }, // Royal Purple
|
| 904 |
+
{ name: "Azure", fg: "#007FFF" }, // Azure Blue
|
| 905 |
+
{ name: "Coral", fg: "#FF7F50" }, // Coral Orange
|
| 906 |
+
{ name: "Mint Green", fg: "#98FF98" }, // Light Mint Green
|
| 907 |
+
{ name: "Lavender", fg: "#E6E6FA" }, // Light Lavender
|
| 908 |
+
{ name: "Chocolate", fg: "#D2691E" }, // Chocolate Brown
|
| 909 |
+
{ name: "Silver", fg: "#C0C0C0" }, // Silver
|
| 910 |
+
{ name: "Bronze", fg: "#CD7F32" }, // Bronze
|
| 911 |
+
{ name: "Copper", fg: "#B87333" }, // Copper
|
| 912 |
+
{ name: "Plum", fg: "#8E4585" }, // Plum Purple
|
| 913 |
+
{ name: "Olive", fg: "#808000" }, // Olive Green
|
| 914 |
+
{ name: "Maroon", fg: "#800000" }, // Maroon Red
|
| 915 |
+
{ name: "Teal Blue", fg: "#367588" }, // Teal Blue
|
| 916 |
+
{ name: "Sky Blue", fg: "#87CEEB" }, // Sky Blue
|
| 917 |
+
{ name: "Slate Gray", fg: "#708090" }, // Slate Gray
|
| 918 |
+
{ name: "Dark Green", fg: "#006400" }, // Dark Green
|
| 919 |
+
{ name: "Dark Red", fg: "#8B0000" }, // Dark Red
|
| 920 |
+
{ name: "Dark Blue", fg: "#00008B" }, // Dark Blue
|
| 921 |
+
{ name: "Dark Cyan", fg: "#008B8B" }, // Dark Cyan
|
| 922 |
+
{ name: "Dark Magenta", fg: "#8B008B" }, // Dark Magenta
|
| 923 |
+
{ name: "Dark Yellow", fg: "#8B8B00" }, // Dark Yellow
|
| 924 |
+
{ name: "Light Gray", fg: "#D3D3D3" }, // Light Gray
|
| 925 |
+
{ name: "Light Blue", fg: "#ADD8E6" }, // Light Blue
|
| 926 |
+
{ name: "Light Green", fg: "#90EE90" }, // Light Green
|
| 927 |
+
{ name: "Light Pink", fg: "#FFB6C1" }, // Light Pink
|
| 928 |
+
{ name: "Light Yellow", fg: "#FFFFE0" }, // Light Yellow
|
| 929 |
+
{ name: "Pale Green", fg: "#98FB98" }, // Pale Green
|
| 930 |
+
{ name: "Pale Blue", fg: "#AFEEEE" }, // Pale Blue
|
| 931 |
+
{ name: "Pale Red", fg: "#F08080" }, // Pale Red
|
| 932 |
+
{ name: "Pale Yellow", fg: "#FFFF99" }, // Pale Yellow
|
| 933 |
+
{ name: "Deep Orange", fg: "#FF6600" }, // Deep Orange
|
| 934 |
+
{ name: "Deep Pink", fg: "#FF1493" }, // Deep Pink
|
| 935 |
+
{ name: "Deep Purple", fg: "#800080" }, // Deep Purple
|
| 936 |
+
{ name: "Deep Sky Blue", fg: "#00BFFF" }, // Deep Sky Blue
|
| 937 |
+
{ name: "Medium Sea Green", fg: "#3CB371" }, // Medium Sea Green
|
| 938 |
+
{ name: "Medium Slate Blue", fg: "#7B68EE" }, // Medium Slate Blue
|
| 939 |
+
{ name: "Medium Spring Green", fg: "#00FA9A" }, // Medium Spring Green
|
| 940 |
+
{ name: "Medium Turquoise", fg: "#48D1CC" }, // Medium Turquoise
|
| 941 |
+
{ name: "Medium Violet Red", fg: "#C71585" }, // Medium Violet Red
|
| 942 |
+
{ name: "Dark Goldenrod", fg: "#B8860B" }, // Dark Goldenrod
|
| 943 |
+
{ name: "Dark Orchid", fg: "#9932CC" }, // Dark Orchid
|
| 944 |
+
{ name: "Dark Salmon", fg: "#E9967A" }, // Dark Salmon
|
| 945 |
+
{ name: "Dark Sea Green", fg: "#8FBC8F" }, // Dark Sea Green
|
| 946 |
+
{ name: "Dark Slate Blue", fg: "#483D8B" }, // Dark Slate Blue
|
| 947 |
+
{ name: "Dark Slate Gray", fg: "#2F4F4F" }, // Dark Slate Gray
|
| 948 |
+
{ name: "Dark Turquoise", fg: "#00CED1" }, // Dark Turquoise
|
| 949 |
+
{ name: "Dark Violet", fg: "#9400D3" }, // Dark Violet
|
| 950 |
+
{ name: "Light Coral", fg: "#F08080" }, // Light Coral
|
| 951 |
+
{ name: "Light Cyan", fg: "#E0FFFF" }, // Light Cyan
|
| 952 |
+
{ name: "Light Goldenrod Yellow", fg: "#FAFAD2" }, // Light Goldenrod Yellow
|
| 953 |
+
{ name: "Light Green", fg: "#90EE90" }, // Light Green
|
| 954 |
+
{ name: "Light Pink", fg: "#FFB6C1" }, // Light Pink
|
| 955 |
+
{ name: "Light Salmon", fg: "#FFA07A" }, // Light Salmon
|
| 956 |
+
{ name: "Light Sea Green", fg: "#20B2AA" }, // Light Sea Green
|
| 957 |
+
{ name: "Light Sky Blue", fg: "#87CEFA" }, // Light Sky Blue
|
| 958 |
+
{ name: "Light Slate Gray", fg: "#778899" }, // Light Slate Gray
|
| 959 |
+
{ name: "Light Steel Blue", fg: "#B0C4DE" }, // Light Steel Blue
|
| 960 |
+
{ name: "Light Yellow", fg: "#FFFFE0" }, // Light Yellow
|
| 961 |
+
{ name: "Hot Pink", fg: "#FF69B4" }, // Hot Pink
|
| 962 |
+
{ name: "Indian Red", fg: "#CD5C5C" }, // Indian Red
|
| 963 |
+
{ name: "Indigo", fg: "#4B0082" }, // Indigo
|
| 964 |
+
{ name: "Khaki", fg: "#F0E68C" }, // Khaki
|
| 965 |
+
{ name: "Lavender Blush", fg: "#FFF0F5" }, // Lavender Blush
|
| 966 |
+
{ name: "Lemon Chiffon", fg: "#FFFACD" }, // Lemon Chiffon
|
| 967 |
+
{ name: "Lime Green", fg: "#32CD32" }, // Lime Green
|
| 968 |
+
{ name: "Linen", fg: "#FAF0E6" }, // Linen
|
| 969 |
+
{ name: "Medium Aqua Marine", fg: "#66CDAA" }, // Medium Aqua Marine
|
| 970 |
+
{ name: "Medium Blue", fg: "#0000CD" }, // Medium Blue
|
| 971 |
+
{ name: "Medium Orchid", fg: "#BA55D3" }, // Medium Orchid
|
| 972 |
+
{ name: "Medium Purple", fg: "#9370DB" }, // Medium Purple
|
| 973 |
+
{ name: "Medium Violet Red", fg: "#C71585" }, // Medium Violet Red
|
| 974 |
+
{ name: "Misty Rose", fg: "#FFE4E1" }, // Misty Rose
|
| 975 |
+
{ name: "Moccasin", fg: "#FFE4B5" }, // Moccasin
|
| 976 |
+
{ name: "Navajo White", fg: "#FFDEAD" }, // Navajo White
|
| 977 |
+
{ name: "Old Lace", fg: "#FDF5E6" }, // Old Lace
|
| 978 |
+
{ name: "Olive Drab", fg: "#6B8E23" }, // Olive Drab
|
| 979 |
+
{ name: "Orange Red", fg: "#FF4500" }, // Orange Red
|
| 980 |
+
{ name: "Orchid", fg: "#DA70D6" }, // Orchid
|
| 981 |
+
{ name: "Pale Goldenrod", fg: "#EEE8AA" }, // Pale Goldenrod
|
| 982 |
+
{ name: "Pale Turquoise", fg: "#AFEEEE" }, // Pale Turquoise
|
| 983 |
+
{ name: "Pale Violet Red", fg: "#DB7093" }, // Pale Violet Red
|
| 984 |
+
{ name: "Papaya Whip", fg: "#FFEFD5" }, // Papaya Whip
|
| 985 |
+
{ name: "Peach Puff", fg: "#FFDAB9" }, // Peach Puff
|
| 986 |
+
{ name: "Peru", fg: "#CD853F" }, // Peru
|
| 987 |
+
{ name: "Pink", fg: "#FFC0CB" }, // Pink
|
| 988 |
+
{ name: "Plum", fg: "#DDA0DD" }, // Plum
|
| 989 |
+
{ name: "Powder Blue", fg: "#B0E0E6" }, // Powder Blue
|
| 990 |
+
{ name: "Rosy Brown", fg: "#BC8F8F" }, // Rosy Brown
|
| 991 |
+
{ name: "Royal Blue", fg: "#4169E1" }, // Royal Blue
|
| 992 |
+
{ name: "Saddle Brown", fg: "#8B4513" }, // Saddle Brown
|
| 993 |
+
{ name: "Salmon", fg: "#FA8072" }, // Salmon
|
| 994 |
+
{ name: "Sandy Brown", fg: "#F4A460" }, // Sandy Brown
|
| 995 |
+
{ name: "Sea Green", fg: "#2E8B57" }, // Sea Green
|
| 996 |
+
{ name: "Sea Shell", fg: "#FFF5EE" }, // Sea Shell
|
| 997 |
+
{ name: "Sienna", fg: "#A0522D" }, // Sienna
|
| 998 |
+
{ name: "Sky Blue", fg: "#87CEEB" }, // Sky Blue
|
| 999 |
+
{ name: "Slate Blue", fg: "#6A5ACD" }, // Slate Blue
|
| 1000 |
+
{ name: "Slate Gray", fg: "#708090" }, // Slate Gray
|
| 1001 |
+
{ name: "Snow", fg: "#FFFAFA" }, // Snow
|
| 1002 |
+
{ name: "Spring Green", fg: "#00FF7F" }, // Spring Green
|
| 1003 |
+
{ name: "Steel Blue", fg: "#4682B4" }, // Steel Blue
|
| 1004 |
+
{ name: "Tan", fg: "#D2B48C" }, // Tan
|
| 1005 |
+
{ name: "Thistle", fg: "#D8BFD8" }, // Thistle
|
| 1006 |
+
{ name: "Tomato", fg: "#FF6347" }, // Tomato
|
| 1007 |
+
{ name: "Turquoise", fg: "#40E0D0" }, // Turquoise
|
| 1008 |
+
{ name: "Violet", fg: "#EE82EE" }, // Violet
|
| 1009 |
+
{ name: "Wheat", fg: "#F5DEB3" }, // Wheat
|
| 1010 |
+
{ name: "White Smoke", fg: "#F5F5F5" }, // White Smoke
|
| 1011 |
+
{ name: "Yellow Green", fg: "#9ACD32" }, // Yellow Green
|
| 1012 |
];
|
| 1013 |
|
| 1014 |
// Define themes (remains in App)
|
|
|
|
| 1180 |
};
|
| 1181 |
|
| 1182 |
// Callback to generate QR code on a given canvas
|
| 1183 |
+
// Added a new parameter `lightColorOverride` to explicitly set the light module color
|
| 1184 |
+
const drawQrCode = useCallback((canvas, text, color, errorLevel, size = 256, lightColorOverride = null) => {
|
| 1185 |
if (!canvas) {
|
| 1186 |
console.warn("Canvas element is null, cannot draw QR code.");
|
| 1187 |
return;
|
|
|
|
| 1199 |
const context = canvas.getContext('2d');
|
| 1200 |
context.clearRect(0, 0, canvas.width, canvas.height);
|
| 1201 |
|
| 1202 |
+
// Determine the light module color: white if QR color is black, otherwise black
|
| 1203 |
+
const effectiveLightColor = lightColorOverride || (color === '#000000' ? '#FFFFFF' : '#000000');
|
| 1204 |
+
|
| 1205 |
if (text.trim() !== '') {
|
| 1206 |
QRCode.toCanvas(canvas, text, {
|
| 1207 |
errorCorrectionLevel: errorLevel,
|
| 1208 |
width: size,
|
| 1209 |
color: {
|
| 1210 |
dark: color,
|
| 1211 |
+
light: effectiveLightColor // Use the determined light color
|
| 1212 |
}
|
| 1213 |
}, function (error) {
|
| 1214 |
if (error) console.error("QR Code drawing error:", error);
|
|
|
|
| 1228 |
tempCanvas.width = downloadResolution;
|
| 1229 |
tempCanvas.height = downloadResolution;
|
| 1230 |
|
| 1231 |
+
// Determine the light module color for download: white if QR color is black, otherwise black
|
| 1232 |
+
const effectiveLightColorForDownload = qrColor === '#000000' ? '#FFFFFF' : '#000000';
|
| 1233 |
+
|
| 1234 |
QRCode.toCanvas(tempCanvas, content, {
|
| 1235 |
errorCorrectionLevel: errorLevel,
|
| 1236 |
width: downloadResolution,
|
| 1237 |
color: {
|
| 1238 |
dark: qrColor,
|
| 1239 |
+
light: effectiveLightColorForDownload // Use the determined light color for download
|
| 1240 |
}
|
| 1241 |
}, function (error) {
|
| 1242 |
if (error) console.error("QR Code drawing error for download:", error);
|