mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 19:25:24 +02:00
Improve experiment form UI - make it more compact
- Reduced modal max-width and padding - Changed from buttons to select dropdowns for Type/Marketplace - Smaller text sizes and spacing throughout - Shorter placeholder texts - More compact ASIN tags with max-height scroll - Reduced textarea rows - Smaller button labels Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
co-authored by
Qwen-Coder
parent
aebebecf1b
commit
9736a3d591
@@ -89,87 +89,73 @@ const ExperimentForm: React.FC<ExperimentFormProps> = ({
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 bg-black/60 backdrop-blur-sm z-50 flex items-center justify-center p-4">
|
||||
<div className="bg-slate-900 border border-slate-700 rounded-2xl w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col">
|
||||
<div className="bg-slate-900 border border-slate-700 rounded-2xl w-full max-w-3xl max-h-[85vh] overflow-hidden flex flex-col">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between p-6 border-b border-slate-700">
|
||||
<h2 className="text-xl font-bold text-white">🧪 Create New Experiment</h2>
|
||||
<div className="flex items-center justify-between p-4 border-b border-slate-700">
|
||||
<h2 className="text-lg font-bold text-white">🧪 New Experiment</h2>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="p-2 text-slate-400 hover:text-white hover:bg-slate-800 rounded-lg transition-colors"
|
||||
className="p-1.5 text-slate-400 hover:text-white hover:bg-slate-800 rounded-lg transition-colors"
|
||||
>
|
||||
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" strokeWidth={2} stroke="currentColor">
|
||||
<svg className="w-4 h-4" fill="none" viewBox="0 0 24 24" strokeWidth={2} stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Form */}
|
||||
<form onSubmit={handleSubmit} className="flex-1 overflow-y-auto p-6 space-y-6">
|
||||
<form onSubmit={handleSubmit} className="flex-1 overflow-y-auto p-4 space-y-4">
|
||||
{/* Name */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-slate-300 mb-2">
|
||||
Experiment Name <span className="text-red-400">*</span>
|
||||
<label className="block text-xs font-medium text-slate-300 mb-1">
|
||||
Name <span className="text-red-400">*</span>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={formData.name}
|
||||
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-3 py-2 text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-3 py-1.5 text-sm text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
placeholder="e.g., Q1 Price Reduction Test"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Type */}
|
||||
{/* Type & Marketplace */}
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-slate-300 mb-2">
|
||||
Experiment Type <span className="text-red-400">*</span>
|
||||
<label className="block text-xs font-medium text-slate-300 mb-1">
|
||||
Type <span className="text-red-400">*</span>
|
||||
</label>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{typeOptions.map((opt) => (
|
||||
<button
|
||||
key={opt.value}
|
||||
type="button"
|
||||
onClick={() => setFormData({ ...formData, type: opt.value })}
|
||||
className={`p-3 rounded-lg border text-sm font-medium transition-colors flex items-center gap-2 ${
|
||||
formData.type === opt.value
|
||||
? 'bg-indigo-600/20 border-indigo-500 text-indigo-400'
|
||||
: 'bg-slate-800 border-slate-600 text-slate-400 hover:border-slate-500'
|
||||
}`}
|
||||
<select
|
||||
value={formData.type}
|
||||
onChange={(e) => setFormData({ ...formData, type: e.target.value as ExperimentType })}
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-3 py-1.5 text-sm text-white focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
>
|
||||
<span className="text-lg">{opt.icon}</span>
|
||||
{opt.label}
|
||||
</button>
|
||||
))}
|
||||
<option value="pricing">💰 Pricing</option>
|
||||
<option value="advertising">📢 Advertising</option>
|
||||
<option value="content">📝 Content</option>
|
||||
<option value="promotion">🏷️ Promotion</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Marketplace */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-slate-300 mb-2">
|
||||
<label className="block text-xs font-medium text-slate-300 mb-1">
|
||||
Marketplace <span className="text-red-400">*</span>
|
||||
</label>
|
||||
<div className="flex gap-2">
|
||||
{marketplaceOptions.map((mp) => (
|
||||
<button
|
||||
key={mp}
|
||||
type="button"
|
||||
onClick={() => setFormData({ ...formData, marketplace: mp })}
|
||||
className={`px-4 py-2 rounded-lg border text-sm font-medium transition-colors ${
|
||||
formData.marketplace === mp
|
||||
? 'bg-indigo-600/20 border-indigo-500 text-indigo-400'
|
||||
: 'bg-slate-800 border-slate-600 text-slate-400 hover:border-slate-500'
|
||||
}`}
|
||||
<select
|
||||
value={formData.marketplace}
|
||||
onChange={(e) => setFormData({ ...formData, marketplace: e.target.value })}
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-3 py-1.5 text-sm text-white focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
>
|
||||
{mp}
|
||||
</button>
|
||||
{marketplaceOptions.map((mp) => (
|
||||
<option key={mp} value={mp}>{mp}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ASINs */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-slate-300 mb-2">
|
||||
<label className="block text-xs font-medium text-slate-300 mb-1">
|
||||
Target ASINs <span className="text-red-400">*</span>
|
||||
</label>
|
||||
<div className="flex gap-2 mb-2">
|
||||
@@ -178,23 +164,23 @@ const ExperimentForm: React.FC<ExperimentFormProps> = ({
|
||||
value={asinInput}
|
||||
onChange={(e) => setAsinInput(e.target.value)}
|
||||
onKeyPress={(e) => e.key === 'Enter' && (e.preventDefault(), handleAddAsin())}
|
||||
className="flex-1 bg-slate-800 border border-slate-600 rounded-lg px-3 py-2 text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
placeholder="Enter ASINs (comma-separated)"
|
||||
className="flex-1 bg-slate-800 border border-slate-600 rounded-lg px-3 py-1.5 text-sm text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
placeholder="ASINs (comma-separated)"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleAddAsin}
|
||||
className="px-4 py-2 bg-slate-700 hover:bg-slate-600 text-white rounded-lg transition-colors"
|
||||
className="px-3 py-1.5 bg-slate-700 hover:bg-slate-600 text-white rounded-lg text-sm transition-colors"
|
||||
>
|
||||
Add
|
||||
</button>
|
||||
</div>
|
||||
{formData.asins.length > 0 && (
|
||||
<div className="flex flex-wrap gap-2 p-3 bg-slate-800/50 border border-slate-700 rounded-lg">
|
||||
<div className="flex flex-wrap gap-1.5 p-2 bg-slate-800/50 border border-slate-700 rounded-lg max-h-20 overflow-y-auto">
|
||||
{formData.asins.map((asin) => (
|
||||
<span
|
||||
key={asin}
|
||||
className="inline-flex items-center gap-1 px-2.5 py-1 bg-slate-700 border border-slate-600 rounded-lg text-sm text-slate-300 font-mono"
|
||||
className="inline-flex items-center gap-1 px-2 py-1 bg-slate-700 border border-slate-600 rounded text-xs text-slate-300 font-mono"
|
||||
>
|
||||
{asin}
|
||||
<button
|
||||
@@ -202,7 +188,7 @@ const ExperimentForm: React.FC<ExperimentFormProps> = ({
|
||||
onClick={() => handleRemoveAsin(asin)}
|
||||
className="text-slate-400 hover:text-red-400 transition-colors"
|
||||
>
|
||||
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" strokeWidth={2} stroke="currentColor">
|
||||
<svg className="w-3 h-3" fill="none" viewBox="0 0 24 24" strokeWidth={2} stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
@@ -215,54 +201,54 @@ const ExperimentForm: React.FC<ExperimentFormProps> = ({
|
||||
{/* Timeline */}
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-slate-300 mb-2">
|
||||
<label className="block text-xs font-medium text-slate-300 mb-1">
|
||||
Start Date <span className="text-red-400">*</span>
|
||||
</label>
|
||||
<input
|
||||
type="date"
|
||||
value={formData.start_date}
|
||||
onChange={(e) => setFormData({ ...formData, start_date: e.target.value })}
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-2 py-1.5 text-sm text-white focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-slate-300 mb-2">
|
||||
<label className="block text-xs font-medium text-slate-300 mb-1">
|
||||
End Date
|
||||
</label>
|
||||
<input
|
||||
type="date"
|
||||
value={formData.end_date}
|
||||
onChange={(e) => setFormData({ ...formData, end_date: e.target.value })}
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-2 py-1.5 text-sm text-white focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Hypothesis */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-slate-300 mb-2">
|
||||
<label className="block text-xs font-medium text-slate-300 mb-1">
|
||||
Hypothesis
|
||||
</label>
|
||||
<textarea
|
||||
value={formData.hypothesis}
|
||||
onChange={(e) => setFormData({ ...formData, hypothesis: e.target.value })}
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-3 py-2 text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
rows={3}
|
||||
placeholder="What do you expect to happen? e.g., 'Reducing price by 10% will increase units sold by 25%'"
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-3 py-1.5 text-sm text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 resize-none"
|
||||
rows={2}
|
||||
placeholder="What do you expect to happen?"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Primary Metric & Target Lift */}
|
||||
{/* Metric & Target */}
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-slate-300 mb-2">
|
||||
<label className="block text-xs font-medium text-slate-300 mb-1">
|
||||
Primary Metric
|
||||
</label>
|
||||
<select
|
||||
value={formData.primary_metric}
|
||||
onChange={(e) => setFormData({ ...formData, primary_metric: e.target.value as ExperimentMetric })}
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-2 py-1.5 text-sm text-white focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
>
|
||||
{metricOptions.map((opt) => (
|
||||
<option key={opt.value} value={opt.value}>{opt.label}</option>
|
||||
@@ -270,14 +256,14 @@ const ExperimentForm: React.FC<ExperimentFormProps> = ({
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-slate-300 mb-2">
|
||||
<label className="block text-xs font-medium text-slate-300 mb-1">
|
||||
Target Lift (%)
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
value={formData.target_lift_percent}
|
||||
onChange={(e) => setFormData({ ...formData, target_lift_percent: parseFloat(e.target.value) || 0 })}
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-2 py-1.5 text-sm text-white focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
min="0"
|
||||
max="1000"
|
||||
/>
|
||||
@@ -286,29 +272,29 @@ const ExperimentForm: React.FC<ExperimentFormProps> = ({
|
||||
|
||||
{/* Owner */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-slate-300 mb-2">
|
||||
<label className="block text-xs font-medium text-slate-300 mb-1">
|
||||
Owner
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={formData.owner}
|
||||
onChange={(e) => setFormData({ ...formData, owner: e.target.value })}
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-3 py-2 text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-3 py-1.5 text-sm text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
placeholder="Your name"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Description */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-slate-300 mb-2">
|
||||
<label className="block text-xs font-medium text-slate-300 mb-1">
|
||||
Description
|
||||
</label>
|
||||
<textarea
|
||||
value={formData.description}
|
||||
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-3 py-2 text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
rows={3}
|
||||
placeholder="Additional details about this experiment..."
|
||||
className="w-full bg-slate-800 border border-slate-600 rounded-lg px-3 py-1.5 text-sm text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 resize-none"
|
||||
rows={2}
|
||||
placeholder="Additional details..."
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -317,16 +303,16 @@ const ExperimentForm: React.FC<ExperimentFormProps> = ({
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="flex-1 px-4 py-2.5 bg-slate-800 hover:bg-slate-700 text-white rounded-lg font-medium transition-colors"
|
||||
className="flex-1 px-4 py-2 bg-slate-800 hover:bg-slate-700 text-white rounded-lg text-sm font-medium transition-colors"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
className="flex-1 px-4 py-2.5 bg-indigo-600 hover:bg-indigo-700 disabled:bg-indigo-600/50 text-white rounded-lg font-medium transition-colors"
|
||||
className="flex-1 px-4 py-2 bg-indigo-600 hover:bg-indigo-700 disabled:bg-indigo-600/50 text-white rounded-lg text-sm font-medium transition-colors"
|
||||
>
|
||||
{loading ? 'Creating...' : 'Create Experiment'}
|
||||
{loading ? 'Creating...' : 'Create'}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user