@dytsou/intern-corner-scheduler 1.2.13 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,21 @@
1
- import { useState } from 'react';
1
+ import { useRef, useState } from 'react';
2
2
  import PairInput from './PairInput';
3
3
 
4
- function ScheduleForm({ onSubmit, loading }) {
4
+ function ScheduleForm({ onSubmit, onCancel, loading, cancelling }) {
5
5
  const [participants, setParticipants] = useState('');
6
6
  const [tables, setTables] = useState('');
7
7
  const [rounds, setRounds] = useState('');
8
8
  const [timeLimit, setTimeLimit] = useState(60);
9
9
  const [sameOncePairs, setSameOncePairs] = useState([]);
10
10
  const [neverTogetherPairs, setNeverTogetherPairs] = useState([]);
11
+ const nextPairId = useRef(0);
11
12
 
12
13
  const handleSubmit = (e) => {
13
14
  e.preventDefault();
14
15
 
15
- const participantsNum = parseInt(participants);
16
- const tablesNum = parseInt(tables);
17
- const roundsNum = parseInt(rounds);
16
+ const participantsNum = Number.parseInt(participants, 10);
17
+ const tablesNum = Number.parseInt(tables, 10);
18
+ const roundsNum = Number.parseInt(rounds, 10);
18
19
 
19
20
  // Validation
20
21
  if (tablesNum > participantsNum) {
@@ -51,11 +52,17 @@ function ScheduleForm({ onSubmit, loading }) {
51
52
  };
52
53
 
53
54
  const addSameOncePair = () => {
54
- setSameOncePairs([...sameOncePairs, { u: '', v: '' }]);
55
+ setSameOncePairs([
56
+ ...sameOncePairs,
57
+ { id: nextPairId.current++, u: '', v: '' },
58
+ ]);
55
59
  };
56
60
 
57
61
  const addNeverTogetherPair = () => {
58
- setNeverTogetherPairs([...neverTogetherPairs, { u: '', v: '' }]);
62
+ setNeverTogetherPairs([
63
+ ...neverTogetherPairs,
64
+ { id: nextPairId.current++, u: '', v: '' },
65
+ ]);
59
66
  };
60
67
 
61
68
  const updateSameOncePair = (index, field, value) => {
@@ -79,127 +86,189 @@ function ScheduleForm({ onSubmit, loading }) {
79
86
  };
80
87
 
81
88
  return (
82
- <section className="card" id="input-section">
83
- <h2>Schedule Parameters</h2>
89
+ <section className="card form-card" id="input-section">
90
+ <div className="section-heading">
91
+ <h2>Schedule Parameters</h2>
92
+ </div>
93
+ <p className="section-intro">
94
+ Choose your group size, tables, and rounds. Add anyone you want to bring
95
+ together or keep apart.
96
+ </p>
84
97
  <form
85
98
  id="schedule-form"
86
99
  onSubmit={handleSubmit}
87
100
  className={loading ? 'loading' : ''}
101
+ aria-busy={loading}
88
102
  >
89
- <div className="form-group">
90
- <label htmlFor="participants">Number of Participants</label>
91
- <input
92
- type="number"
93
- id="participants"
94
- name="participants"
95
- min="1"
96
- required
97
- value={participants}
98
- onChange={(e) => setParticipants(e.target.value)}
99
- />
100
- <small>Total number of participants (1..a)</small>
101
- </div>
102
-
103
- <div className="form-group">
104
- <label htmlFor="tables">Number of Tables</label>
105
- <input
106
- type="number"
107
- id="tables"
108
- name="tables"
109
- min="1"
110
- required
111
- value={tables}
112
- onChange={(e) => setTables(e.target.value)}
113
- />
114
- <small>
115
- Number of tables (1..b). Participants 1..b will be hosts.
116
- </small>
117
- </div>
118
-
119
- <div className="form-group">
120
- <label htmlFor="rounds">Number of Rounds</label>
121
- <input
122
- type="number"
123
- id="rounds"
124
- name="rounds"
125
- min="1"
126
- required
127
- value={rounds}
128
- onChange={(e) => setRounds(e.target.value)}
129
- />
130
- <small>Number of rounds to schedule</small>
131
- </div>
103
+ <div className="parameter-grid">
104
+ <div className="form-group">
105
+ <label htmlFor="participants">Number of Participants</label>
106
+ <input
107
+ type="number"
108
+ id="participants"
109
+ name="participants"
110
+ min="1"
111
+ required
112
+ aria-describedby="participants-help"
113
+ value={participants}
114
+ onChange={(e) => setParticipants(e.target.value)}
115
+ />
116
+ <small id="participants-help">
117
+ Total number of participants (1..a)
118
+ </small>
119
+ </div>
132
120
 
133
- <div className="form-group">
134
- <label htmlFor="time-limit">Time Limit (seconds)</label>
135
- <input
136
- type="number"
137
- id="time-limit"
138
- name="time-limit"
139
- min="1"
140
- max="300"
141
- value={timeLimit}
142
- onChange={(e) => setTimeLimit(parseInt(e.target.value))}
143
- />
144
- <small>Maximum time for the solver (1-300 seconds)</small>
145
- </div>
121
+ <div className="form-group">
122
+ <label htmlFor="tables">Number of Tables</label>
123
+ <input
124
+ type="number"
125
+ id="tables"
126
+ name="tables"
127
+ min="1"
128
+ required
129
+ aria-describedby="tables-help"
130
+ value={tables}
131
+ onChange={(e) => setTables(e.target.value)}
132
+ />
133
+ <small id="tables-help">
134
+ Number of tables (1..b). Participants 1..b will be hosts.
135
+ </small>
136
+ </div>
146
137
 
147
- <div className="form-group">
148
- <div className="pairs-header">
149
- <label>Same-Once Pairs</label>
150
- <button
151
- type="button"
152
- className="btn-secondary"
153
- onClick={addSameOncePair}
154
- >
155
- + Add Pair
156
- </button>
138
+ <div className="form-group">
139
+ <label htmlFor="rounds">Number of Rounds</label>
140
+ <input
141
+ type="number"
142
+ id="rounds"
143
+ name="rounds"
144
+ min="1"
145
+ required
146
+ aria-describedby="rounds-help"
147
+ value={rounds}
148
+ onChange={(e) => setRounds(e.target.value)}
149
+ />
150
+ <small id="rounds-help">Number of rounds to schedule</small>
157
151
  </div>
158
- <small>Pairs that should be seated together exactly once</small>
159
- <div className="pairs-container">
160
- {sameOncePairs.map((pair, index) => (
161
- <PairInput
162
- key={index}
163
- pair={pair}
164
- onChange={(field, value) =>
165
- updateSameOncePair(index, field, value)
166
- }
167
- onRemove={() => removeSameOncePair(index)}
168
- />
169
- ))}
152
+
153
+ <div className="form-group">
154
+ <label htmlFor="time-limit">Time Limit (seconds)</label>
155
+ <input
156
+ type="number"
157
+ id="time-limit"
158
+ name="time-limit"
159
+ min="1"
160
+ max="300"
161
+ aria-describedby="time-limit-help"
162
+ value={timeLimit}
163
+ onChange={(e) =>
164
+ setTimeLimit(Number.parseInt(e.target.value, 10))
165
+ }
166
+ />
167
+ <small id="time-limit-help">
168
+ Maximum time for the solver (1-300 seconds)
169
+ </small>
170
170
  </div>
171
171
  </div>
172
172
 
173
- <div className="form-group">
174
- <div className="pairs-header">
175
- <label>Never-Together Pairs</label>
176
- <button
177
- type="button"
178
- className="btn-secondary"
179
- onClick={addNeverTogetherPair}
180
- >
181
- + Add Pair
182
- </button>
183
- </div>
184
- <small>Pairs that must never be seated together</small>
185
- <div className="pairs-container">
186
- {neverTogetherPairs.map((pair, index) => (
187
- <PairInput
188
- key={index}
189
- pair={pair}
190
- onChange={(field, value) =>
191
- updateNeverTogetherPair(index, field, value)
192
- }
193
- onRemove={() => removeNeverTogetherPair(index)}
194
- />
195
- ))}
196
- </div>
173
+ <div className="pair-rules-grid">
174
+ <fieldset className="pair-rule">
175
+ <legend>Same-Once Pairs</legend>
176
+ <div className="pairs-header">
177
+ <span className="rule-caption">A connection to make once</span>
178
+ <button
179
+ type="button"
180
+ className="btn-secondary"
181
+ onClick={addSameOncePair}
182
+ >
183
+ + Add Pair
184
+ </button>
185
+ </div>
186
+ <small id="same-once-help">
187
+ These participants should share a table in one round.
188
+ </small>
189
+ <div className="pairs-container">
190
+ {sameOncePairs.map((pair, index) => (
191
+ <PairInput
192
+ key={pair.id}
193
+ pair={pair}
194
+ pairLabel={`Same-once pair ${index + 1}`}
195
+ helpId="same-once-help"
196
+ onChange={(field, value) =>
197
+ updateSameOncePair(index, field, value)
198
+ }
199
+ onRemove={() => removeSameOncePair(index)}
200
+ />
201
+ ))}
202
+ </div>
203
+ </fieldset>
204
+
205
+ <fieldset className="pair-rule">
206
+ <legend>Never-Together Pairs</legend>
207
+ <div className="pairs-header">
208
+ <span className="rule-caption">A combination to avoid</span>
209
+ <button
210
+ type="button"
211
+ className="btn-secondary"
212
+ onClick={addNeverTogetherPair}
213
+ >
214
+ + Add Pair
215
+ </button>
216
+ </div>
217
+ <small id="never-together-help">
218
+ Keep these participants at separate tables in every round.
219
+ </small>
220
+ <div className="pairs-container">
221
+ {neverTogetherPairs.map((pair, index) => (
222
+ <PairInput
223
+ key={pair.id}
224
+ pair={pair}
225
+ pairLabel={`Never-together pair ${index + 1}`}
226
+ helpId="never-together-help"
227
+ onChange={(field, value) =>
228
+ updateNeverTogetherPair(index, field, value)
229
+ }
230
+ onRemove={() => removeNeverTogetherPair(index)}
231
+ />
232
+ ))}
233
+ </div>
234
+ </fieldset>
197
235
  </div>
198
236
 
199
- <button type="submit" className="btn-primary" disabled={loading}>
200
- {loading ? 'Generating...' : 'Generate Schedule'}
237
+ <button
238
+ type="submit"
239
+ className="btn-primary"
240
+ disabled={loading}
241
+ aria-busy={loading}
242
+ >
243
+ <span className="button-label">
244
+ {loading && (
245
+ <progress
246
+ className="button-spinner"
247
+ aria-label="Generating schedule"
248
+ />
249
+ )}
250
+ <span>
251
+ {loading ? 'Generating schedule…' : 'Generate Schedule'}
252
+ </span>
253
+ </span>
254
+ <span className="button-arrow" aria-hidden="true">
255
+ {loading ? '⋯' : '↗'}
256
+ </span>
201
257
  </button>
202
258
  </form>
259
+ {loading && (
260
+ <button
261
+ id="cancel-solve"
262
+ type="button"
263
+ className="btn-secondary cancel-solve-button"
264
+ onClick={onCancel}
265
+ disabled={cancelling}
266
+ aria-controls="schedule-form"
267
+ aria-label={cancelling ? 'Stopping solver' : undefined}
268
+ >
269
+ {cancelling ? 'Stopping solver…' : 'Cancel schedule generation'}
270
+ </button>
271
+ )}
203
272
  </section>
204
273
  );
205
274
  }
@@ -7,7 +7,13 @@ function TableAssignments({ schedule, currentRound }) {
7
7
  <h3 className="round-title">Round {currentRound + 1}</h3>
8
8
  <div className="tables-grid">
9
9
  {roundAssignments.map((table, tableIndex) => (
10
- <div key={tableIndex} className="table-card">
10
+ <div
11
+ key={table
12
+ .slice()
13
+ .sort((left, right) => left - right)
14
+ .join('-')}
15
+ className="table-card"
16
+ >
11
17
  <div className="table-header">
12
18
  <span className="table-number">Table {tableIndex + 1}</span>
13
19
  <span className="table-size">
package/src/index.css CHANGED
@@ -1,38 +1,165 @@
1
- /* Modern CSS Reset and Base Styles */
1
+ :root {
2
+ color-scheme: light;
3
+ font-synthesis: none;
4
+ text-rendering: optimizeLegibility;
5
+ -webkit-font-smoothing: antialiased;
6
+
7
+ --paper: #f4f6ff;
8
+ --sheet: #ffffff;
9
+ --surface: #f8f9ff;
10
+ --input: #fbfcff;
11
+ --ink: #27334d;
12
+ --muted: #596780;
13
+ --line: #e0e5f1;
14
+ --line-strong: #c5cee0;
15
+ --accent: #5369dc;
16
+ --accent-hover: #4358c5;
17
+ --accent-ink: #3348ad;
18
+ --accent-soft: #edf0ff;
19
+ --accent-line: #d8defb;
20
+ --accent-ring: rgb(83 105 220 / 20%);
21
+ --accent-shadow: rgb(83 105 220 / 23%);
22
+ --coral: #e86e7b;
23
+ --coral-soft: #fff0f2;
24
+ --coral-line: #f5d3d8;
25
+ --danger: #ad4050;
26
+ --danger-ink: #963746;
27
+ --lavender: #8372d5;
28
+ --lavender-ink: #5c4eaa;
29
+ --lavender-soft: #f1efff;
30
+ --lavender-line: #dfdaf8;
31
+ --mint: #39977f;
32
+ --mint-ink: #277760;
33
+ --mint-soft: #e7f6f1;
34
+ --mint-line: #c8e8dd;
35
+ --gold-ink: #795417;
36
+ --gold-soft: #fff5df;
37
+ --gold-line: #f1dfb8;
38
+ --shadow: 0 14px 38px rgb(49 63 105 / 8%);
39
+ --shadow-small: 0 6px 18px rgb(49 63 105 / 7%);
40
+ }
41
+
2
42
  * {
3
- margin: 0;
4
- padding: 0;
5
43
  box-sizing: border-box;
6
44
  }
7
45
 
8
- :root {
9
- --primary-color: #2563eb;
10
- --primary-hover: #1d4ed8;
11
- --secondary-color: #64748b;
12
- --success-color: #10b981;
13
- --danger-color: #ef4444;
14
- --warning-color: #f59e0b;
15
- --bg-color: #f8fafc;
16
- --card-bg: #ffffff;
17
- --text-primary: #1e293b;
18
- --text-secondary: #64748b;
19
- --border-color: #e2e8f0;
20
- --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
21
- --shadow-lg:
22
- 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
23
- --border-radius: 8px;
24
- --transition: all 0.2s ease;
46
+ html {
47
+ min-width: 320px;
48
+ scroll-behavior: smooth;
25
49
  }
26
50
 
27
51
  body {
28
- font-family:
29
- -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
30
- Arial, sans-serif;
31
- background-color: var(--bg-color);
32
- color: var(--text-primary);
33
- line-height: 1.6;
52
+ min-width: 320px;
53
+ min-height: 100vh;
54
+ margin: 0;
55
+ color: var(--ink);
56
+ background:
57
+ radial-gradient(circle at 92% 7%, rgb(131 114 213 / 8%), transparent 23rem),
58
+ var(--paper);
59
+ font-family: Inter, 'Avenir Next', 'Segoe UI', 'Trebuchet MS', sans-serif;
60
+ font-size: 1rem;
61
+ line-height: 1.55;
62
+ }
63
+
64
+ button,
65
+ input {
66
+ font: inherit;
67
+ }
68
+
69
+ button {
70
+ color: inherit;
71
+ }
72
+
73
+ button:focus-visible,
74
+ a:focus-visible,
75
+ input:focus-visible {
76
+ outline: 3px solid var(--lavender);
77
+ outline-offset: 3px;
78
+ }
79
+
80
+ ::selection {
81
+ color: white;
82
+ background: var(--accent);
34
83
  }
35
84
 
36
85
  #root {
37
86
  min-height: 100vh;
38
87
  }
88
+
89
+ @media (prefers-color-scheme: dark) {
90
+ :root {
91
+ color-scheme: dark;
92
+ --paper: #171c2b;
93
+ --sheet: #222a3c;
94
+ --surface: #273047;
95
+ --input: #20283a;
96
+ --ink: #f2f4ff;
97
+ --muted: #c1c9dc;
98
+ --line: #3b4660;
99
+ --line-strong: #58647d;
100
+ --accent: #91a2ff;
101
+ --accent-hover: #a9b6ff;
102
+ --accent-ink: #d4daff;
103
+ --accent-soft: #2b3453;
104
+ --accent-line: #414d77;
105
+ --accent-ring: rgb(145 162 255 / 25%);
106
+ --accent-shadow: rgb(83 105 220 / 20%);
107
+ --coral: #f18a96;
108
+ --coral-soft: #422d3a;
109
+ --coral-line: #67404b;
110
+ --danger: #f08b9a;
111
+ --danger-ink: #ffc4cd;
112
+ --lavender: #b2a5ff;
113
+ --lavender-ink: #d5ccff;
114
+ --lavender-soft: #332f50;
115
+ --lavender-line: #514979;
116
+ --mint: #70c9ad;
117
+ --mint-ink: #b0f0d9;
118
+ --mint-soft: #263e3d;
119
+ --mint-line: #3e645b;
120
+ --gold-ink: #f2d28f;
121
+ --gold-soft: #433a2b;
122
+ --gold-line: #665638;
123
+ --shadow: 0 14px 38px rgb(0 0 0 / 24%);
124
+ --shadow-small: 0 6px 18px rgb(0 0 0 / 18%);
125
+ }
126
+
127
+ body {
128
+ background:
129
+ radial-gradient(
130
+ circle at 92% 7%,
131
+ rgb(178 165 255 / 8%),
132
+ transparent 23rem
133
+ ),
134
+ var(--paper);
135
+ }
136
+
137
+ .hero-panel {
138
+ background:
139
+ radial-gradient(
140
+ circle at 85% 18%,
141
+ rgb(178 165 255 / 10%),
142
+ transparent 17rem
143
+ ),
144
+ linear-gradient(140deg, var(--sheet), var(--accent-soft));
145
+ }
146
+ }
147
+
148
+ @media (prefers-reduced-motion: reduce) {
149
+ html {
150
+ scroll-behavior: auto;
151
+ }
152
+
153
+ *,
154
+ *::before,
155
+ *::after {
156
+ animation-duration: 0.01ms !important;
157
+ animation-iteration-count: 1 !important;
158
+ transition-duration: 0.01ms !important;
159
+ }
160
+
161
+ .button-spinner {
162
+ animation-duration: 6s !important;
163
+ animation-iteration-count: infinite !important;
164
+ }
165
+ }