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 document outline mobile view #369

Merged
merged 12 commits into from May 21, 2024
Merged

Conversation

agoose77
Copy link
Collaborator

@agoose77 agoose77 commented Apr 23, 2024

Fixes #363 by moving the document outline to the main body of the page.

image

  • I've added a new types.ts file that declares the template option interface.
  • I've moved ArticlePage from @myst-theme/site to themes/book (to mirror the one already copied to themes/article.
  • I've added hide_outline and outline_maxdepth to the article theme options

I need to understand why the article theme has its own implementation of ArticlePage, instead of re-using that from @myst-theme/site. Perhaps @stevejpurves could shed some light? :)

@agoose77 agoose77 marked this pull request as draft April 23, 2024 10:32
@agoose77
Copy link
Collaborator Author

@stevejpurves I've replicated the DocumentOutline logic for both article and book themes; now, only the article differs in that it has supporting downloads too.

It feels like Article is a fairly high-level component that is theme specific. I wonder if we should just move Article from @myst-theme/site into the book theme (such that the article and book themes have their own independent versions). What do you think about that suggestion? Is there something I'm missing?

@agoose77
Copy link
Collaborator Author

OK, I decided to make that change; I assume that as we built out the themes, it became clear that the article theme needed its own ArticlePage, and from there we have been left with the type in @myst-theme.

@agoose77
Copy link
Collaborator Author

I've seen that this is a place where we have project, site, and page frontmatter. I haven't gone through these changes super carefully, so any reviewer would be welcome to cast an eye.

@agoose77 agoose77 self-assigned this Apr 24, 2024
@rowanc1
Copy link
Member

rowanc1 commented Apr 24, 2024

We have 3-4 themes that are dependent on that export from site, anything in book/article cannot be exported.

@agoose77
Copy link
Collaborator Author

Hmm, OK. @rowanc1 can you nudge on whether the core site export should include this change, or whether I should fork it for the book export?

@rowanc1
Copy link
Member

rowanc1 commented Apr 24, 2024

I will take a more in depth look/test later this week. I forgot that we had forked the articlePage for the article theme already, so this is in family with those changes. I suppose the general advice is that exportable things need to be in the site package. So it is possible that we move both of these back down, and provide variants there?

@agoose77
Copy link
Collaborator Author

agoose77 commented Apr 24, 2024

Sure, that's an idea! It might just be that the difference between the two is the addition of downloads. But I also feel that it makes sense eventually for articles and books to be "different" at the page level.

@agoose77 agoose77 force-pushed the agoose77/wip-outline-inline branch from 08554a3 to d2bb502 Compare May 10, 2024 15:00
@agoose77 agoose77 marked this pull request as ready for review May 10, 2024 15:00
@agoose77
Copy link
Collaborator Author

@rowanc1 I'm actually thinking that we shouldn't try and have an ArticlePage in the site package. These article pages are built from published components, so users can already re-implement them fairly easily. I think the differences between articles and book pages should better be described by distinct components instead of a "meta" component that encodes the logic for both variants.

Are you OK with that change; dropping the Article from @myst-theme/site?

@agoose77 agoose77 requested a review from rowanc1 May 10, 2024 15:16
@stevejpurves
Copy link
Member

@agoose77 I think that suggestion was not to have a single ArticlePage meta component that encoded both sets of changes but indeed to have two distinct page components available in site by moving the article-theme version up to the package too?

That's leaves us with some naming to sort out but then provides two jumping off points for existing page patterns to be used in downstream themes...?

Copy link
Member

@fwkoch fwkoch left a comment

Choose a reason for hiding this comment

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

Tried this out locally and the mobile view works great, outline appears at the top as expected and the various options seem to be picked up correctly.

Just summarizing from the discussion here, though, I think we need to keep the existing ArticlePage, etc, exports from @myst-theme/site, so we don't break dependencies from other external themes. @agoose77 - if you think the correct direction is for each theme to define it's own ArticlePage, I think it's fine to leave your new book/.../ArticlePage.tsx so book theme no longer needs to import it from @myst-theme/site. But there isn't any reason to delete the old version from there (can even mark it as deprecated?).

This means we won't be breaking dependencies for external themes; we will just be setting an example of how to do things better, and they can upgrade as they see fit.

Other than that and the template option I mentioned in my other comment, all this needs is a changeset, then should be good to go!

themes/book/app/types.ts Show resolved Hide resolved
@agoose77
Copy link
Collaborator Author

@fwkoch this is a really helpful review, thank you (and also to @rowanc1).

Could you perhaps help nudge this over the line with the deprecation logic?

Copy link
Member

@fwkoch fwkoch left a comment

Choose a reason for hiding this comment

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

@agoose77 - thanks for the updates! This is all I was thinking regarding deprecation: https://github.com/executablebooks/myst-theme/blob/agoose77/wip-outline-inline/packages/site/src/pages/Article.tsx#L45

Should all be good to go now, as far as I'm concerned.

@agoose77
Copy link
Collaborator Author

Are you comfortable merging this? Or would you like a separate review e.g. from @stevejpurves?

@stevejpurves stevejpurves self-requested a review May 21, 2024 15:40
@fwkoch fwkoch merged commit 792f9f5 into main May 21, 2024
2 checks passed
@fwkoch fwkoch deleted the agoose77/wip-outline-inline branch May 21, 2024 15:41
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.

Show "on this page" navigation menu for in-page navigation on mobile
4 participants