Skip to content

Commit 76ea4db

Browse files
committed
style(editor): use the original dialog, material and field classes
1 parent 143d816 commit 76ea4db

7 files changed

Lines changed: 21 additions & 14 deletions

File tree

resources/js/components/Modal.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ interface ModalProps {
44
title: string;
55
children: ReactNode;
66
footer?: ReactNode;
7-
wide?: boolean;
7+
/** Extra class the original gave each dialog, which carries its width. */
8+
variant?: string;
89
onClose: () => void;
910
}
1011

1112
/**
1213
* The editor's dialog shell. Escape and a click on the backdrop close it, the
1314
* way every dialog in the legacy editor behaved.
1415
*/
15-
export function Modal({ title, children, footer, wide, onClose }: ModalProps) {
16+
export function Modal({ title, children, footer, variant, onClose }: ModalProps) {
1617
useEffect(() => {
1718
const escape = (event: KeyboardEvent): void => {
1819
if (event.key === 'Escape') {
@@ -31,7 +32,7 @@ export function Modal({ title, children, footer, wide, onClose }: ModalProps) {
3132
role="presentation"
3233
onClick={event => event.target === event.currentTarget && onClose()}
3334
>
34-
<div className="modal" role="dialog" aria-modal="true" aria-label={title} style={wide ? { minWidth: '640px' } : undefined}>
35+
<div className={`modal${variant === undefined ? '' : ` ${variant}`}`} role="dialog" aria-modal="true" aria-label={title}>
3536
<div className="modal-header">{title}</div>
3637
<div className="modal-body">{children}</div>
3738
{footer !== undefined && <div className="modal-footer">{footer}</div>}

resources/js/components/visual/ActionEditor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ function ActionDialog({
118118
return (
119119
<Modal
120120
title="Action"
121+
variant="action-editor-modal"
121122
onClose={onClose}
122123
footer={
123124
<>

resources/js/components/visual/ConditionEditor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ function ConditionDialog({
168168
return (
169169
<Modal
170170
title="Condition"
171+
variant="condition-editor-modal"
171172
onClose={onClose}
172173
footer={
173174
<>

resources/js/components/visual/ItemEditor.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ interface ItemEditorProps {
1919
export function ItemEditor({ slot, item, serverVersion, onChange, onRemove }: ItemEditorProps) {
2020
if (item === undefined) {
2121
return (
22-
<p className="item-editor-content">
22+
<div className="item-editor-notice">
2323
Slot {slot} is empty. Drop a material on it, or pick one from the palette.
24-
</p>
24+
</div>
2525
);
2626
}
2727

@@ -51,7 +51,7 @@ export function ItemEditor({ slot, item, serverVersion, onChange, onRemove }: It
5151

5252
<div className="item-editor-section">
5353
<div className="editor-field">
54-
<span>Material</span>
54+
<span className="item-label">Material</span>
5555
<MaterialSelector
5656
material={item.material}
5757
serverVersion={serverVersion}
@@ -60,9 +60,10 @@ export function ItemEditor({ slot, item, serverVersion, onChange, onRemove }: It
6060
</div>
6161

6262
<div className="editor-field">
63-
<label htmlFor="item-amount">Amount</label>
63+
<label className="item-label" htmlFor="item-amount">Amount</label>
6464
<input
6565
id="item-amount"
66+
className="item-input"
6667
type="number"
6768
min={1}
6869
max={64}
@@ -73,9 +74,10 @@ export function ItemEditor({ slot, item, serverVersion, onChange, onRemove }: It
7374

7475
{item.material === 'PLAYER_HEAD' && (
7576
<div className="editor-field">
76-
<label htmlFor="item-head">Head texture</label>
77+
<label className="item-label" htmlFor="item-head">Head texture</label>
7778
<input
7879
id="item-head"
80+
className="item-input"
7981
value={typeof item.value === 'string' ? item.value : ''}
8082
onChange={event => update({ value: event.target.value })}
8183
/>
@@ -86,7 +88,7 @@ export function ItemEditor({ slot, item, serverVersion, onChange, onRemove }: It
8688

8789
<div className="item-editor-section">
8890
<div className="editor-field">
89-
<label htmlFor="item-name">Name</label>
91+
<span className="item-label">Name</span>
9092
<FormattedInput
9193
ariaLabel="Item name"
9294
value={typeof item.name === 'string' ? item.name : ''}
@@ -95,7 +97,7 @@ export function ItemEditor({ slot, item, serverVersion, onChange, onRemove }: It
9597
</div>
9698

9799
<div className="editor-field">
98-
<label htmlFor="item-lore">Lore</label>
100+
<span className="item-label">Lore</span>
99101
<FormattedInput
100102
ariaLabel="Item lore"
101103
multiline

resources/js/components/visual/ItemIcon.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useState } from 'react';
22
import { getMaterialEmoji, getMaterialImageUrl } from '../../editor/materials';
33
import { getPlayerHeadImageUrl } from '../../editor/heads';
44

5-
type IconVariant = 'canvas' | 'palette';
5+
type IconVariant = 'canvas' | 'palette' | 'material-list';
66

77
interface ItemIconProps {
88
item: { material: string; value?: unknown };
@@ -13,6 +13,7 @@ interface ItemIconProps {
1313
const CLASSES: Record<IconVariant, { image: string; fallback: string }> = {
1414
canvas: { image: 'item-icon-image', fallback: 'item-icon-fallback' },
1515
palette: { image: 'palette-item-image', fallback: 'palette-item-fallback' },
16+
'material-list': { image: 'material-list-image', fallback: 'material-list-fallback' },
1617
};
1718

1819
/**

resources/js/components/visual/MaterialSelector.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function MaterialSelector({ material, serverVersion, onChange }: Material
1919
<>
2020
<button type="button" className="material-selector-btn" onClick={() => setOpen(true)}>
2121
<span className="material-preview-inline">
22-
<ItemIcon item={{ material }} serverVersion={serverVersion} variant="palette" />
22+
<ItemIcon item={{ material }} serverVersion={serverVersion} variant="material-list" />
2323
<span className="material-list-name">{formatMaterialName(material)}</span>
2424
</span>
2525
<span className="material-change-icon">Change</span>
@@ -61,7 +61,7 @@ function MaterialModal({
6161
return (
6262
<Modal
6363
title="Choose a material"
64-
wide
64+
variant="material-selector-modal"
6565
onClose={onClose}
6666
footer={
6767
<button type="button" className="btn btn-secondary" onClick={onClose}>
@@ -90,7 +90,7 @@ function MaterialModal({
9090
onKeyDown={event => event.key === 'Enter' && onPick(name)}
9191
title={name}
9292
>
93-
<ItemIcon item={{ material: name }} serverVersion={serverVersion} variant="palette" />
93+
<ItemIcon item={{ material: name }} serverVersion={serverVersion} variant="material-list" />
9494
<span className="material-list-name">{formatMaterialName(name)}</span>
9595
</div>
9696
))}

resources/js/components/visual/SlotContextMenu.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export function SlotContextMenu({
6262
>
6363
{hasItem && <Entry label="Copy" shortcut="Ctrl+C" onClick={onCopy} />}
6464
{canPaste && <Entry label={hasItem ? 'Paste (replace)' : 'Paste'} shortcut="Ctrl+V" onClick={onPaste} />}
65+
{hasItem && <div className="context-menu-divider" />}
6566
{hasItem && <Entry label="Delete" shortcut="Del" onClick={onDelete} tone="danger" />}
6667
</div>
6768
);

0 commit comments

Comments
 (0)