feat(frontend): redesign the candidate cabinet with step-by-step profile and questionnaire forms
This commit is contained in:
1 parent
15590d127c
commit
c836d02ea3
77 files changed
+5409
-1618
No files matched your search
@@ -4,49 +4,116 @@
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* The answer sits directly in the item panel: no second frame around it. */
|
||||
.fields,
|
||||
.code-lines {
|
||||
display: grid;
|
||||
gap: var(--space-3);
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
padding: var(--space-4);
|
||||
border: var(--line-thin) solid var(--color-divider);
|
||||
border-radius: var(--radius-m);
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.legend,
|
||||
.code-lines legend {
|
||||
padding: 0 var(--space-2);
|
||||
font-weight: var(--font-weight-bold);
|
||||
float: left;
|
||||
width: 100%;
|
||||
margin-bottom: var(--space-1);
|
||||
padding: 0;
|
||||
color: var(--color-text-secondary);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-xs);
|
||||
font-weight: var(--font-weight-medium);
|
||||
letter-spacing: var(--letter-spacing-label);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.options,
|
||||
.practice {
|
||||
display: grid;
|
||||
gap: var(--space-3);
|
||||
gap: var(--space-2);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* An option is a nested surface; a keycap gives its keyboard digit. The
|
||||
* chosen option gets the accent border and tint and its native mark. */
|
||||
.option,
|
||||
.code-line {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: var(--space-3);
|
||||
align-items: flex-start;
|
||||
min-width: 0;
|
||||
padding: var(--space-3);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
border: var(--line-thin) solid var(--color-border-strong);
|
||||
border-radius: var(--radius-s);
|
||||
background: var(--color-canvas);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
border-color var(--duration-fast) var(--easing-standard),
|
||||
background-color var(--duration-fast) var(--easing-standard);
|
||||
}
|
||||
|
||||
.code-line {
|
||||
align-items: baseline;
|
||||
font-family: var(--font-mono);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.option:hover,
|
||||
.code-line:hover {
|
||||
border-color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.option[data-checked],
|
||||
.code-line:has(input:checked) {
|
||||
border-color: var(--color-accent);
|
||||
background: var(--color-accent-tint);
|
||||
}
|
||||
|
||||
.option:has(input:focus-visible) {
|
||||
outline: var(--focus-ring-width) solid var(--color-focus-ring);
|
||||
outline-offset: var(--focus-ring-offset);
|
||||
}
|
||||
|
||||
.option input,
|
||||
.code-line input {
|
||||
flex: 0 0 auto;
|
||||
width: 1.2rem;
|
||||
height: 1.2rem;
|
||||
margin-block-start: 0.15rem;
|
||||
accent-color: var(--color-action);
|
||||
margin-block-start: 0.2rem;
|
||||
}
|
||||
|
||||
.option-text {
|
||||
min-width: 0;
|
||||
line-height: var(--line-height-body);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.keycap,
|
||||
.keys kbd {
|
||||
display: inline-grid;
|
||||
flex: none;
|
||||
place-items: center;
|
||||
min-width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
padding: 0 var(--space-1);
|
||||
border: var(--line-thin) solid var(--color-border-hover);
|
||||
border-radius: var(--radius-xs);
|
||||
color: var(--color-text-secondary);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-xs);
|
||||
background: var(--color-surface-elevated);
|
||||
}
|
||||
|
||||
.keys {
|
||||
color: var(--color-text-muted);
|
||||
font-size: var(--font-size-xs);
|
||||
}
|
||||
|
||||
.keys kbd {
|
||||
display: inline-flex;
|
||||
min-width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
vertical-align: 0.05em;
|
||||
}
|
||||
|
||||
.field {
|
||||
@@ -61,15 +128,14 @@
|
||||
.field textarea {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: var(--space-3);
|
||||
border: var(--line-thin) solid var(--color-border-strong);
|
||||
border-radius: var(--radius-s);
|
||||
color: var(--color-text);
|
||||
background: var(--color-surface);
|
||||
font: inherit;
|
||||
font-weight: var(--font-weight-regular);
|
||||
}
|
||||
|
||||
.field input {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.field textarea {
|
||||
resize: vertical;
|
||||
font-family: var(--font-mono);
|
||||
@@ -77,13 +143,6 @@
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.field :is(input, select, textarea):focus-visible,
|
||||
.option input:focus-visible,
|
||||
.code-line input:focus-visible {
|
||||
outline: var(--line-strong) solid var(--color-accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.hint {
|
||||
margin: 0;
|
||||
color: var(--color-text-secondary);
|
||||
@@ -109,6 +168,7 @@
|
||||
padding: var(--space-3);
|
||||
border: var(--line-thin) solid var(--color-border-strong);
|
||||
border-radius: var(--radius-s);
|
||||
background: var(--color-canvas);
|
||||
}
|
||||
|
||||
.order-actions,
|
||||
@@ -119,16 +179,6 @@
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.code-lines {
|
||||
padding-inline: var(--space-3);
|
||||
}
|
||||
|
||||
.code-line {
|
||||
align-items: baseline;
|
||||
font-family: var(--font-mono);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.line-number {
|
||||
flex: 0 0 2.5rem;
|
||||
color: var(--color-text-secondary);
|
||||
@@ -171,10 +221,6 @@
|
||||
}
|
||||
|
||||
@media (width < 42rem) {
|
||||
.fields {
|
||||
padding: var(--space-3);
|
||||
}
|
||||
|
||||
.order-item {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useId, useState, type FormEvent } from "react";
|
||||
import { useId, useState, type FormEvent, type KeyboardEvent } from "react";
|
||||
import type { AssessmentItem } from "../../../shared/api/schemas";
|
||||
import { Button } from "../../../shared/ui";
|
||||
import type { AnswerDraft } from "../model/answer-draft";
|
||||
@@ -42,8 +42,33 @@ export function AnswerForm({
|
||||
onSubmit(draft);
|
||||
}
|
||||
|
||||
// Keyboard first: digits 1-9 pick an option of a choice item, and Enter on
|
||||
// an option sends the answer like Enter in a text field. Text fields keep
|
||||
// their digits; modifier keys are left to the browser and assistive tools.
|
||||
function handleKeyDown(event: KeyboardEvent<HTMLFormElement>) {
|
||||
if (frozen || event.altKey || event.ctrlKey || event.metaKey) return;
|
||||
const target = event.target as HTMLElement;
|
||||
const isOption =
|
||||
target instanceof HTMLInputElement && (target.type === "radio" || target.type === "checkbox");
|
||||
if (event.key === "Enter" && isOption) {
|
||||
event.preventDefault();
|
||||
event.currentTarget.requestSubmit();
|
||||
return;
|
||||
}
|
||||
if (item.content.format !== "choice" || !/^[1-9]$/.test(event.key)) return;
|
||||
if (target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement) return;
|
||||
if (target instanceof HTMLInputElement && !isOption) return;
|
||||
const option = event.currentTarget.querySelectorAll<HTMLInputElement>(
|
||||
`input[name="answer-${item.id}"]`,
|
||||
)[Number(event.key) - 1];
|
||||
if (!option) return;
|
||||
event.preventDefault();
|
||||
option.focus();
|
||||
option.click();
|
||||
}
|
||||
|
||||
return (
|
||||
<form className={styles.form} onSubmit={submit}>
|
||||
<form className={styles.form} onSubmit={submit} onKeyDown={handleKeyDown}>
|
||||
<fieldset
|
||||
className={styles.fields}
|
||||
disabled={frozen}
|
||||
@@ -51,6 +76,12 @@ export function AnswerForm({
|
||||
>
|
||||
<legend className={styles.legend}>Ваш ответ</legend>
|
||||
<AnswerFields item={item} draft={draft} setDraft={setDraft} />
|
||||
{item.content.format === "choice" ? (
|
||||
<p className={styles.keys}>
|
||||
<kbd>1</kbd>-<kbd>{Math.min(item.content.options.length, 9)}</kbd> выбирают вариант,{" "}
|
||||
<kbd>Enter</kbd> отправляет ответ.
|
||||
</p>
|
||||
) : null}
|
||||
</fieldset>
|
||||
{errorMessage ? (
|
||||
<p className={styles.error} id={errorId} role="alert">
|
||||
@@ -86,10 +117,10 @@ function AnswerFields({ item, draft, setDraft }: AnswerFieldsProps) {
|
||||
const selected = draft.format === "choice" ? draft.optionIds : [];
|
||||
return (
|
||||
<div className={styles.options}>
|
||||
{content.options.map((option) => {
|
||||
{content.options.map((option, index) => {
|
||||
const checked = selected.includes(option.id);
|
||||
return (
|
||||
<label className={styles.option} key={option.id}>
|
||||
<label className={styles.option} key={option.id} data-checked={checked || undefined}>
|
||||
<input
|
||||
type={content.multiple ? "checkbox" : "radio"}
|
||||
name={`answer-${item.id}`}
|
||||
@@ -104,7 +135,12 @@ function AnswerFields({ item, draft, setDraft }: AnswerFieldsProps) {
|
||||
setDraft({ format: "choice", optionIds });
|
||||
}}
|
||||
/>
|
||||
<span>{option.text}</span>
|
||||
{index < 9 ? (
|
||||
<kbd className={styles.keycap} aria-hidden="true">
|
||||
{index + 1}
|
||||
</kbd>
|
||||
) : null}
|
||||
<span className={styles["option-text"]}>{option.text}</span>
|
||||
</label>
|
||||
);
|
||||
})}
|
||||
|
||||
Reference in new issue
Block a user