Skip to content

Conversation

@KavanBhavsar35
Copy link

Summary

Fixes #676
This PR introduces an optional words prop to the True Focus component, allowing developers to pass a custom array of words (or space tokens) for precise spacing control.


Changes

  • Added new optional prop: words?: string[]
  • If words is provided, it is used directly instead of splitting sentence via .split(" ")
  • Updated component logic accordingly
  • Updated propData and registry entry to document the new prop
  • Backward compatible: existing sentence usage works as before

Motivation

Currently, multiple spaces between words are collapsed because of .split(" ").
This new prop allows full flexibility:

<TrueFocus
  words={["Full Stack", "DevOps"]}
/>

…cing control

Added optional words prop to True Focus component
Falls back to splitting sentence when words not provided
Enables developers to control spacing precisely between words
Maintains backward compatibility
@DavidHDev
Copy link
Owner

It makes zero sense to have two ways of providing the text. If you want this merged, clean up the "sentence" prop and its usage.

Also, be 100% sure nothing is broken by your changes by thoroughly testing locally.

@DavidHDev DavidHDev requested a review from Copilot November 9, 2025 08:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an optional words prop to the TrueFocus component, allowing users to pass a pre-split array of words/tokens instead of relying solely on the default space-based sentence splitting. This provides better control over spacing and tokenization.

Key Changes

  • Added optional words?: string[] prop to component interfaces/parameters
  • Renamed internal words variable to wordList to avoid naming collision
  • Updated wordList initialization to prioritize the words prop over splitting sentence

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/ts-tailwind/TextAnimations/TrueFocus/TrueFocus.tsx Added words prop and refactored to use wordList variable
src/ts-default/TextAnimations/TrueFocus/TrueFocus.tsx Added words prop and refactored to use wordList variable
src/tailwind/TextAnimations/TrueFocus/TrueFocus.jsx Added words prop and refactored to use wordList variable
src/content/TextAnimations/TrueFocus/TrueFocus.jsx Added words prop and refactored to use wordList variable
src/demo/TextAnimations/TrueFocusDemo.jsx Documented the new words prop in the demo
public/r/TrueFocus-TS-TW.json Updated registry file with new component code
public/r/TrueFocus-TS-CSS.json Updated registry file with new component code
public/r/TrueFocus-JS-TW.json Updated registry file with new component code
public/r/TrueFocus-JS-CSS.json Updated registry file with new component code

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

pauseBetweenAnimations = 1
}) => {
const words = sentence.split(' ');
const wordList = Array.isArray(words) && words.length > 0 ? words : sentence.split(' ');
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The words prop should be included in the dependency arrays of the useEffect hooks to ensure the component properly re-renders when words changes. Currently, only wordList.length is tracked, which won't detect changes if the words prop reference changes but maintains the same length.

Copilot uses AI. Check for mistakes.
pauseBetweenAnimations = 1
}) => {
const words = sentence.split(' ');
const wordList = Array.isArray(words) && words.length > 0 ? words : sentence.split(' ');
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The words prop should be included in the dependency arrays of the useEffect hooks to ensure the component properly re-renders when words changes. Currently, only wordList.length is tracked, which won't detect changes if the words prop reference changes but maintains the same length.

Copilot uses AI. Check for mistakes.
pauseBetweenAnimations = 1
}) => {
const words = sentence.split(' ');
const wordList = Array.isArray(words) && words.length > 0 ? words : sentence.split(' ');
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The words prop should be included in the dependency arrays of the useEffect hooks to ensure the component properly re-renders when words changes. Currently, only wordList.length is tracked, which won't detect changes if the words prop reference changes but maintains the same length.

Copilot uses AI. Check for mistakes.
pauseBetweenAnimations = 1
}) => {
const words = sentence.split(' ');
const wordList = Array.isArray(words) && words.length > 0 ? words : sentence.split(' ');
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The words prop should be included in the dependency arrays of the useEffect hooks to ensure the component properly re-renders when words changes. Currently, only wordList.length is tracked, which won't detect changes if the words prop reference changes but maintains the same length.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: text-animations/true-focus

2 participants