Skip to content
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

✨ GC-1464 Remember the last resize position #1305

Merged
merged 5 commits into from
Sep 29, 2023

Conversation

timbryandev
Copy link
Contributor

💬 Description

Builds on the new Resizable component. This PR adds a new useLocalStorage hook to record the last width a component may have been resized to and can be restored to using that locally recorded value.

Uses the new rememberPosition boolean prop to enable the functionality, and will use the new optional id string prop to record instances uniquely.

Added a new story too to demonstrate usage.

Copy link
Contributor

@micmcgrorty micmcgrorty left a comment

Choose a reason for hiding this comment

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

Awesome stuff 🙌

const [localStorageValue, setLocalStorageValue] = useState(() => {
try {
// Try and retrieve any previously recorded values
const value = localStorage.getItem(key);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could name this currentValue/previousValue and then just do away with the comments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good feedback! I've renamed and refactored out the comments, especially in the catch as its pretty clear we're using the default in the catch :D

@timbryandev timbryandev merged commit e6e83c3 into main Sep 29, 2023
2 checks passed
@timbryandev timbryandev deleted the feature/GC-1464_remember-resize-position branch September 29, 2023 14:24
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.

3 participants