Skip to content

Commit a66a3b1

Browse files
Update colorPlotter.js
1 parent 2c889cd commit a66a3b1

File tree

1 file changed

+84
-96
lines changed

1 file changed

+84
-96
lines changed

colorPlotter.js

Lines changed: 84 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// colorPlotter.js
2-
const { useState } = React;
32

4-
// Basic UI components since we don't have access to shadcn/ui
3+
const { useState, useEffect } = React;
4+
5+
// Reusable Components
56
const Card = ({ children, className = '' }) => (
67
<div className={`border rounded-lg shadow ${className}`}>{children}</div>
78
);
@@ -20,20 +21,21 @@ const Button = ({ children, type = 'button', variant = 'primary', onClick }) =>
2021
onClick={onClick}
2122
className={`px-4 py-2 rounded ${
2223
variant === 'primary'
23-
? 'bg-blue-500 text-white'
24+
? 'bg-brown-600 text-white'
2425
: 'border border-gray-300'
2526
}`}
2627
>
2728
{children}
2829
</button>
2930
);
3031

31-
const Input = ({ value, onChange, placeholder }) => (
32+
const Input = ({ value, onChange, placeholder, dataColor }) => (
3233
<input
3334
type="text"
3435
value={value}
3536
onChange={onChange}
3637
placeholder={placeholder}
38+
data-color={dataColor}
3739
className="w-full px-3 py-2 border rounded"
3840
/>
3941
);
@@ -44,7 +46,7 @@ const Select = ({ value, onChange, options }) => (
4446
onChange={onChange}
4547
className="w-full px-3 py-2 border rounded"
4648
>
47-
<option value="">Choose a pathway (optional)</option>
49+
<option value="">Choose a pathway...</option>
4850
{options.map(option => (
4951
<option key={option} value={option}>
5052
{option.charAt(0).toUpperCase() + option.slice(1)}
@@ -53,17 +55,21 @@ const Select = ({ value, onChange, options }) => (
5355
</select>
5456
);
5557

58+
// Color + GNH Data
5659
const colorData = [
57-
{ color: 'grey', rgb: [170,170,170], direction: 'respectful effective apposite precary' },
58-
{ color: 'pink', rgb: [250,0,90], direction: 'incredibily exquisite and ambitious' },
59-
{ color: 'gold', rgb: [250,200,0], direction: 'undepartable preflorating technocracy lotiform' },
60-
{ color: 'nude', rgb: [250,180,120], direction: 'felicitously deft satisfied unextenuable' },
61-
{ color: 'orange', rgb: [250,110,0], direction: 'blurry artesian awesome' },
62-
{ color: 'white', rgb: [255,255,255], direction: 'unlavish analeptical' },
63-
{ color: 'blue', rgb: [0,0,255], direction: 'daintily perfect, intelligent photopathy' },
64-
{ color: 'green', rgb: [0,255,0], direction: 'bulbous spontaneous heroic' },
65-
{ color: 'red', rgb: [255,0,0], direction: 'candid apophantic, distinct and radiant' },
66-
{ color: 'black', rgb: [0,0,0], direction: 'undertreated paleoatavistic obeyable swabble' },
60+
{ color: 'grey', rgb: [170,170,170], gnh: 'Economic Wellness' },
61+
{ color: 'pink', rgb: [250,0,90], gnh: 'Mental Wellness' },
62+
{ color: 'gold', rgb: [250,200,0], gnh: 'Workplace Wellness' },
63+
{ color: 'nude', rgb: [250,180,120], gnh: 'Physical Wellness' },
64+
{ color: 'orange', rgb: [250,110,0], gnh: 'Social Wellness' },
65+
{ color: 'white', rgb: [255,255,255], gnh: 'Political Wellness' },
66+
{ color: 'blue', rgb: [0,0,255], gnh: 'Environmental Wellness' },
67+
{ color: 'green', rgb: [0,255,0], gnh: 'Ecological Diversity' },
68+
{ color: 'red', rgb: [255,0,0], gnh: 'Health' },
69+
{ color: 'black', rgb: [0,0,0], gnh: 'Good Governance' },
70+
{ color: 'brown', rgb: [180,50,0], gnh: 'Education Value' },
71+
{ color: 'yellow', rgb: [255,255,0], gnh: 'Living Standards' },
72+
{ color: 'purple', rgb: [180,50,255], gnh: 'Cultural Diversity' }
6773
];
6874

6975
const pathways = {
@@ -75,7 +81,7 @@ const pathways = {
7581
precise: ['pink', 'black'],
7682
fem: ['brown', 'gold', 'orange', 'pink'],
7783
masc: ['red', 'blue', 'orange'],
78-
direct': ['red', 'orange'],
84+
direct: ['red', 'orange'],
7985
};
8086

8187
function ColorPlotter() {
@@ -90,102 +96,84 @@ function ColorPlotter() {
9096
resultText += `Pathway: ${pathway || '[no pathway selected]'}\n\n`;
9197
resultText += 'Color Interpretations:\n\n';
9298

93-
colorData.forEach(({ color, direction }) => {
94-
const userInput = colorInputs[color] || direction;
95-
resultText += `${color.toUpperCase()}:\n`;
96-
resultText += `Your interpretation: ${userInput}\n`;
97-
resultText += `Original direction: ${direction}\n\n`;
99+
(pathway && pathways[pathway] ? pathways[pathway] : colorData.map(cd => cd.color)).forEach(colorName => {
100+
const colorInfo = colorData.find(c => c.color === colorName);
101+
const userInput = colorInputs[colorName] || '';
102+
resultText += `${colorInfo.color.toUpperCase()}:\n`;
103+
resultText += `GNH Indicator: ${colorInfo.gnh}\n`;
104+
resultText += `Your interpretation: ${userInput || '[no input]'}\n\n`;
98105
});
99106

100-
if (pathway && pathways[pathway]) {
101-
resultText += `\nSelected pathway colors: ${pathways[pathway].join(', ')}`;
102-
}
103-
104107
setResults(resultText);
108+
109+
document.getElementById('results').classList.remove('hidden');
110+
document.getElementById('resultContent').innerText = resultText;
105111
};
106112

107-
return (
108-
<div className="max-w-4xl mx-auto p-4">
109-
<h1 className="text-2xl font-bold mb-2">The RGB Root Matrix Color Plotter</h1>
110-
<p className="text-sm mb-4">by Danielle Gauthier</p>
113+
const handleColorInputChange = (color) => (e) => {
114+
setColorInputs({ ...colorInputs, [color]: e.target.value });
115+
};
111116

112-
<Card className="mb-4">
113-
<CardHeader>Description</CardHeader>
114-
<CardContent>
115-
<p>This program is inspired by ecofeminist pluriverse and feminist perspectives on family-making and crafting. It is used for telepathic communication and poetic linguistic navigation programming.</p>
116-
</CardContent>
117-
</Card>
117+
const renderColorInputs = () => {
118+
const filteredColors = pathway && pathways[pathway]
119+
? pathways[pathway]
120+
: colorData.map(c => c.color);
121+
122+
return filteredColors.map(colorName => {
123+
const colorInfo = colorData.find(c => c.color === colorName);
118124

119-
<form onSubmit={handleSubmit} className="space-y-4">
120-
<div>
121-
<label className="block mb-2">Enter your obstacle (optional):</label>
125+
return (
126+
<div key={colorName}>
127+
<label className="block mb-1" title={`GNH: ${colorInfo.gnh}`}>
128+
{colorName.charAt(0).toUpperCase() + colorName.slice(1)} ({colorInfo.gnh})
129+
</label>
122130
<Input
123-
value={obstacle}
124-
onChange={(e) => setObstacle(e.target.value)}
125-
placeholder="e.g., fear, uncertainty, conflict..."
131+
value={colorInputs[colorName] || ''}
132+
onChange={handleColorInputChange(colorName)}
133+
placeholder={`Describe ${colorName} meaning`}
134+
dataColor={colorName}
126135
/>
127136
</div>
137+
);
138+
});
139+
};
128140

129-
<div>
130-
<label className="block mb-2">Select Pathway:</label>
131-
<Select
132-
value={pathway}
133-
onChange={(e) => setPathway(e.target.value)}
134-
options={Object.keys(pathways)}
135-
/>
136-
</div>
141+
return (
142+
<div className="max-w-4xl mx-auto p-4">
143+
<Card className="mb-4">
144+
<CardHeader>Color Plotter</CardHeader>
145+
<CardContent>
146+
<form onSubmit={handleSubmit} className="space-y-4">
147+
<div>
148+
<label className="block mb-2">Enter your obstacle:</label>
149+
<Input value={obstacle} onChange={(e) => setObstacle(e.target.value)} placeholder="Obstacle..." />
150+
</div>
137151

138-
<div className="space-y-4">
139-
{colorData.map(({ color, direction }) => (
140-
<div key={color} className="flex items-center space-x-4">
141-
<div
142-
className="w-8 h-8 rounded"
143-
style={{
144-
backgroundColor: `rgb(${colorData.find(c => c.color === color).rgb.join(',')})`,
145-
border: color === 'white' ? '1px solid black' : 'none'
146-
}}
152+
<div>
153+
<label className="block mb-2">Select Pathway:</label>
154+
<Select
155+
value={pathway}
156+
onChange={(e) => setPathway(e.target.value)}
157+
options={Object.keys(pathways)}
147158
/>
148-
<div className="flex-grow">
149-
<label className="block mb-1">
150-
{color.charAt(0).toUpperCase() + color.slice(1)}:
151-
</label>
152-
<Input
153-
value={colorInputs[color] || ''}
154-
onChange={(e) => setColorInputs({...colorInputs, [color]: e.target.value})}
155-
placeholder={direction}
156-
/>
157-
</div>
158159
</div>
159-
))}
160-
</div>
161160

162-
<div className="space-x-4">
163-
<Button type="submit">Expose</Button>
164-
<Button
165-
variant="secondary"
166-
onClick={() => {
167-
setObstacle('');
168-
setPathway('');
169-
setColorInputs({});
170-
setResults('');
171-
}}
172-
>
173-
Clear
174-
</Button>
175-
</div>
176-
</form>
177-
178-
{results && (
179-
<Card className="mt-4">
180-
<CardHeader>Results</CardHeader>
181-
<CardContent>
182-
<pre className="whitespace-pre-wrap">{results}</pre>
183-
</CardContent>
184-
</Card>
185-
)}
161+
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
162+
{renderColorInputs()}
163+
</div>
164+
165+
<Button type="submit">Generate</Button>
166+
</form>
167+
</CardContent>
168+
</Card>
169+
170+
<div id="results" className="hidden">
171+
<h2 className="font-bold mb-2">Results</h2>
172+
<pre id="resultContent" className="whitespace-pre-wrap bg-amber-100 p-4 rounded"></pre>
173+
</div>
186174
</div>
187175
);
188176
}
189177

190-
// Render the app
191-
ReactDOM.render(<ColorPlotter />, document.getElementById('root'));
178+
// Render the React app
179+
ReactDOM.render(<ColorPlotter />, document.getElementById('colorForm'));

0 commit comments

Comments
 (0)