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

Add font menu previews and virtual scrolling #650

Merged
merged 28 commits into from
Jun 10, 2022
Merged

Add font menu previews and virtual scrolling #650

merged 28 commits into from
Jun 10, 2022

Conversation

0HyperCube
Copy link
Member

@0HyperCube 0HyperCube commented May 19, 2022

Closes #596
fontpreview

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented May 19, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 13e645b
Status: ✅  Deploy successful!
Preview URL: https://bec95788.graphite-master.pages.dev
Branch Preview URL: https://font-prieviews.graphite-master.pages.dev

View logs

@Keavon
Copy link
Member

Keavon commented May 19, 2022

I'm heavily refactoring these files right now so hopefully this won't be too hard to port over the changes once I'm ready to merge mine.

@0HyperCube
Copy link
Member Author

Oh right sorry.

@Keavon
Copy link
Member

Keavon commented May 19, 2022

Nothing to apologize for! Just giving you an update on the status. This looks like an exciting feature!

@Keavon
Copy link
Member

Keavon commented May 23, 2022

For the record, but not relevant in this PR:

My plan for the design of the FontInput widget will involve using a single component that encapsulates two DropdownInputs. (And from a UI/UX standpoint, we'll tailor it more closely to provide useful font-related things, like a search box to filter the list and a button to upload fonts).

By making the one component use the two DropdownInput components as children, we can avoid duplicating code used by the DropdownInput component and avoid needing to check this.isStyle to change behavior depending on the intention of this FontInput component instance.

Just mentioning this for future reference.

@Keavon
Copy link
Member

Keavon commented May 23, 2022

It would also be a cool feature to display the font weight as a preview.

@Keavon Keavon force-pushed the master branch 2 times, most recently from a86fd02 to fd95326 Compare May 26, 2022 07:28
@Keavon
Copy link
Member

Keavon commented May 26, 2022

If you get a chance to fix the merge conflicts, I think this should be pretty quick to get merged since it has a great UX/behavior already. (I'll just skim over the code but there's probably nothing major to change.)

@0HyperCube 0HyperCube requested a review from Keavon June 5, 2022 14:58
Copy link
Member

@Keavon Keavon left a comment

Choose a reason for hiding this comment

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

Welcome back from your vacation! :)

editor/src/dialog/dialogs/export_dialog.rs Outdated Show resolved Hide resolved
editor/src/document/document_message_handler.rs Outdated Show resolved Hide resolved
frontend/src/components/widgets/inputs/FontInput.vue Outdated Show resolved Hide resolved
frontend/src/components/widgets/inputs/FontInput.vue Outdated Show resolved Hide resolved
Comment on lines 72 to 76
return {
state: readonly(state) as typeof state,
fontNames,
getFontStyles,
getFontFileUrl,
};
Copy link
Member

Choose a reason for hiding this comment

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

I may have misdirected you about this being an I/O manager. The format for all I/O managers is that they must return from their constructor either nothing or a single destructor function. Not an object with several functions. I don't think utility-functions is the correct folder for this either, though, because those are all stateless single-purpose functions. Feel free to read frontend/src/README.md for a bit more detail on each of these types. Do you think this could maybe be restructured to fit the conventions for any of the others? I assume you can't make this stateless to work with utility-functions. Maybe the getter functions could be changed into entries for the state object and this could become a state provider again? Happy to discuss this further, I don't mean to misdirect you again.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why should they become entries in a state object? This would be additional complexity for no gain.

Copy link
Member

Choose a reason for hiding this comment

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

I'm just trying to figure out how we can make it match the code style of the other files to avoid confusing inconsistency. My idea about state was that, perhaps instead of exposing these getter functions, we can instead just bind the current value to the state object so users can replace their getter function calls with reading the state values? I don't know if that is the right approach here or not, but just an idea. If you'd like to talk more about this on Discord, we can probably settle it out real quick, I just want to make sure we're using our frontend architecture in a not-inconsistent way.

@Keavon
Copy link
Member

Keavon commented Jun 9, 2022

Done with this round of code review comments. I'll look more closely at FontInput.vue once you move some of the functions in there to MenuList.vue or remove them if they're redundant. I'm very happy we get to implement virtual scrolling in this PR! We were needing that for performance reasons.

@Keavon
Copy link
Member

Keavon commented Jun 10, 2022

Hmm...

capture_2_.mp4

@Keavon Keavon changed the title Font previews Add font menu previews and virtual scrolling Jun 10, 2022
@Keavon
Copy link
Member

Keavon commented Jun 10, 2022

Awesome! There's only one very minor polishing behavior I'd like to eventually fix, but it's probably worth leaving for a later date. When you scroll, once you reach the bottom of a loaded chunk, it bottoms out and doesn't let you keep scrolling with the mouse wheel until you move your cursor by a pixel. Kind of strange. But I'm happy to merge this now unless you prefer to take a poke at that real quick.

@Keavon Keavon merged commit c0bac28 into master Jun 10, 2022
@Keavon Keavon deleted the font-prieviews branch June 10, 2022 22:21
@0HyperCube
Copy link
Member Author

When you scroll, once you reach the bottom of a loaded chunk, it bottoms out and doesn't let you keep scrolling with the mouse wheel until you move your cursor by a pixel. Kind of strange. But I'm happy to merge this now unless you prefer to take a poke at that real quick.

That is quite odd - this does not happen on firefox but I can reproduce it on chromium. The loaded chunk is just the 21 visible entries (you can see 21 x 20px entries in the 400px height if the scroll is not offset by a multiple of 20) so this doesn't happen when you reach the end of that.

Keavon added a commit that referenced this pull request Jun 16, 2022
* Keyboard menu navigation

* Fix dropdown keyboard navigation

* Fix merge error

* Some code review

* Interactive dropdowns

* Query by data attr not class name

* Add locking behaviour

* Add font prieviews

* Remove blank line in css

* Use default for interactive in struct

* Use menulist for fontinput

* Polish

* Rename state -> manager

* Code review

* Cleanup fontinput

* More cleanup

* Make fonts.ts an empty state

* Fix regression

Co-authored-by: Keavon Chambers <[email protected]>
Keavon added a commit that referenced this pull request Jul 30, 2023
* Keyboard menu navigation

* Fix dropdown keyboard navigation

* Fix merge error

* Some code review

* Interactive dropdowns

* Query by data attr not class name

* Add locking behaviour

* Add font prieviews

* Remove blank line in css

* Use default for interactive in struct

* Use menulist for fontinput

* Polish

* Rename state -> manager

* Code review

* Cleanup fontinput

* More cleanup

* Make fonts.ts an empty state

* Fix regression

Co-authored-by: Keavon Chambers <[email protected]>
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.

Preview fonts
2 participants