Files
flatrender/src/components/studio/properties/CommonLayerControls.tsx
T
soroush.asadi 3fc7bf2b97
Build backend images / build content-svc (push) Failing after 3m39s
Build backend images / build file-svc (push) Failing after 52s
Build backend images / build gateway (push) Failing after 58s
Build backend images / build identity-svc (push) Failing after 1m21s
Build backend images / build notification-svc (push) Failing after 1m0s
Build backend images / build render-svc (push) Failing after 58s
Build backend images / build studio-svc (push) Failing after 55s
feat: AI SEO generator, full admin panel, i18n sweep, new logo + auth/RTL fixes
AI SEO content generator
- content-svc: per-tenant OpenAI config (ai_settings) + /v1/ai endpoints
  (settings GET/PUT, seo-post) with SEO-expert prompt → structured article
- admin UI to configure token/base-url/model and generate + save as blog
- configurable base URL for restricted networks

Full data-driven admin panel
- generic /api/admin/resource proxy + reusable AdminResource component
- categories/tags/fonts/blogs (CRUD), users (list + ban), plans/slides
- AI content section; nav + i18n

i18n localization sweep
- localized 116 user-facing + studio/editor components to next-intl (fa+en)
  under the auto.* namespace; merge tooling in scripts/merge-i18n.js

Branding + assets
- Monoline F logo (LogoMark + favicon)
- offline SVG placeholder generator (/api/placeholder), dropped picsum.photos

Fixes
- JWT issuer mismatch on content/studio (flatrender → flatrender-identity)
- missing role claim → [Authorize(Roles="Admin")] now works (RBAC)
- Secure cookies broke HTTP sessions → gated behind AUTH_COOKIE_SECURE
- Radix RTL via DirectionProvider (right-aligned menus in fa)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 09:35:14 +03:30

128 lines
4.5 KiB
TypeScript

"use client";
import { useRef, useState } from "react";
import { useTranslations } from "next-intl";
import { ArrowDown, ArrowUp, Trash2 } from "lucide-react";
import {
AspectRatioLockButton,
PanelSection,
PropertyNumberInput,
} from "@/components/studio/properties/PropertyControls";
import { useLayerUpdater } from "@/components/studio/properties/useLayerUpdater";
import type { Layer } from "@/lib/studio-types";
import { useStudioStore } from "@/lib/studio-store";
interface CommonLayerControlsProps {
layer: Layer;
}
export function CommonLayerControls({ layer }: CommonLayerControlsProps) {
const t = useTranslations("auto.componentsStudioPropertiesCommonLayerControls");
const [aspectLocked, setAspectLocked] = useState(false);
const aspectRatioRef = useRef(layer.width / layer.height || 1);
const { update } = useLayerUpdater(layer);
const deleteLayer = useStudioStore((state) => state.deleteLayer);
const moveLayerToFront = useStudioStore((state) => state.moveLayerToFront);
const moveLayerToBack = useStudioStore((state) => state.moveLayerToBack);
const aspectRatio = aspectRatioRef.current;
const setWidth = (width: number) => {
if (aspectLocked) {
update({ width, height: Math.max(8, width / aspectRatio) });
return;
}
update({ width: Math.max(8, width) });
};
const setHeight = (height: number) => {
if (aspectLocked) {
update({ height, width: Math.max(8, height * aspectRatio) });
return;
}
update({ height: Math.max(8, height) });
};
return (
<>
<PanelSection title={t("transformTitle")}>
<div className="grid grid-cols-2 gap-2">
<PropertyNumberInput
label="X"
value={layer.x}
onChange={(x) => update({ x })}
/>
<PropertyNumberInput
label="Y"
value={layer.y}
onChange={(y) => update({ y })}
/>
</div>
<div className="flex items-end gap-2">
<div className="grid flex-1 grid-cols-2 gap-2">
<PropertyNumberInput
label={t("widthLabel")}
value={layer.width}
min={8}
onChange={setWidth}
/>
<PropertyNumberInput
label={t("heightLabel")}
value={layer.height}
min={8}
onChange={setHeight}
/>
</div>
<AspectRatioLockButton
locked={aspectLocked}
onToggle={() => {
setAspectLocked((locked) => {
if (!locked) {
aspectRatioRef.current = layer.width / layer.height || 1;
}
return !locked;
});
}}
/>
</div>
<PropertyNumberInput
label={t("rotationLabel")}
value={layer.rotation}
onChange={(rotation) => update({ rotation })}
/>
</PanelSection>
<PanelSection title={t("layerOrderTitle")}>
<div className="grid grid-cols-2 gap-2">
<button
type="button"
onClick={() => moveLayerToFront(layer.id)}
className="flex items-center justify-center gap-1 rounded-md border border-gray-200 bg-gray-50 px-2 py-2 text-[11px] text-gray-600 hover:border-gray-300 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500"
>
<ArrowUp className="h-3.5 w-3.5" aria-hidden />
{t("toFront")}
</button>
<button
type="button"
onClick={() => moveLayerToBack(layer.id)}
className="flex items-center justify-center gap-1 rounded-md border border-gray-200 bg-gray-50 px-2 py-2 text-[11px] text-gray-600 hover:border-gray-300 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500"
>
<ArrowDown className="h-3.5 w-3.5" aria-hidden />
{t("toBack")}
</button>
</div>
</PanelSection>
<button
type="button"
onClick={() => deleteLayer(layer.id)}
className="flex w-full items-center justify-center gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2.5 text-xs font-medium text-red-500 transition-colors hover:border-red-300 hover:bg-red-100 hover:text-red-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-500"
>
<Trash2 className="h-3.5 w-3.5" aria-hidden />
{t("deleteLayer")}
</button>
</>
);
}