-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add scaled text input #1224
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
style={{ | ||
transform: `scale(${containerScale})`, | ||
width: `${100 / containerScale}%`, | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should try to refrain from using inline-styling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpcramer I think we are forced here to have the inline style. As this is a dynamic CSS story, which I don't think Tailwind has an easy solution for it.
@cpcramer this is also very similar on how CSS animation are built, where you have a basic class, but then use inline style to do crazy animaiton tricks.
import type { TextInputReact } from './TextInput'; | ||
import { TextInput } from './TextInput'; | ||
|
||
export function ScaledTextInput(props: TextInputReact) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some comments that explain when to use ScaledTextInput
vs TextInput
?
import type { TextInputReact } from './TextInput'; | ||
import { TextInput } from './TextInput'; | ||
|
||
export function ScaledTextInput(props: TextInputReact) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some comments that explain when to use ScaledTextInput
vs TextInput
?
} else { | ||
setContainerScale(1); | ||
} | ||
}, [props.value]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open question, could this re-fire too many times if we keep props.value
too wide?
export function ScaledTextInput(props: TextInputReact) { | ||
const inputContainer = useRef<HTMLDivElement | null>(null); | ||
const offscreenRef = useRef<HTMLSpanElement | null>(null); | ||
const [containerScale, setContainerScale] = useState(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Help me understand what this number means. Maybe with a line of comment.
return ( | ||
<> | ||
<div ref={inputContainer}> | ||
<div |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be done with just 1 <div>
instead of 2?
<TextInput {...props} /> | ||
</div> | ||
</div> | ||
<span |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
closing in favor of increasing the padding between the value and select and keeping the current scroll behavior, cc: @mindapivessa |
What changed? Why?

Notes to reviewers
How has it been tested?