summaryrefslogtreecommitdiff
path: root/src/components/InputPanel.tsx
blob: c4ad902ef436ae74524c5895fa0829a43f5b30c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import type { BrandInputs } from '../types';
import { TokenInput } from './TokenInput';

const TONE_SUGGESTIONS = ['minimal', 'technical', 'calm', 'bold', 'warm', 'dry', 'focused', 'sharp'];
const AVOID_SUGGESTIONS = ['buzzwords', 'hype', 'startup language', 'passive voice', 'corporate tone', 'exclamation points', 'superlatives'];

interface Props {
  inputs: BrandInputs;
  onChange: (inputs: BrandInputs) => void;
  onGenerate: () => void;
  isGenerating: boolean;
  generateLabel?: string;
}

export function InputPanel({ inputs, onChange, onGenerate, isGenerating, generateLabel }: Props) {
  const set = <K extends keyof BrandInputs>(key: K) =>
    (value: BrandInputs[K]) => onChange({ ...inputs, [key]: value });

  const handleKey = (e: React.KeyboardEvent) => {
    if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
      e.preventDefault();
      onGenerate();
    }
  };

  const canGenerate = inputs.name.trim().length > 0 && inputs.purpose.trim().length > 0;

  return (
    <div className="input-panel" onKeyDown={handleKey}>
      <div className="input-section">
        <div className="input-section-label">Project</div>
        <div className="field">
          <label className="field-label" htmlFor="f-name">Name</label>
          <input
            id="f-name"
            className="field-input"
            placeholder="e.g. Foundry"
            value={inputs.name}
            onChange={e => set('name')(e.target.value)}
          />
        </div>
        <div className="field">
          <label className="field-label" htmlFor="f-category">Category</label>
          <input
            id="f-category"
            className="field-input"
            placeholder="e.g. developer tool, design studio"
            value={inputs.category}
            onChange={e => set('category')(e.target.value)}
          />
        </div>
        <div className="field">
          <label className="field-label" htmlFor="f-purpose">One-line purpose</label>
          <input
            id="f-purpose"
            className="field-input"
            placeholder="e.g. deploy microservices without boilerplate"
            value={inputs.purpose}
            onChange={e => set('purpose')(e.target.value)}
          />
        </div>
        <div className="field">
          <label className="field-label" htmlFor="f-audience">Audience</label>
          <input
            id="f-audience"
            className="field-input"
            placeholder="e.g. backend engineers"
            value={inputs.audience}
            onChange={e => set('audience')(e.target.value)}
          />
        </div>
      </div>

      <div className="input-section">
        <div className="input-section-label">Voice</div>
        <div className="field">
          <TokenInput
            label="Tone attributes"
            values={inputs.tone}
            onChange={set('tone')}
            suggestions={TONE_SUGGESTIONS}
            placeholder="Add tone..."
          />
        </div>
        <div className="field" style={{ marginTop: 8 }}>
          <TokenInput
            label="Avoid"
            values={inputs.avoid}
            onChange={set('avoid')}
            suggestions={AVOID_SUGGESTIONS}
            placeholder="Add avoid..."
          />
        </div>
      </div>

      <div className="input-section">
        <div className="input-section-label">Notes</div>
        <div className="field">
          <label className="field-label sr-only" htmlFor="f-notes">Notes & constraints</label>
          <textarea
            id="f-notes"
            className="field-textarea"
            placeholder="Optional: constraints, context, inspirations, or anything the brand package should reflect."
            value={inputs.notes}
            onChange={e => set('notes')(e.target.value)}
            rows={4}
          />
        </div>
      </div>

      <div className="generate-area">
        <button
          className={`btn-generate${isGenerating ? ' generating' : ''}`}
          onClick={onGenerate}
          disabled={!isGenerating && !canGenerate}
          title={!canGenerate ? 'Enter a name and purpose to generate' : 'Generate brand package (⌘Enter)'}
        >
          {generateLabel ?? (isGenerating ? 'Generating…' : 'Generate brand package')}
        </button>
        {!canGenerate && (
          <div style={{ marginTop: 7, fontSize: 11, color: 'var(--text-4)', textAlign: 'center' }}>
            Name and purpose required
          </div>
        )}
        {canGenerate && !isGenerating && (
          <div style={{ marginTop: 7, fontSize: 11, color: 'var(--text-4)', textAlign: 'center' }}>
            ⌘ Enter to generate
          </div>
        )}
      </div>
    </div>
  );
}