|
|
@@ -1,19 +1,16 @@
|
|
|
import { RGBA } from "@opentui/core"
|
|
|
import {
|
|
|
- blendColor,
|
|
|
createColorRampTheme,
|
|
|
DIAGRAM_FADE_STEPS,
|
|
|
numberedStyleKeys,
|
|
|
rgba,
|
|
|
type DiagramRgb,
|
|
|
} from "../core/color/style.js"
|
|
|
-import { SEQUENCE_LIFELINE_FADE_STEPS } from "./options.js"
|
|
|
-import type { FadeStyle, LifelineFadeStyle, LifelineRampStyle, SequenceCellStyle } from "./types.js"
|
|
|
+import type { FadeStyle, LifelineRampStyle, SequenceCellStyle } from "./types.js"
|
|
|
|
|
|
export interface SequenceStyleColors {
|
|
|
participant?: RGBA
|
|
|
lifeline?: RGBA
|
|
|
- lifelineEnd?: RGBA
|
|
|
group?: RGBA
|
|
|
request?: RGBA
|
|
|
response?: RGBA
|
|
|
@@ -33,7 +30,6 @@ const LIFELINE_RAMP_STYLES = [
|
|
|
const DEFAULT_THEME_RGB = {
|
|
|
participant: [228, 239, 232],
|
|
|
lifeline: [111, 138, 126],
|
|
|
- lifelineEnd: [15, 23, 19],
|
|
|
group: [76, 99, 89],
|
|
|
request: [134, 225, 200],
|
|
|
response: [230, 177, 126],
|
|
|
@@ -45,22 +41,14 @@ const DEFAULT_THEME_RGB = {
|
|
|
|
|
|
export function resolveSequenceStyleColors(
|
|
|
colors: SequenceStyleColors = {},
|
|
|
-): Required<SequenceStyleColors> & Record<FadeStyle | LifelineFadeStyle | LifelineRampStyle, RGBA> {
|
|
|
+): Required<SequenceStyleColors> & Record<FadeStyle | LifelineRampStyle, RGBA> {
|
|
|
const participant = colors.participant ?? rgba(DEFAULT_THEME_RGB.participant)
|
|
|
const lifeline = colors.lifeline ?? rgba(DEFAULT_THEME_RGB.lifeline)
|
|
|
const request = colors.request ?? rgba(DEFAULT_THEME_RGB.request)
|
|
|
const response = colors.response ?? rgba(DEFAULT_THEME_RGB.response)
|
|
|
- const lifelineEnd = colors.lifelineEnd ?? rgba(DEFAULT_THEME_RGB.lifelineEnd)
|
|
|
- const lifelineFade = Object.fromEntries(
|
|
|
- SEQUENCE_LIFELINE_FADE_STEPS.map((step, index) => [
|
|
|
- `lifelineFade${step}`,
|
|
|
- blendColor(lifeline, lifelineEnd, index / (SEQUENCE_LIFELINE_FADE_STEPS.length - 1)),
|
|
|
- ]),
|
|
|
- ) as Record<LifelineFadeStyle, RGBA>
|
|
|
return {
|
|
|
participant,
|
|
|
lifeline,
|
|
|
- lifelineEnd,
|
|
|
group: colors.group ?? rgba(DEFAULT_THEME_RGB.group),
|
|
|
request,
|
|
|
response,
|
|
|
@@ -71,13 +59,12 @@ export function resolveSequenceStyleColors(
|
|
|
...createColorRampTheme(numberedStyleKeys("requestFade", SEQUENCE_FADE_STEPS), lifeline, request),
|
|
|
...createColorRampTheme(numberedStyleKeys("responseFade", SEQUENCE_FADE_STEPS), lifeline, response),
|
|
|
...createColorRampTheme(LIFELINE_RAMP_STYLES, participant, lifeline),
|
|
|
- ...lifelineFade,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function sequenceStyleColor(
|
|
|
style: SequenceCellStyle | undefined,
|
|
|
- colors: Required<SequenceStyleColors> & Record<FadeStyle | LifelineFadeStyle | LifelineRampStyle, RGBA>,
|
|
|
+ colors: Required<SequenceStyleColors> & Record<FadeStyle | LifelineRampStyle, RGBA>,
|
|
|
): RGBA | undefined {
|
|
|
if (style === "noteBadge") return colors.note
|
|
|
if (style === "fragmentLabel") return colors.fragment
|