diff --git a/README.md b/README.md index ef3b468..11a2114 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,10 @@ The package exports a function called `createTelescopicText` that returns a HTML Basic usage may look something like this: ```html + + + +
+``` + +## Types +```typescript +interface Content { + text: string // Original string content in the line + replacements: Line[] // Sections of the original text to replace/expand +} + +interface Line { + og: string // the original string to replace + new: string // the replacement string + replacements: Line[] // nested replacements to apply on the resultant line afterwards +} + +// Default function to create a new `
` node containing the +// telescoping text. +function createTelescopicText(content: Content[]) ``` \ No newline at end of file diff --git a/index.js b/index.js index 0863129..4ccca84 100644 --- a/index.js +++ b/index.js @@ -4,10 +4,10 @@ // interface Line { // og: string // the original string to replace // new: string // the replacement string -// replacement: Line[] // nested replacements to apply on the resultant line afterwards +// replacements: Line[] // nested replacements to apply on the resultant line afterwards // } // ``` -export function hydrate(line, node) { +function hydrate(line, node) { let lineText = line.text || line.og if (line.replacements.length > 0) { @@ -80,7 +80,7 @@ export function hydrate(line, node) { // replacements: Line[] // Sections of the original text to replace/expand // } // ``` -export function createTelescopicText(content) { +function createTelescopicText(content) { const letter = document.createElement("div") letter.id = "telescope" content.forEach(line => { @@ -94,4 +94,6 @@ export function createTelescopicText(content) { return letter } - +module.exports = { + createTelescopicText, hydrate +} \ No newline at end of file