From 5b8aaf0577e0063ff196ef54ed320beebeedc797 Mon Sep 17 00:00:00 2001 From: NikitaKalitov Date: Wed, 22 Jul 2026 11:23:05 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- palette.css | 7 ---- src/diagram.css | 2 + src/nodes.tsx | 106 +++++++++++++++++++++++++++++++----------------- 3 files changed, 71 insertions(+), 44 deletions(-) diff --git a/palette.css b/palette.css index c04e229..4f3123b 100644 --- a/palette.css +++ b/palette.css @@ -1,10 +1,3 @@ -/* - Извлечено со скриншотов брендбука/стайлгайда. - Угол градиента в источнике указан как «60%» — трактован как 60deg - (стандартная запись угла в CSS linear-gradient). Проверьте по оригиналу, - если это принципиально. -*/ - :root { /* ============================================================ ОСНОВНЫЕ ГРАДИЕНТЫ (синие) — для инфоблоков, диаграмм, блок-схем diff --git a/src/diagram.css b/src/diagram.css index d0eecf9..1b86052 100644 --- a/src/diagram.css +++ b/src/diagram.css @@ -61,6 +61,7 @@ .diagram-node__label { white-space: pre-wrap; overflow-wrap: break-word; + font-weight: 600; } .diagram-node__badge { @@ -89,6 +90,7 @@ max-width: 120px; text-align: center; white-space: pre-wrap; + font-weight: 600; } .diagram-node--circle { diff --git a/src/nodes.tsx b/src/nodes.tsx index accc3e9..46fc0bf 100644 --- a/src/nodes.tsx +++ b/src/nodes.tsx @@ -1,6 +1,12 @@ -import { createContext, useContext } from 'react'; -import { Handle, NodeResizer, Position, type Node, type NodeProps } from '@xyflow/react'; -import type { DiagramNodeData, NodeKind } from './types'; +import { createContext, useContext } from "react"; +import { + Handle, + NodeResizer, + Position, + type Node, + type NodeProps, +} from "@xyflow/react"; +import type { DiagramNodeData, NodeKind } from "./types"; type ShapeNode = Node; @@ -8,31 +14,31 @@ type ShapeNode = Node; export const NodesWithChildrenContext = createContext>(new Set()); /** Current editor mode — resize handles and connection points only show in 'edit'. */ -export const ModeContext = createContext<'edit' | 'view'>('edit'); +export const ModeContext = createContext<"edit" | "view">("edit"); // Gradients from palette.css's "ОСНОВНАЯ ПАЛИТРА" section — the one the // palette itself labels as meant for diagrams/flowcharts/semantic highlights. // This is what nodes actually render with until a user picks a custom color. export const DEFAULT_NODE_BACKGROUND: Record = { - task: 'var(--gradient-blue)', - startEvent: 'var(--gradient-green)', - intermediateEvent: 'var(--gradient-orange)', - endEvent: 'var(--gradient-red)', - exclusiveGateway: 'var(--gradient-purple)', - parallelGateway: 'var(--gradient-cyan)', - inclusiveGateway: 'var(--gradient-olive)', + task: "var(--gradient-blue)", + startEvent: "var(--gradient-green)", + intermediateEvent: "var(--gradient-orange)", + endEvent: "var(--gradient-red)", + exclusiveGateway: "var(--gradient-purple)", + parallelGateway: "var(--gradient-cyan)", + inclusiveGateway: "var(--gradient-olive)", }; // The color picker only understands flat hex, so it needs a solid fallback // distinct from the gradient rendered on canvas — the gradient's start color. export const DEFAULT_NODE_COLOR: Record = { - task: '#0790CB', - startEvent: '#2CB587', - intermediateEvent: '#FF8E58', - endEvent: '#E13042', - exclusiveGateway: '#A12C7E', - parallelGateway: '#1BD3F7', - inclusiveGateway: '#BBBD39', + task: "#0790CB", + startEvent: "#2CB587", + intermediateEvent: "#FF8E58", + endEvent: "#E13042", + exclusiveGateway: "#A12C7E", + parallelGateway: "#1BD3F7", + inclusiveGateway: "#BBBD39", }; export const DEFAULT_TASK_BORDER_RADIUS = 6; @@ -41,15 +47,15 @@ export const DEFAULT_TASK_BORDER_RADIUS = 6; // default; the caption below events/gateways sits on the plain canvas // background instead and needs a dark one. Both are overridable via the // same `data.textColor`/`data.fontSize`. -export const DEFAULT_NODE_TEXT_COLOR = '#FFFFFF'; -export const DEFAULT_CAPTION_TEXT_COLOR = '#525A64'; +export const DEFAULT_NODE_TEXT_COLOR = "#FFFFFF"; +export const DEFAULT_CAPTION_TEXT_COLOR = "#525A64"; export const DEFAULT_NODE_FONT_SIZE = 12; const HANDLE_POSITIONS: { id: string; position: Position }[] = [ - { id: 'top', position: Position.Top }, - { id: 'right', position: Position.Right }, - { id: 'bottom', position: Position.Bottom }, - { id: 'left', position: Position.Left }, + { id: "top", position: Position.Top }, + { id: "right", position: Position.Right }, + { id: "bottom", position: Position.Bottom }, + { id: "left", position: Position.Left }, ]; /** @@ -71,7 +77,10 @@ function SubProcessBadge({ id }: { id: string }) { const withChildren = useContext(NodesWithChildrenContext); if (!withChildren.has(id)) return null; return ( - + ⊞ ); @@ -91,7 +100,7 @@ function ShapeResizer({ const mode = useContext(ModeContext); return ( ) { borderRadius: data.borderRadius ?? DEFAULT_TASK_BORDER_RADIUS, }} > - + {data.label} @@ -122,7 +139,8 @@ function TaskNode({ id, data, selected }: NodeProps) { } function EventNode({ id, data, type, selected }: NodeProps) { - const kind = (type as 'startEvent' | 'intermediateEvent' | 'endEvent') ?? 'startEvent'; + const kind = + (type as "startEvent" | "intermediateEvent" | "endEvent") ?? "startEvent"; return (
) { {data.label} @@ -141,14 +162,19 @@ function EventNode({ id, data, type, selected }: NodeProps) { ); } -const GATEWAY_ICON: Record<'exclusiveGateway' | 'parallelGateway' | 'inclusiveGateway', string> = { - exclusiveGateway: '✕', - parallelGateway: '+', - inclusiveGateway: '○', +const GATEWAY_ICON: Record< + "exclusiveGateway" | "parallelGateway" | "inclusiveGateway", + string +> = { + exclusiveGateway: "✕", + parallelGateway: "+", + inclusiveGateway: "○", }; function GatewayNode({ id, data, type, selected }: NodeProps) { - const kind = (type as 'exclusiveGateway' | 'parallelGateway' | 'inclusiveGateway') ?? 'exclusiveGateway'; + const kind = + (type as "exclusiveGateway" | "parallelGateway" | "inclusiveGateway") ?? + "exclusiveGateway"; return (
@@ -165,13 +191,19 @@ function GatewayNode({ id, data, type, selected }: NodeProps) { of it, since clip-path would otherwise cut off anything of theirs that renders outside the diamond outline. */} -
+
{GATEWAY_ICON[kind]} {data.label}