Skip to content

Commit

Permalink
Docs: Cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aurindam committed Dec 11, 2024
1 parent 8997f2c commit a39da87
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 11 deletions.
7 changes: 4 additions & 3 deletions docs/astro/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ export default defineConfig({
},
integrations: [
starlight({
title: "Docs",
title: "Slint Docs",
logo: {
light: "./src/assets/slint-logo-simple-light.webp",
dark: "./src/assets/slint-logo-simple-dark.webp",
light: "./src/assets/slint-logo-simple-light.svg",
dark: "./src/assets/slint-logo-simple-dark.svg",
replacesTitle: true
},
customCss: ["./src/styles/custom.css"],

Expand Down
17 changes: 17 additions & 0 deletions docs/astro/src/assets/slint-logo-simple-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions docs/astro/src/assets/slint-logo-simple-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 15 additions & 7 deletions docs/astro/src/components/Footer.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
// SPDX-License-Identifier: MIT
import type { Props } from "@astrojs/starlight/props";
import Default from "@astrojs/starlight/components/Footer.astro";
const year = new Date().getFullYear();
---
<div>
<Default {...Astro.props}/>
<slot />
<div class="meta sl-flex">
<p>Copyright © SixtyFPS GmbH</p>
</div>
</div>

<Default {...Astro.props}><slot /></Default>

<hr />

<p>&copy; {year} SixtyFPS GmbH</p>

<style>
p {
text-align: center;
color: var(--sl-color-gray-2);
font-size: var(--sl-text-sm);
}
hr {
border: 0;
border-bottom: 1px solid var(--sl-color-hairline);
}
</style>
2 changes: 1 addition & 1 deletion docs/astro/src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import LanguageSelect from "@astrojs/starlight/components/LanguageSelect.astro";
import Search from "@astrojs/starlight/components/Search.astro";
import SiteTitle from "@astrojs/starlight/components/SiteTitle.astro";
import SocialIcons from "@astrojs/starlight/components/SocialIcons.astro";
import ThemeSelect from "@astrojs/starlight/components/ThemeSelect.astro";
import ThemeSelect from "./ThemeSelect.astro";
import VersionSelector from "./VersionSelector.astro";
---

Expand Down
75 changes: 75 additions & 0 deletions docs/astro/src/components/ThemeSelect.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: MIT
import type { Props } from '@astrojs/starlight/props';
import { Icon } from '@astrojs/starlight/components';
---

<script>
class ThemeSwitcher extends HTMLElement {
constructor() {
super();
const storedTheme =
typeof localStorage !== 'undefined' && localStorage.getItem('starlight-theme');
const theme =
storedTheme ||
(window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark');
document.documentElement.dataset.theme = theme === 'light' ? 'light' : 'dark';
this.handleMouseDown = this.handleMouseDown.bind(this);
}
connectedCallback() {
this.addEventListener('click', this.handleMouseDown);
}
disconnectedCallback() {
this.removeEventListener('click', this.handleMouseDown);
}
private handleMouseDown(e: MouseEvent) {
const theme = document.documentElement.dataset.theme === 'light' ? 'dark' : 'light';
document.documentElement.dataset.theme = theme;
localStorage.setItem('starlight-theme', theme);
}
}
customElements.define('theme-switcher', ThemeSwitcher);
</script>

<theme-switcher class="sl-flex">
<Icon name="sun" class="theme-selector-light" />
<Icon name="moon" class="theme-selector-dark" />
</theme-switcher>

<style>
theme-switcher {
align-items: center;
}
.theme-selector-light,
.theme-selector-dark {
user-select: none;
z-index: 999999;
position: relative;
cursor: pointer;
}
.theme-selector-light:hover,
.theme-selector-dark:hover {
color: var(--sl-color-accent-high);
}
:root {
.theme-selector-light {
display: none;
}
.theme-selector-dark {
display: inline-block;
}
}
:root[data-theme='light'] {
.theme-selector-light {
display: inline-block;
}
.theme-selector-dark {
display: none;
}
.theme-selector-light:hover,
.theme-selector-dark:hover {
color: var(--sl-color-accent);
}
}
</style>

0 comments on commit a39da87

Please sign in to comment.