Skip to content

Commit

Permalink
Merge branch 'localisation' of https://github.com/sensebox/docs into …
Browse files Browse the repository at this point in the history
…localisation
  • Loading branch information
kgalb01 committed Jan 28, 2025
2 parents 0e6d728 + 8602c49 commit a247ff0
Show file tree
Hide file tree
Showing 29 changed files with 513 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/components/BoardDropdown/BoardDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const BoardDropdown = () => {
const handleBoardChange = (selectedBoard) => {
// Verwende die setBoard-Funktion direkt, um das Board im Store zu aktualisieren
useBoardStore.setState({ board: selectedBoard });
console.log(selectedBoard, useBoardStore((state) => state.board))
// Hier kannst du weitere Aktionen ausführen, wenn sich das Board ändert
};

Expand Down
13 changes: 6 additions & 7 deletions src/components/HomepageFeatures/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const FeatureList = [
Bildungsbereich. Klicke hier für alle nötigen Informationen!
</Translate>
),
to: '/docs/boards/mcus2/mcu-s2-overview',
to: '/docs/boards/mcus2/mcu-s2-overview?board=edus2',
},
{
title: ':edu',
Expand All @@ -28,7 +28,7 @@ const FeatureList = [
den Einsatz im Bildungsbereich
</Translate>
),
to: '/docs/boards/mcu/mcu-overview',
to: '/docs/boards/mcu/mcu-overview?board=edu',
},
{
title: ':bike',
Expand All @@ -38,7 +38,7 @@ const FeatureList = [
der Installation der Fahrradhalterung
</Translate>
),
to: '/docs/category/bike',
to: '/docs/category/bike?board=bike',
},
{
title: ':CO2 Ampel',
Expand All @@ -48,7 +48,7 @@ const FeatureList = [
weiteren Bauteilen für Bildungszwecke
</Translate>
),
to: '/docs/products/co2Ampel/co2Ampel-overview',
to: '/docs/products/co2Ampel/co2Ampel-overview?board=co2',
},
{
title: ':home',
Expand All @@ -58,7 +58,7 @@ const FeatureList = [
Sensoren der senseBox:home findest du hier!
</Translate>
),
to: '/docs/boards/mcu/mcu-overview',
to: '/docs/boards/mcu/mcu-overview?board=home',
},
{
title: ':mini',
Expand All @@ -68,7 +68,7 @@ const FeatureList = [
du hier!
</Translate>
),
to: '/docs/boards/mini/mini-overview',
to: '/docs/boards/mini/mini-overview?board=mini',
},
]

Expand Down Expand Up @@ -115,7 +115,6 @@ const ThumbNailPreviewList = [
function ThumbailPreview({ Image, title, description, onClick, to }) {
return (
<Link
onClick={onClick}
className="mx-auto w-full overflow-hidden rounded-lg bg-gradient-to-r from-green-3 to-green text-white transition duration-300 hover:-translate-y-1 hover:text-white hover:no-underline hover:shadow-[rgba(0,0,15,0.5)_-7px_7px_0px_0px] hover:shadow-yellow lg:w-[25%]"
to={to}
>
Expand Down
21 changes: 20 additions & 1 deletion src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,27 @@
@tailwind components;
@tailwind utilities;

@font-face {
font-family: "BrixSlab-Bold";
src: url("webfonts/2EF157_0_0.eot");
src: url("webfonts/2EF157_0_0.eot?#iefix") format("embedded-opentype"),
url("webfonts/2EF157_0_0.woff2") format("woff2"),
url("webfonts/2EF157_0_0.woff") format("woff"),
url("webfonts/2EF157_0_0.ttf") format("truetype");
}

@font-face {
font-family: "BrixSlab-Regular";
src: url("webfonts/2EF157_1_0.eot");
src: url("webfonts/2EF157_1_0.eot?#iefix") format("embedded-opentype"),
url("webfonts/2EF157_1_0.woff2") format("woff2"),
url("webfonts/2EF157_1_0.woff") format("woff"),
url("webfonts/2EF157_1_0.ttf") format("truetype");
}


html {
font-family: 'Roboto', "Helvetica", "Arial", sans-serif;
font-family: 'BrixSlab-Regular', "Helvetica", "Arial", sans-serif;

}
/*header {
Expand Down
Binary file added src/css/webfonts/2EF157_0_0.eot
Binary file not shown.
Binary file added src/css/webfonts/2EF157_0_0.ttf
Binary file not shown.
Binary file added src/css/webfonts/2EF157_0_0.woff
Binary file not shown.
Binary file added src/css/webfonts/2EF157_0_0.woff2
Binary file not shown.
Binary file added src/css/webfonts/2EF157_1_0.eot
Binary file not shown.
Binary file added src/css/webfonts/2EF157_1_0.ttf
Binary file not shown.
Binary file added src/css/webfonts/2EF157_1_0.woff
Binary file not shown.
Binary file added src/css/webfonts/2EF157_1_0.woff2
Binary file not shown.
2 changes: 1 addition & 1 deletion src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function Home() {
return (
<Layout
title={`senseBox Dokumentation`}
description="Description will go into a meta tag in <head />"
description="Der Platz für die senseBox-Dokumentation."
>
<HomepageHeader />
<main className="">
Expand Down
53 changes: 53 additions & 0 deletions src/theme/BoardDropdown/BoardDropdown.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// BoardDropdown.jsx

import React, { useState } from "react";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@site/src/components/ui/select";
import { useBoardStore } from "@site/src/lib/stores/store";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faMicrochip } from "@fortawesome/free-solid-svg-icons";
const BoardDropdown = () => {
const board = useBoardStore((state) => state.board);
const handleBoardChange = (selectedBoard) => {
// Verwende die setBoard-Funktion direkt, um das Board im Store zu aktualisieren
useBoardStore.setState({ board: selectedBoard });
// Hier kannst du weitere Aktionen ausführen, wenn sich das Board ändert
};

return (
<Select onValueChange={(value) => handleBoardChange(value)} default>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder={board ? board : "Board auswählen"} />
</SelectTrigger>
<SelectContent>
<SelectItem value=":edu">
<FontAwesomeIcon icon={faMicrochip} className="mr-2" />
:edu
</SelectItem>
<SelectItem value=":edu S2">
<FontAwesomeIcon icon={faMicrochip} className="mr-2" />
:edu S2
</SelectItem>
<SelectItem value=":home">
<FontAwesomeIcon icon={faMicrochip} className="mr-2" />
:home
</SelectItem>
<SelectItem value=":bike">
<FontAwesomeIcon icon={faMicrochip} className="mr-2" />
:bike
</SelectItem>
<SelectItem value=":CO2Traffic">
<FontAwesomeIcon icon={faMicrochip} className="mr-2" />
CO2 Traffic Light
</SelectItem>
</SelectContent>
</Select>
);
};

export default BoardDropdown;
22 changes: 22 additions & 0 deletions src/theme/Navbar/ColorModeToggle/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import {useColorMode, useThemeConfig} from '@docusaurus/theme-common';
import ColorModeToggle from '@theme/ColorModeToggle';
import styles from './styles.module.css';
export default function NavbarColorModeToggle({className}) {
const navbarStyle = useThemeConfig().navbar.style;
const disabled = useThemeConfig().colorMode.disableSwitch;
const {colorMode, setColorMode} = useColorMode();
if (disabled) {
return null;
}
return (
<ColorModeToggle
className={className}
buttonClassName={
navbarStyle === 'dark' ? styles.darkNavbarColorModeToggle : undefined
}
value={colorMode}
onChange={setColorMode}
/>
);
}
3 changes: 3 additions & 0 deletions src/theme/Navbar/ColorModeToggle/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.darkNavbarColorModeToggle:hover {
background: var(--ifm-color-gray-800);
}
126 changes: 126 additions & 0 deletions src/theme/Navbar/Content/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import React, { useEffect, useState } from 'react';
import { useThemeConfig, ErrorCauseBoundary } from '@docusaurus/theme-common';
import {
splitNavbarItems,
useNavbarMobileSidebar,
} from '@docusaurus/theme-common/internal';
import NavbarItem from '@theme/NavbarItem';
import NavbarColorModeToggle from '@theme/Navbar/ColorModeToggle';
import SearchBar from '@theme/SearchBar';
import NavbarMobileSidebarToggle from '@theme/Navbar/MobileSidebar/Toggle';
import NavbarLogo from '@theme/Navbar/Logo';
import NavbarSearch from '@theme/Navbar/Search';
import styles from './styles.module.css';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@site/src/components/ui/select";
import { useBoardStore } from "@site/src/lib/stores/store";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faMicrochip } from "@fortawesome/free-solid-svg-icons";
import { useNavigate, useLocation } from 'react-router-dom'; // Verwende useLocation

function useNavbarItems() {
return useThemeConfig().navbar.items;
}

function NavbarItems({ items }) {
return (
<>
{items.map((item, i) => (
<ErrorCauseBoundary
key={i}
onError={(error) =>
new Error(
`A theme navbar item failed to render.
Please double-check the following navbar item (themeConfig.navbar.items) of your Docusaurus config:
${JSON.stringify(item, null, 2)}`,
{ cause: error },
)
}
>
<NavbarItem {...item} />
</ErrorCauseBoundary>
))}
</>
);
}

function NavbarContentLayout({ left, right }) {
return (
<div className="navbar__inner">
<div className="navbar__items">{left}</div>
<div className="navbar__items navbar__items--right">{right}</div>
</div>
);
}

const BoardDropdown = () => {
const board = useBoardStore((state) => state.board);
const location = useLocation();

const handleBoardChange = (selectedBoard) => {
// Verwende die setBoard-Funktion direkt, um das Board im Store zu aktualisieren
console.log(selectedBoard)
useBoardStore.setState({ board: selectedBoard });
// Hier kannst du weitere Aktionen ausführen, wenn sich das Board ändert
};

useEffect(() => {
const searchParams = new URLSearchParams(location.search);
const currentBoard = searchParams.get('board');
// Map der Suchbegriffe zu den entsprechenden Board-Werten
const boardMap = {
home: ":home",
edus2: ":edu S2",
edu: ":edu",
bike: ":bike",
co2: ":CO2 Ampel",
mini: ":mini",
};

// Überprüfen, ob der Suchbegriff gültig ist, und Board setzen
if (currentBoard && boardMap[currentBoard.toLowerCase()]) {
useBoardStore.setState({ board: boardMap[currentBoard.toLowerCase()] });
} else {
console.warn("Ungültiger Board-Parameter:", currentBoard);
}
}, [location.search]); // Überwache Änderungen an den Query-Parametern

return (<></>
);
};

export default function NavbarContent() {
const mobileSidebar = useNavbarMobileSidebar();
const items = useNavbarItems();
const [leftItems, rightItems] = splitNavbarItems(items);
const searchBarItem = items.find((item) => item.type === 'search');

return (
<NavbarContentLayout
left={
<>
{!mobileSidebar.disabled && <NavbarMobileSidebarToggle />}
<NavbarLogo />
<NavbarItems items={leftItems} />
</>
}
right={
<>
<BoardDropdown />
<NavbarItems items={rightItems} />
<NavbarColorModeToggle className={styles.colorModeToggle} />
{!searchBarItem && (
<NavbarSearch>
<SearchBar />
</NavbarSearch>
)}
</>
}
/>
);
}
8 changes: 8 additions & 0 deletions src/theme/Navbar/Content/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Hide color mode toggle in small viewports
*/
@media (max-width: 996px) {
.colorModeToggle {
display: none;
}
}
52 changes: 52 additions & 0 deletions src/theme/Navbar/Layout/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from 'react';
import clsx from 'clsx';
import {useThemeConfig} from '@docusaurus/theme-common';
import {
useHideableNavbar,
useNavbarMobileSidebar,
} from '@docusaurus/theme-common/internal';
import {translate} from '@docusaurus/Translate';
import NavbarMobileSidebar from '@theme/Navbar/MobileSidebar';
import styles from './styles.module.css';
function NavbarBackdrop(props) {
return (
<div
role="presentation"
{...props}
className={clsx('navbar-sidebar__backdrop', props.className)}
/>
);
}
export default function NavbarLayout({children}) {
const {
navbar: {hideOnScroll, style},
} = useThemeConfig();
const mobileSidebar = useNavbarMobileSidebar();
const {navbarRef, isNavbarVisible} = useHideableNavbar(hideOnScroll);
return (
<nav
ref={navbarRef}
aria-label={translate({
id: 'theme.NavBar.navAriaLabel',
message: 'Main',
description: 'The ARIA label for the main navigation',
})}
className={clsx(
'navbar',
'navbar--fixed-top',
hideOnScroll && [
styles.navbarHideable,
!isNavbarVisible && styles.navbarHidden,
],
{
'navbar--dark': style === 'dark',
'navbar--primary': style === 'primary',
'navbar-sidebar--show': mobileSidebar.shown,
},
)}>
{children}
<NavbarBackdrop onClick={mobileSidebar.toggle} />
<NavbarMobileSidebar />
</nav>
);
}
7 changes: 7 additions & 0 deletions src/theme/Navbar/Layout/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.navbarHideable {
transition: transform var(--ifm-transition-fast) ease;
}

.navbarHidden {
transform: translate3d(0, calc(-100% - 2px), 0);
}
11 changes: 11 additions & 0 deletions src/theme/Navbar/Logo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import Logo from '@theme/Logo';
export default function NavbarLogo() {
return (
<Logo
className="navbar__brand"
imageClassName="navbar__logo"
titleClassName="navbar__title text--truncate"
/>
);
}
Loading

0 comments on commit a247ff0

Please sign in to comment.