Skip to content

Commit c84e53e

Browse files
committed
Types - Add createTSpan utility function signature
1 parent 5c3af84 commit c84e53e

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

types/vue-data-ui.d.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6874,4 +6874,50 @@ declare module "vue-data-ui" {
68746874
* @returns The shifted color in hexadecimal format.
68756875
*/
68766876
export const shiftColorHue: (color: string, strength: number) => string;
6877+
6878+
export type CreateTSpansArgs = {
6879+
content: string;
6880+
fontSize: number;
6881+
fill: string;
6882+
maxWords: number;
6883+
x: number;
6884+
y: number;
6885+
}
6886+
6887+
/**
6888+
* Vue Data UI utility
6889+
* ---
6890+
* Creates TSpan elements from a string to break text into multiple lines.
6891+
* The output should be placed with `v-html` inside an SVG `<text>` element.
6892+
* ___
6893+
* @example
6894+
* const textContent = createTSpans({
6895+
* content: "This is an example of multiline text",
6896+
* fontSize: 16,
6897+
* fill: "#1A1A1A",
6898+
* maxWords: 3, // Will create lines of 3 words max
6899+
* x: 10,
6900+
* y: 20
6901+
* });
6902+
*
6903+
* // Usage: <text :x="10" :y="20" fill="#1A1A1A" :font-size="16" v-html="textContent"/>
6904+
*
6905+
* @param {Object} args - The arguments object.
6906+
* @param {string} args.content - The text content to be split into lines.
6907+
* @param {number} args.fontSize - The font size used to determine line spacing.
6908+
* @param {string} args.fill - The fill color for the text.
6909+
* @param {number} args.maxWords - Maximum number of words per line.
6910+
* @param {number} args.x - The x-coordinate for each `tspan` element.
6911+
* @param {number} args.y - The starting y-coordinate for the first `tspan`.
6912+
*
6913+
* @returns {string} A string containing the HTML content to be placed with `v-html` inside an SVG `<text>` element.
6914+
*/
6915+
export const createTSpans: ({
6916+
content,
6917+
fontSize,
6918+
fill,
6919+
maxWords,
6920+
x,
6921+
y
6922+
}: CreateTSpansArgs) => string;
68776923
}

0 commit comments

Comments
 (0)