Skip to content

Commit

Permalink
Remove node specific code from StickyNotePreview, update openApi defs
Browse files Browse the repository at this point in the history
  • Loading branch information
philemone committed Nov 20, 2024
1 parent 4bf3249 commit e239e73
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion designer/client/src/components/ComponentPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function ComponentPreview({ node, isActive, isOver }: { node: NodeType; i
const colors = isOver ? nodeColorsHover : nodeColors;

return node?.type === StickyNoteType ? (
<StickyNotePreview node={node} isActive={isActive} isOver={isOver} />
<StickyNotePreview isActive={isActive} isOver={isOver} />
) : (
<div className={cx(colors, nodeStyles)}>
<div className={cx(imageStyles, imageColors)}>
Expand Down
21 changes: 5 additions & 16 deletions designer/client/src/components/StickyNotePreview.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { css, cx } from "@emotion/css";
import React from "react";
import { NodeType } from "../types";
import { BORDER_RADIUS, CONTENT_PADDING, iconBackgroundSize, iconSize } from "./graph/EspNode/esp";
import { ComponentIcon } from "./toolbars/creator/ComponentIcon";
import { getStickyNoteIconSrc, PreloadedIcon } from "./toolbars/creator/ComponentIcon";
import { alpha, useTheme } from "@mui/material";
import { blend } from "@mui/system";
import { getBorderColor, getStickyNoteBackgroundColor } from "../containers/theme/helpers";
import { STICKY_NOTE_DEFAULT_COLOR, STICKY_NOTE_HEIGHT, STICKY_NOTE_WIDTH } from "./graph/EspNode/stickyNote";

export function StickyNotePreview({ node, isActive, isOver }: { node: NodeType; isActive?: boolean; isOver?: boolean }): JSX.Element {
export function StickyNotePreview({ isActive, isOver }: { isActive?: boolean; isOver?: boolean }): JSX.Element {
const theme = useTheme();

const PREVIEW_SCALE = 0.9;
Expand All @@ -35,15 +33,11 @@ export function StickyNotePreview({ node, isActive, isOver }: { node: NodeType;
willChange: "transform, opacity, border-color, background-color",
});

const nodeColors = css({
const colors = css({
opacity: 0.5,
borderColor: getBorderColor(theme),
backgroundColor: getStickyNoteBackgroundColor(theme, STICKY_NOTE_DEFAULT_COLOR).main,
});
const nodeColorsHover = css({
borderColor: blend(getBorderColor(theme), theme.palette.secondary.main, 0.2),
backgroundColor: getStickyNoteBackgroundColor(theme, STICKY_NOTE_DEFAULT_COLOR).main,
});

const imageStyles = css({
padding: iconSize / 2 - CONTENT_PADDING / 2,
Expand All @@ -57,15 +51,10 @@ export function StickyNotePreview({ node, isActive, isOver }: { node: NodeType;
},
});

const imageColors = css({
color: theme.palette.common.black,
});

const colors = isOver ? nodeColorsHover : nodeColors;
return (
<div className={cx(colors, nodeStyles)}>
<div className={cx(imageStyles, imageColors)}>
<ComponentIcon node={node} />
<div className={cx(imageStyles, colors)}>
<PreloadedIcon src={getStickyNoteIconSrc} />
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const preloadBeImage = memoize((src: string): string | null => {
return `#${id}`;
});

export const getStickyNoteIconSrc = `/assets/components/${StickyNoteType}.svg`;
export function getStickyNoteIcon(): string | null {
const typeIcon = `/assets/components/${StickyNoteType}.svg`;
return preloadBeImage(typeIcon);
return preloadBeImage(getStickyNoteIconSrc);
}

export function getComponentIconSrc(node: NodeType, { components }: ProcessDefinitionData): string | null {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class StickyNotesApiEndpoints(auth: EndpointInput[AuthCredentials]) extends Base
exampleStickyNote,
exampleStickyNote.copy(noteId = StickyNoteId(2))
)
) // TODO example of errors
)
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ object Dtos {
targetEdge: Option[String]
)

// TODO add this to configuration file in next iteration
case class StickyNotesSettings(
maxContentLength: Int,
maxNotesCount: Int
Expand Down
22 changes: 17 additions & 5 deletions docs-internal/api/nu-designer-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2680,12 +2680,17 @@ paths:
'200':
description: ''
'400':
description: 'Invalid value for: header Nu-Impersonate-User-Identity, Invalid
value for: body'
description: ''
content:
text/plain:
schema:
type: string
examples:
Example:
summary: Provided note content is too long (5004 characters). Max
content length is 5000.
value: Provided note content is too long (5004 characters). Max
content length is 5000.
'401':
description: ''
content:
Expand Down Expand Up @@ -2778,12 +2783,19 @@ paths:
type: string
format: uuid
'400':
description: 'Invalid value for: header Nu-Impersonate-User-Identity, Invalid
value for: body'
description: ''
content:
text/plain:
schema:
type: string
anyOf:
- type: string
- type: string
examples:
Example:
summary: 'Cannot add another sticky note, since max number of sticky
notes was reached: 5 (see configuration).'
value: 'Cannot add another sticky note, since max number of sticky
notes was reached: 5 (see configuration).'
'401':
description: ''
content:
Expand Down

0 comments on commit e239e73

Please sign in to comment.