Skip to content

refactor: extract redundant max-width into utility#525

Merged
satnaing merged 2 commits into
mainfrom
refactor/extract-max-width-for-better-customization
Jun 9, 2025
Merged

refactor: extract redundant max-width into utility#525
satnaing merged 2 commits into
mainfrom
refactor/extract-max-width-for-better-customization

Conversation

@satnaing

@satnaing satnaing commented Jun 7, 2025

Copy link
Copy Markdown
Owner

Extract redundant max-width into a universal tailwind utility class. By doing so, the width of the layout in different pages can be customized easily.

Demo

extracted-max-w-demo.mp4

Types of changes

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Documentation Update (if none of the other choices apply)
  • Others (any other types not listed above)

Checklist

  • I have read the Contributing Guide
  • I have added the necessary documentation (if appropriate)
  • Breaking Change (fix or feature that would cause existing functionality to not work as expected)

Remark

Obviously, there's a problem with BackToTop button.
Currently, we have to update the position property inside the BackToTop button when we update the max-w-app.
There's gonna be a PR for that.

Related PR & discussion

#490 #436

Extract redundant max-width into a universal tailwind
utility class. By doing so, the width of the layout
in different pages can be customized easily.
@fre-ben

fre-ben commented Jun 7, 2025

Copy link
Copy Markdown
Contributor

Great idea!

@eerison

eerison commented Jun 7, 2025

Copy link
Copy Markdown
Contributor

Hi @satnaing thank you to move this feature forward,

I am trying to test your branch locally, but I am getting this error

> astro-paper@5.2.0 dev
app-1  | > astro dev --host 0.0.0.0
app-1  | 
app-1  | [config] Astro found issue(s) with your configuration:
app-1  | 
app-1  | ! image.experimentalLayout: Invalid enum value. Expected 'constrained' | 'fixed' | 'full-width' | 'none', received 'responsive'
app-1  | 
app-1  | ! experimental: Invalid or outdated experimental feature.
app-1  |   Check for incorrect spelling or outdated Astro version.
app-1  |   See https://docs.astro.build/en/reference/experimental-flags/ for a list of all current experiments.

edit: I guess it is related with #521
edit 2: After apply the changes like in this PR #521, it worked!

@eerison

eerison commented Jun 7, 2025

Copy link
Copy Markdown
Contributor

It is doing exactly what I was wanting ❤️

in case I want to build another layout like mantioned here: #436, it is possible 🥳

Screenshot from 2025-06-07 12-25-46

Just one point but it is not direct related with this PR, But maybe we could replace those hr (https://github.com/satnaing/astro-paper/blob/main/src/components/Hr.astro) for a bottom line in css. in this way I can remove the line if I need :)

@satnaing

satnaing commented Jun 7, 2025

Copy link
Copy Markdown
Owner Author

Hi @eerison

in case I want to build another layout like mantioned here: #436, it is possible 🥳

Yes, exactly.
In terms of the layout width, you now have a lot of flexibility. For example, we can target specific breakpoints easily.

@utility max-w-app {
  @apply max-w-3xl lg:max-w-5xl xl:max-w-full;
}

I don't recommend doing "full-screen" for blog posts tho; as it will affect the readability and user experience.
If we want to have the layout shown in #436, we'll have to do some more customizations.
But it can be done with the current styling solution.

@eerison

eerison commented Jun 7, 2025

Copy link
Copy Markdown
Contributor

Hi @eerison

in case I want to build another layout like mantioned here: #436, it is possible 🥳

Yes, exactly. In terms of the layout width, you now have a lot of flexibility. For example, we can target specific breakpoints easily.

@utility max-w-app {
  @apply max-w-3xl lg:max-w-5xl xl:max-w-full;
}

I don't recommend doing "full-screen" for blog posts tho; as it will affect the readability and user experience. If we want to have the layout shown in #436, we'll have to do some more customizations. But it can be done with the current styling solution.

I guess it's a good start 😁

@eerison

eerison commented Jun 7, 2025

Copy link
Copy Markdown
Contributor

And what about Hr component?

@satnaing

satnaing commented Jun 7, 2025

Copy link
Copy Markdown
Owner Author

Just one point but it is not direct related with this PR, But maybe we could replace those hr (https://github.com/satnaing/astro-paper/blob/main/src/components/Hr.astro) for a bottom line in css. in this way I can remove the line if I need :)

You meant something like border-b?
If so, I prefer the component <Hr />. It's more semantic. Plus, you don't need to touch css classes if you want to add or remove those lines. You just have to remove the <Hr /> component.
But let me know if you think otherwise. @eerison

@eerison

eerison commented Jun 7, 2025

Copy link
Copy Markdown
Contributor

Yeah i know I can remove the Component, but the problem with this is, I gonna change files from astro-paper repository, and I want to avoid this, because it gonna be a way easier to update my repository... if i keep doing custom changes in many files I gonna get many conflicts :/

For this reason I would like to change this via css, because I could just keep changes in one file.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 7, 2025

Copy link
Copy Markdown

Deploying astro-paper with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6dc3609
Status: ✅  Deploy successful!
Preview URL: https://c25f4eae.astro-paper.pages.dev
Branch Preview URL: https://refactor-extract-max-width-f.astro-paper.pages.dev

View logs

@satnaing

satnaing commented Jun 8, 2025

Copy link
Copy Markdown
Owner Author

@eerison
I got your point, and I think we could replace unnecessary <Hr /> with border styling.
The issue is that a lot of code and layout structures need to be updated to achieve the same result as the current implementation.
Thus, I'll focus on other issues for now. In the future, I'll look into that issue again.

@eerison

eerison commented Jun 8, 2025

Copy link
Copy Markdown
Contributor

I don't recommend doing "full-screen" for blog posts tho;

Hey @satnaing

just a question is it possible apply different max-w-* by pages?
like in index (#main-content) uses max-w-full and others pages keep the default one (max-w-3xl) ?

@satnaing

satnaing commented Jun 9, 2025

Copy link
Copy Markdown
Owner Author

just a question is it possible apply different max-w-* by pages?
like in index (#main-content) uses max-w-full and others pages keep the default one (max-w-3xl) ?

@eerison

Technically, yes.
I've seen some AstroPaper-based blogs with customized full-screen layouts.
However, to do so, the user needs to be able to do custom CSS styling.
The hard part is that it wouldn't be as easy as updating a custom class.

@satnaing
satnaing merged commit 5f72b93 into main Jun 9, 2025
6 checks passed
@satnaing
satnaing deleted the refactor/extract-max-width-for-better-customization branch June 9, 2025 04:42
miyayaLora pushed a commit to miyayaLora/astro-paper-zed-like that referenced this pull request Jun 27, 2025
* refactor: extract redundant max-width into utility

Extract redundant max-width into a universal tailwind
utility class. By doing so, the width of the layout
in different pages can be customized easily.

* docs: update docs for modifying `max-w-app` utility

(cherry picked from commit 5f72b93)
jxgla pushed a commit to jxgla/astro-paper that referenced this pull request Mar 10, 2026
* refactor: extract redundant max-width into utility

Extract redundant max-width into a universal tailwind
utility class. By doing so, the width of the layout
in different pages can be customized easily.

* docs: update docs for modifying `max-w-app` utility
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