Replace panel tileKey with a direct color prop.

Drop theme panelTiles keys and the ArticleView update callback wiring.
This commit is contained in:
seb
2026-08-05 18:38:21 +02:00
parent 1fda43b20d
commit 4ccc92c01f
15 changed files with 20 additions and 70 deletions

View File

@@ -78,7 +78,7 @@ class ArticlePhotoTile extends Component {
wide = 1, wide = 1,
minHeight = 200, minHeight = 200,
sx, sx,
tileKey, color,
} = this.props; } = this.props;
const { busy, editOpen } = this.state; const { busy, editOpen } = this.state;
const photo = primaryPhoto(articleData); const photo = primaryPhoto(articleData);
@@ -90,7 +90,7 @@ class ArticlePhotoTile extends Component {
wide={wide} wide={wide}
minHeight={minHeight} minHeight={minHeight}
sx={sx} sx={sx}
tileKey={tileKey} color={color}
action={ action={
hasPhoto hasPhoto
? { ? {

View File

@@ -123,7 +123,6 @@ class ArticleTileTab extends Component {
wide = 3, wide = 3,
minHeight = 200, minHeight = 200,
sx, sx,
tileKey,
tab = DEFAULT_ARTICLE_TAB, tab = DEFAULT_ARTICLE_TAB,
} = this.props; } = this.props;
const { preferredTab } = this.state; const { preferredTab } = this.state;
@@ -255,12 +254,11 @@ class ArticleTileTab extends Component {
<PanelTile <PanelTile
wide={wide} wide={wide}
minHeight={minHeight} minHeight={minHeight}
tileKey={tileKey} color={activeColor}
elevation={0} elevation={0}
sx={{ sx={{
gridColumn: 'auto', gridColumn: 'auto',
width: '100%', width: '100%',
bgcolor: activeColor,
borderTopLeftRadius: 0, borderTopLeftRadius: 0,
borderTopRightRadius: (theme) => borderTopRightRadius: (theme) =>
`${(theme.shape.borderRadius || 4) * PANEL_TILE_BORDER_RADIUS}px`, `${(theme.shape.borderRadius || 4) * PANEL_TILE_BORDER_RADIUS}px`,

View File

@@ -1,7 +1,6 @@
import { Component } from 'react'; import { Component } from 'react';
import { PanelTileGrid } from '../panels'; import { PanelTileGrid } from '../panels';
import { StorageManagerContext } from '../../api/storageManagerContext'; import { StorageManagerContext } from '../../api/storageManagerContext';
import { PANEL_TILE_KEYS } from '../../theme';
import withNavigate from '../withNavigate'; import withNavigate from '../withNavigate';
import { import {
buildCategoryPath, buildCategoryPath,
@@ -54,11 +53,6 @@ class ArticleView extends Component {
} }
} }
handleArticleUpdated = (next) => {
this.context.setArticle(next);
this.setState({ article: next });
};
handleArticleDeleted = () => { handleArticleDeleted = () => {
const { navigate } = this.props; const { navigate } = this.props;
const { article, categories, rootCategoryId } = this.state; const { article, categories, rootCategoryId } = this.state;
@@ -87,39 +81,25 @@ class ArticleView extends Component {
return ( return (
<PanelTileGrid> <PanelTileGrid>
<ArticleViewName <ArticleViewName article={article} />
article={article}
onArticleUpdated={this.handleArticleUpdated}
/>
<ArticlePhotoTile <ArticlePhotoTile
wide={1} wide={1}
tileKey={PANEL_TILE_KEYS.photo} color="#fde68a"
sx={{ minHeight: 0 }} sx={{ minHeight: 0 }}
article={article} article={article}
onArticleUpdated={this.handleArticleUpdated}
/> />
<ArticleViewStock article={article} /> <ArticleViewStock article={article} />
<ArticleViewBrand <ArticleViewBrand article={article} />
article={article}
onArticleUpdated={this.handleArticleUpdated}
/>
<ArticleViewEANs <ArticleViewEANs article={article} />
article={article}
onArticleUpdated={this.handleArticleUpdated}
/>
<ArticleViewPrice <ArticleViewPrice article={article} />
article={article}
onArticleUpdated={this.handleArticleUpdated}
/>
<ArticleTileTab <ArticleTileTab
wide={3} wide={3}
tileKey={PANEL_TILE_KEYS.content}
minHeight={200} minHeight={200}
article={article} article={article}
tab={resolvedTab} tab={resolvedTab}

View File

@@ -141,6 +141,7 @@ export default class ArticleViewBrand extends Component {
<EditablePanelTile <EditablePanelTile
wide={1} wide={1}
minHeight={SECOND_ROW_MIN_HEIGHT} minHeight={SECOND_ROW_MIN_HEIGHT}
color="#e9d5ff"
value={value} value={value}
onSave={this.handleSave} onSave={this.handleSave}
isDirty={brandDraftDirty} isDirty={brandDraftDirty}

View File

@@ -105,6 +105,7 @@ export default class ArticleViewEANs extends Component {
<EditablePanelTile <EditablePanelTile
wide={1} wide={1}
minHeight={SECOND_ROW_MIN_HEIGHT} minHeight={SECOND_ROW_MIN_HEIGHT}
color="#e2e8f0"
contentAlignItems="flex-start" contentAlignItems="flex-start"
value={value} value={value}
onSave={this.handleSave} onSave={this.handleSave}

View File

@@ -39,7 +39,7 @@ export default class ArticleViewLists extends Component {
render() { render() {
const { article: articleData } = this.props; const { article: articleData } = this.props;
return ( return (
<PanelTile wide={1} minHeight={200}> <PanelTile wide={1} minHeight={200} color="#fbcfe8">
<RelationLine label="Vaterartikel" active={articleData.childCount > 0}> <RelationLine label="Vaterartikel" active={articleData.childCount > 0}>
{articleData.childCount} {articleData.childCount}
</RelationLine> </RelationLine>

View File

@@ -239,6 +239,7 @@ export default class ArticleViewName extends Component {
wide={3} wide={3}
minHeight={0} minHeight={0}
sx={headerTileSx} sx={headerTileSx}
color="#ffffff"
value={value} value={value}
onSave={this.handleSave} onSave={this.handleSave}
isDirty={draftDirty} isDirty={draftDirty}

View File

@@ -506,6 +506,7 @@ export default class ArticleViewPrice extends Component {
<EditablePanelTile <EditablePanelTile
wide={1} wide={1}
minHeight={SECOND_ROW_MIN_HEIGHT} minHeight={SECOND_ROW_MIN_HEIGHT}
color="#bfdbfe"
contentAlignItems="flex-start" contentAlignItems="flex-start"
value={priceValue} value={priceValue}
onSave={this.handleSave} onSave={this.handleSave}

View File

@@ -29,7 +29,7 @@ export default class ArticleViewStock extends Component {
render() { render() {
const { article: articleData } = this.props; const { article: articleData } = this.props;
return ( return (
<PanelTile wide={1} minHeight={SECOND_ROW_MIN_HEIGHT}> <PanelTile wide={1} minHeight={SECOND_ROW_MIN_HEIGHT} color="#bbf7d0">
<PanelValue> <PanelValue>
{articleData.stock != null ? formatStock(articleData.stock) : null} {articleData.stock != null ? formatStock(articleData.stock) : null}
</PanelValue> </PanelValue>

View File

@@ -227,7 +227,7 @@ class EditablePanelTileBase extends Component {
wide = 1, wide = 1,
sx, sx,
minHeight = 120, minHeight = 120,
tileKey, color,
contentAlignItems = 'center', contentAlignItems = 'center',
} = this.props; } = this.props;
const { editing, error } = this.state; const { editing, error } = this.state;
@@ -243,7 +243,7 @@ class EditablePanelTileBase extends Component {
minHeight, minHeight,
editing, editing,
pending, pending,
tileKey, color,
theme, theme,
})} })}
> >

View File

@@ -74,7 +74,7 @@ class PanelTileBase extends Component {
children, children,
sx, sx,
minHeight = 120, minHeight = 120,
tileKey, color,
action, action,
elevation = 4, elevation = 4,
} = this.props; } = this.props;
@@ -87,7 +87,7 @@ class PanelTileBase extends Component {
wide, wide,
sx, sx,
minHeight, minHeight,
tileKey, color,
theme, theme,
})} })}
> >

View File

@@ -29,11 +29,6 @@ export const tileActionIconSx = {
fontSize: 28, fontSize: 28,
}; };
export function panelTileBackground(theme, tileKey) {
if (!tileKey || !theme?.panelTiles) return undefined;
return theme.panelTiles[tileKey];
}
export const PANEL_TILE_BORDER_RADIUS = 4; export const PANEL_TILE_BORDER_RADIUS = 4;
function tileRingBoxShadow(ringColor, elevationShadow) { function tileRingBoxShadow(ringColor, elevationShadow) {
@@ -47,11 +42,9 @@ export function panelTilePaperSx({
minHeight = 120, minHeight = 120,
editing = false, editing = false,
pending = false, pending = false,
tileKey, color,
theme, theme,
}) { }) {
const tileBg = panelTileBackground(theme, tileKey);
const elevationShadow = theme?.shadows?.[4]; const elevationShadow = theme?.shadows?.[4];
const ringColor = pending const ringColor = pending
? PENDING_EDIT_BORDER ? PENDING_EDIT_BORDER
@@ -68,7 +61,7 @@ export function panelTilePaperSx({
flexDirection: 'column', flexDirection: 'column',
border: 'none', border: 'none',
borderRadius: PANEL_TILE_BORDER_RADIUS, borderRadius: PANEL_TILE_BORDER_RADIUS,
...(tileBg ? { bgcolor: tileBg } : {}), ...(color ? { bgcolor: color } : {}),
...(ringColor ...(ringColor
? { ? {
boxShadow: tileRingBoxShadow(ringColor, elevationShadow), boxShadow: tileRingBoxShadow(ringColor, elevationShadow),

View File

@@ -1,4 +1,3 @@
export { PANEL_TILE_KEYS } from './panelTiles';
export { export {
getActiveTheme, getActiveTheme,
getActiveThemeId, getActiveThemeId,

View File

@@ -1,11 +0,0 @@
/** Semantic keys for article view panel tile backgrounds. */
export const PANEL_TILE_KEYS = {
name: 'name',
photo: 'photo',
stock: 'stock',
brand: 'brand',
identifiers: 'identifiers',
price: 'price',
content: 'content',
lists: 'lists',
};

View File

@@ -1,6 +1,5 @@
import { createTheme } from '@mui/material/styles'; import { createTheme } from '@mui/material/styles';
import { MAIN_BACKGROUND } from '../../colors'; import { MAIN_BACKGROUND } from '../../colors';
import { PANEL_TILE_KEYS } from '../panelTiles';
const nav = { const nav = {
background: '#1a3533', background: '#1a3533',
@@ -13,17 +12,6 @@ const nav = {
itemActiveAccent: '#2dd4bf', itemActiveAccent: '#2dd4bf',
}; };
const panelTiles = {
[PANEL_TILE_KEYS.name]: '#ffffff',
[PANEL_TILE_KEYS.photo]: '#fde68a',
[PANEL_TILE_KEYS.stock]: '#bbf7d0',
[PANEL_TILE_KEYS.brand]: '#e9d5ff',
[PANEL_TILE_KEYS.identifiers]: '#e2e8f0',
[PANEL_TILE_KEYS.price]: '#bfdbfe',
[PANEL_TILE_KEYS.content]: '#99f6e4',
[PANEL_TILE_KEYS.lists]: '#fbcfe8',
};
export const defaultThemeId = 'default'; export const defaultThemeId = 'default';
export function createDefaultTheme() { export function createDefaultTheme() {
@@ -37,6 +25,5 @@ export function createDefaultTheme() {
}, },
}, },
nav, nav,
panelTiles,
}); });
} }