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

Override components: TutorialContent #319

Open
iliakan opened this issue Sep 7, 2024 · 7 comments
Open

Override components: TutorialContent #319

iliakan opened this issue Sep 7, 2024 · 7 comments
Labels
enhancement New feature or request nice-to-have Not breaking anything but nice to have

Comments

@iliakan
Copy link

iliakan commented Sep 7, 2024

For information-only lessons without an editor, the text occupies the full width, which is too much.

Content-oriented websites, such as https://medium.com/ and others limit text width, they make it a narrow column with margins.

For example medium.com - it's 680px:

image

I'd like to do the same.

I can add width: 680; margin:auto using dev tools to get it, like this:
image

What is the correct way to do this? Without a need to patch tutorialkit?

I guess, this isn't just about me. Wide texts are usually fit into columns on most sites, hopefully there's a way =).

P.P.S. With an editor, another layout should apply, probably with the editor taking extra right space and no margin. This request is only about the "editor: false" layout.

@AriPerkkio
Copy link
Member

Does this layout look correct? https://stackblitz.com/~/edit/vitejs-vite-zhhoys?file=theme.css&file=src/content/tutorial/1-basics/1-introduction/1-welcome/content.md&terminal=dev

Add a theme.css and define your styles there:

html {
    background-color: var(--tk-background-primary);
}

body {
    max-width: 600px;
    margin-inline: auto;
}
---
type: lesson
title: Welcome to TutorialKit
editor: false
previews: false
terminal: false
---

# Welcom to TutorialKit

Lorem ipsum...

@iliakan
Copy link
Author

iliakan commented Sep 9, 2024

Thank you. I see it's easy to do, but this column in this layout encompasses the whole website, which is a bit different thing.

Usually, it's only the text which is columnized, while the header/footer remains wide.

Here's medium.com for example:

image

@AriPerkkio
Copy link
Member

How about adding it directly into the content.md and not use theme.css at all?

---
type: lesson
title: Welcome to TutorialKit
editor: false
previews: false
terminal: false
---

<div style="max-width: 680px; margin-inline: auto;">

# Welcom to TutorialKit

Lorem ipsum dolor...

</div>

@iliakan
Copy link
Author

iliakan commented Sep 9, 2024

...You mean add this to every content.md file?

Technically possible, but doesn't look good ;)

Making a column out of a wide text is very common rule.
Is it possible to provide such functionality this at the tutorialkit level? Add a class perhaps?

@AriPerkkio
Copy link
Member

I would recommend to create re-usable Astro component and use that in the lessons that are hiding preview and terminal. Something like:

---
type: lesson
...
---

import NarrowLayout from '@component/NarrowLayout';

<NarrowLayout>

# Welcom to TutorialKit

Lorem ipsum dolor...

</NarrowLayout>

What kind of configurable API should this have on TutorialKit's side?

@AriPerkkio AriPerkkio added the enhancement New feature or request label Sep 9, 2024
@iliakan
Copy link
Author

iliakan commented Sep 9, 2024

I would suggest just adding a CSS class to the div with the lesson text. Then a simple theme.css would allow to configure it.

Because content files should be about content as much as possible. It'd be much better to do such a generic thing with CSS.

@AriPerkkio
Copy link
Member

AriPerkkio commented Sep 16, 2024

As solution, let's add support for overriding the elements that render markdown here:

<div class="markdown-content text-tk-elements-content-textColor">
<Markdown />
</div>

This should be called TutorialContent that can be overriden with https://tutorialkit.dev/guides/overriding-components/. Then users can create their own TutorialContent with any styling and classnames they need, and define it in configuration as:

import tutorialkit from '@tutorialkit/astro';
import { defineConfig } from 'astro/config';

export default defineConfig({
  integrations: [
    tutorialkit({
      components: {
        TutorialContent: './src/components/TutorialContent.astro',
      },
    }),
  ],
});

@AriPerkkio AriPerkkio added the nice-to-have Not breaking anything but nice to have label Sep 16, 2024
@AriPerkkio AriPerkkio changed the title No-editor layout column width Override components: TutorialContent Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request nice-to-have Not breaking anything but nice to have
Projects
None yet
Development

No branches or pull requests

2 participants