Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
FDS-664 fClick added on link (#265)
Browse files Browse the repository at this point in the history
* FDS-664 fClick callback added for links

* FDS-664 changelog updated

* FDS-664 changelog updated

* FDS-664 f-select updateDimention bug fixed
  • Loading branch information
vikas-cldcvr authored Apr 15, 2024
1 parent c5bdb0c commit ad912ec
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 9 deletions.
6 changes: 6 additions & 0 deletions packages/flow-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

# Change Log

## [2.9.10] - 2024-04-15

### Bug Fixes

- `f-select` : call `updateDimentions` only while opening.

## [2.9.9] - 2024-04-04

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ollion/flow-core",
"version": "2.9.9",
"version": "2.9.10",
"description": "Core package of flow design system",
"module": "dist/flow-core.es.js",
"main": "dist/flow-core.cjs.js",
Expand Down
4 changes: 3 additions & 1 deletion packages/flow-core/src/components/f-select/f-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,9 @@ export class FSelect extends FRoot {
protected updated(changedProperties: PropertyValues) {
super.updated(changedProperties);

this.updateDimentions();
if (this.openDropdown) {
this.updateDimentions();
}

if (changedProperties.has("value")) {
if (this.value && this.type === "single") {
Expand Down
9 changes: 9 additions & 0 deletions packages/flow-lineage/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

# Change Log

## [3.2.1] - 2024-03-19

### Improvements

- `fClick` callback added in the link.
- `label` property added to display a label on the link.
- `showLabelOn` property added to customize label displaying behaviour either on click or hover;
- The `tooltip` property was added to display more information about the link

## [3.2.0] - 2024-03-19

### Features
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-lineage/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ollion/flow-lineage",
"version": "3.2.0",
"version": "3.2.1",
"description": "Lineage dependency for flow design system",
"module": "dist/flow-lineage.es.js",
"main": "dist/flow-lineage.cjs.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export default function createLinks(
id: sourceNode.id + "->" + targetNode.id,
level: sourceNode.level,
source: sourceNode,
target: nodeElementsObj[targetNode.id as string]
target: nodeElementsObj[targetNode.id as string],
fClick: link.fClick,
label: link.label,
tooltip: link.tooltip,
showLabelOn: link.showLabelOn
});
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FText, FTooltip } from "@ollion/flow-core";
import { DrawLineageParams, LevelLinkGap, LineageLinkElement } from "../lineage-types";

import drawElbow, {
Expand Down Expand Up @@ -39,6 +40,9 @@ export default function drawLinks({
return filter ? filter(l) : degreeFilter(l);
});

const tooltipElement = element.shadowRoot!.querySelector<FTooltip>("#lineage-tooltip");
const tooltipTextElement = tooltipElement?.querySelector<FText>("#lineage-tooltip-text");

const links = svg
.append("g")
.attr("class", "links")
Expand Down Expand Up @@ -88,7 +92,74 @@ export default function drawLinks({
}
return null;
})
.attr("fill", "none");
.attr("fill", "none")
.on("click", (event: MouseEvent, d) => {
event.stopPropagation();
if (d.fClick) {
d.fClick(event, d);
}
if (d.label && d.showLabelOn === "click") {
const linkLabel = element.shadowRoot!.querySelector<SVGTextElement>(
`[id="${d.id}-link-text"]`
);
console.log(linkLabel!.computedStyleMap().get("visibility"));
if (linkLabel!.computedStyleMap().get("visibility")?.toString() === "visible") {
linkLabel!.style.setProperty("visibility", "hidden");
} else {
linkLabel!.style.setProperty("visibility", "visible");
}
}
})
.on("mouseenter", (event: MouseEvent, d) => {
event.stopPropagation();
(event.target as HTMLElement).setAttribute("stroke-width", "4");
if (d.label && d.showLabelOn !== "click") {
const linkLabel = element.shadowRoot!.querySelector<SVGTextElement>(
`[id="${d.id}-link-text"]`
);
linkLabel!.style.setProperty("visibility", "visible");
}

if (d.tooltip) {
tooltipElement!.open = true;
tooltipElement!.target = event.target as HTMLElement;
tooltipTextElement!.innerText = d.tooltip;
}
})
.on("mouseleave", (event: MouseEvent, d) => {
(event.target as HTMLElement).setAttribute("stroke-width", "2");
if (d.label && d.showLabelOn !== "click") {
const linkLabel = element.shadowRoot!.querySelector<SVGTextElement>(
`[id="${d.id}-link-text"]`
);
linkLabel!.style.setProperty("visibility", "hidden");
}

event.stopPropagation();
tooltipElement!.open = false;
tooltipTextElement!.innerText = "";
});

links
.selectAll("text.link-label")
.data(filteredlinks)
.join("text")

.attr("dy", "-4")
.attr("class", "link-label lineage-element")
.attr("id", function (d) {
return `${d.id}-link-text`;
})
.append("textPath")
.attr("startOffset", "50%")
.attr("text-anchor", "middle")
.attr("xlink:href", d => {
return `#${d.id}`;
})
.attr("fill", "var(--color-text-default)")
.text(d => {
return `${d.label}`;
});

links
.append("circle")
Expand Down
6 changes: 6 additions & 0 deletions packages/flow-lineage/src/components/f-lineage/f-lineage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,10 @@
drop-shadow(0 -1px 0 var(--color-primary-default))
drop-shadow(0 1px 0 var(--color-primary-default));
}
.link {
cursor: pointer;
}
.link-label {
visibility: hidden;
}
}
3 changes: 3 additions & 0 deletions packages/flow-lineage/src/components/f-lineage/f-lineage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@ export class FLineage extends FRoot {
></f-icon-button
><slot name="node-meta" @slotchange=${this._onPopoverSlotChange}></slot></f-div
></f-popover>
<f-tooltip placement="auto" id="lineage-tooltip">
<f-text variant="para" size="small" id="lineage-tooltip-text"> </f-text>
</f-tooltip>
`;
}
connectedCallback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function highlightPath(node: LineageNodeElement, lineage: FLineag
});
}

root.querySelectorAll(`[id^="${id}->"]`).forEach(el => {
root.querySelectorAll(`[id^="${id}->"],[id="${id}-link-label"]`).forEach(el => {
el.classList.add("highlight");
el.classList.remove("lowlight");
const fromid = el.getAttribute("id")?.split("->")[1];
Expand Down Expand Up @@ -75,7 +75,7 @@ export default function highlightPath(node: LineageNodeElement, lineage: FLineag
});
}

root.querySelectorAll(`[id$="->${id}"]`).forEach(el => {
root.querySelectorAll(`[id$="->${id}"],[id="${id}-link-label"]`).forEach(el => {
el.classList.add("highlight");
el.classList.remove("lowlight");
const fromid = el.getAttribute("id")?.split("->")[0];
Expand All @@ -89,6 +89,10 @@ export default function highlightPath(node: LineageNodeElement, lineage: FLineag
el.classList.add("highlight");
el.classList.remove("lowlight");
});
root.querySelectorAll(`[id$="->${id}-link-text"]`).forEach(el => {
el.classList.add("highlight");
el.classList.remove("lowlight");
});
root.querySelectorAll(`[data-parent-id$="->${id}"]`).forEach(el => {
el.classList.add("highlight");
el.classList.remove("lowlight");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export type LineageLinkElement = {
source: LineageNodeElement;
target: LineageNodeElement;
level: number;
label?: string;
tooltip?: string;
showLabelOn?: "click" | "hover";
fClick?: (event: Event, node: LineageLinkElement) => void;
};

export type LineageDirection = "horizontal" | "vertical";
Expand Down Expand Up @@ -141,6 +145,10 @@ export type LineageNodes = Record<string, LineageNodePartial>;
export type LineageNodeLinkSchema = {
from: string;
to: string;
showLabelOn?: "click" | "hover";
label?: string;
tooltip?: string;
fClick?: (event: Event, node: LineageLinkElement) => void;
state?: "success" | "danger" | "warning" | "primary" | "default";
type?: "solid" | "dotted" | "dashed";
};
Expand Down
10 changes: 8 additions & 2 deletions stories/flow-lineage/f-lineage.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FLineage, LineageNodeElement } from "@ollion/flow-lineage";
import { FLineage, LineageLinkElement, LineageNodeElement } from "@ollion/flow-lineage";
import { html } from "lit-html";
import { createRef, ref } from "lit/directives/ref.js";

Expand Down Expand Up @@ -166,7 +166,13 @@ export const Playground = {
links: [
{
from: "Tony",
to: "Charlie"
to: "Charlie",
label: "Tony to charlie",
tooltip: "Link tooltip",
// showLabelOn: "click",
fClick(event: Event, d: LineageLinkElement) {
console.log("link fClick", event, d);
}
},
{
from: "Charlie",
Expand Down

0 comments on commit ad912ec

Please sign in to comment.