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

Theme "Advanced" Usage ... Under Construction. #7

Open
nelsonic opened this issue Jul 23, 2024 · 5 comments
Open

Theme "Advanced" Usage ... Under Construction. #7

nelsonic opened this issue Jul 23, 2024 · 5 comments
Labels
chore a tedious but necessary task often paying technical debt discuss Share your constructive thoughts on how to make progress with this issue help wanted If you can help make progress with this issue, please comment! T1h Time Estimate 1 Hour tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written technical A technical issue that requires understanding of the code, infrastructure or dependencies

Comments

@nelsonic
Copy link
Member

Trying to customise the theme of our Nextra site to change the <footer> which defaults to:
"MIT 2024 © Nextra."

nextra-footer-default

Reading the Footer docs: https://nextra.site/docs/docs-theme/theme-configuration#footer

image
export default {
  footer: {
    text: (
      <span>
        MIT {new Date().getFullYear()} ©{' '}
        <a href="https://nextra.site" target="_blank">
          Nextra
        </a>
        .
      </span>
    )
  }
}
nextra-footer-updated

But given that this is a <text> attribute, Nextra is still controlling the appearance in the <footer>.
This is the markup that is rendered:

nextra-footer-markup

What I want is to control the <footer> completely. I don't just want to update the <text> ...
So I went back to the Nextra docs to try and use a <Component> for the <footer> ... nothing. 🤷‍♂️ 😢
Googled for a bit and found: shuding/nextra#2926 (comment)
image

"You might have to experiment with specific css selectors" ...

He links to: https://nextra.site/docs/custom-theme#advanced-usage
advanced-usage-under-construction

Under construction ... 🚧
This is such a time-suck! 😢
I've spent waaaay too much time on this! ⏳
just want a good-looking <footer> ... is that too much to ask?! 🤷‍♂️
I tried the CSS selectors approach and it was hell 😡
I don't want to have to use 50 important! statements
to attempt to override the inline Tailwind styles ... it's horrible! 🤦‍♂️
Just going to have to leave it ugly for now. 🙈
And maybe return to this later. ⏳

@nelsonic nelsonic added help wanted If you can help make progress with this issue, please comment! discuss Share your constructive thoughts on how to make progress with this issue technical A technical issue that requires understanding of the code, infrastructure or dependencies tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written chore a tedious but necessary task often paying technical debt T1h Time Estimate 1 Hour labels Jul 23, 2024
@nelsonic
Copy link
Member Author

Tried creating a custom component but Nextra didn't like it:

image
Module parse failed: Unexpected token (2:9)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| export default function footerComponent() {
>   return <h1>Test</h1>;
| }
|

@anuragmitra4
Copy link

anuragmitra4 commented Aug 21, 2024

After some framework fighting and looking at some source code, seems like the way to customize the footer (or any component) is to use tailwind classes with a nx- prefix.

As an example, I tried to update the project.icon component:

import { Avatar, AvatarImage } from "./components/ui/avatar";
import { Button } from "./components/ui/button";
import { ChevronDown } from "lucide-react";

const config = {
  project: {
    link: "https://github.com/shadcn.png",
    icon: (
      <Button className="nx-flex nx-items-center">
        <Avatar className="nx-h-8 nx-h-8 nx-relative nx-flex nx-shrink-0 nx-overflow-hidden nx-rounded-full">
          <AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
        </Avatar>

        <p className="nx-flex nx-flex-col nx-ml-2 nx-text-left nx-text-xs sm:nx-block hidden">
          <strong className="block font-medium">Shadcn</strong>
          <span className="text-gray-500">shadcnui.com</span>
        </p>

        <ChevronDown className="nx-m-0.5 nx-h-4 nx-w-4" />
      </Button>
    ),
  },
};

export default config;

to get
Screenshot 2024-08-21 at 4 59 50 PM

@anuragmitra4
Copy link

Update: After doing some more testing, the situation is made worse by the fact that tailwind only packages the classes being used by the nextra-docs-theme package. So, if the package has never referenced nx-bg-gray-700, you will not be able to use that class using tailwind. Quite frustrating.

@nelsonic
Copy link
Member Author

Beyond frustrating. Makes any customisation take way longer than it should. ⏳

@nelsonic
Copy link
Member Author

Yeah, the nx- prefix for all TailwindCSS classes is a horrible choice for extensibility 🙅
makes reusing components from the "frontend" (Next.js App) extra difficult
as we have to manually add the prefix or load a second instance of Tailwind. 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore a tedious but necessary task often paying technical debt discuss Share your constructive thoughts on how to make progress with this issue help wanted If you can help make progress with this issue, please comment! T1h Time Estimate 1 Hour tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects
None yet
Development

No branches or pull requests

2 participants