-
Notifications
You must be signed in to change notification settings - Fork 84
feat: support overriding TopBar
#112
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
Conversation
|
5139ae3
to
a5307f6
Compare
--- | ||
title: 'Overriding Components' | ||
description: "Override TutorialKit's default components to fit your needs." | ||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These docs are highly inspired by Starlight: https://starlight.astro.build/guides/overriding-components/
7141020
to
9700943
Compare
I spent some time trying to set up tests for this kind of features but it seemed a bit bigger task than I expected. I don't think there are any existing tests where this feature could be easily tested..? Let's build good testing setup in separate PR later. Next I'll look into adding overrides for other components so that rest of the feature requests can be filled. For example the bottom-left corners "Edit this page" link. |
I totally agree. In particular I think this would be easy to test if we had playwright or puppeteer configured. |
Yep! I had something like this in mind: import { fileURLToPath } from "node:url";
import { beforeAll, expect, test } from "vitest";
import { type Browser, chromium } from "playwright";
import { dev } from "astro";
let browser: Browser;
beforeAll(async () => {
// Start server
const server = await dev({
configFile: false,
root: fileURLToPath(new URL("./fixtures", import.meta.url)),
integrations: [
tutorialkit({
components: {
TopBar: "./src/components/CustomTopBar.astro",
},
}),
],
});
// Open browser
browser = await chromium.launch({ headless: true });
// Close server
return async function cleanup() {
await server.stop();
};
});
test("custom top bar is visible", async () => {
const page = await browser.newPage();
await page.goto("http://localhost:4321/");
await page.getByRole("heading", {
level: 1,
name: "Custom top bar",
});
}); But TutorialKit had some issues when used from Astro's Node API and changing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good and the docs are top notch!! 🤩
Left a few comments, the more important being to consider the impact of doing an eject
.
docs/tutorialkit.dev/src/content/docs/guides/overriding-components.mdx
Outdated
Show resolved
Hide resolved
docs/tutorialkit.dev/src/content/docs/guides/overriding-components.mdx
Outdated
Show resolved
Hide resolved
docs/tutorialkit.dev/src/content/docs/guides/overriding-components.mdx
Outdated
Show resolved
Hide resolved
docs/tutorialkit.dev/src/content/docs/guides/overriding-components.mdx
Outdated
Show resolved
Hide resolved
6267cde
to
f955653
Compare
f955653
to
01dd492
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one!
bf47282
to
ce0a6ec
Compare
ce0a6ec
to
c73dcf5
Compare
Tests on Windows CI were failing but it's fixed now. ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, really good work on this!! 🤩
Adds support for overriding
TopBar
component. In future we can add support for more component overrides.Users may still want to utilize TutorialKit's default
<Logo>
and<ThemeSwitch>
. These are accessible through slots: