Force home page to dark mode while allowing choice for other pages (#1810)

## Description

Force home page to dark mode while allowing choice for other pages

## Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No 

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [x] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Test
- [ ] 💻 CI/Deployment
- [ ] 🐹 Trivial/Minor

## Issue(s)

## Test Plan

<!-- How will this be tested prior to merging.-->
- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
Georgi Matev 2022-12-14 09:23:22 -08:00 committed by GitHub
parent beb8be1d33
commit a7a0ebf017
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 3 deletions

View File

@ -145,8 +145,8 @@ const config = {
}, },
colorMode: { colorMode: {
defaultMode: 'dark', defaultMode: 'dark',
disableSwitch: true, disableSwitch: false,
respectPrefersColorScheme: false, respectPrefersColorScheme: true,
}, },
zoom: { zoom: {

View File

@ -18,6 +18,7 @@ export default function Demo() {
borderLeft: "2px solid #e5e7eb", borderLeft: "2px solid #e5e7eb",
borderRight: "2px solid #e5e7eb", borderRight: "2px solid #e5e7eb",
borderBottom: "2px solid #e5e7eb", borderBottom: "2px solid #e5e7eb",
backgroundColor: "#121831",
}} }}
> >
<video className="w-full" poster="assets/images/corso_demo_thumbnail.png" muted loop autoPlay playsInline> <video className="w-full" poster="assets/images/corso_demo_thumbnail.png" muted loop autoPlay playsInline>

View File

@ -11,6 +11,13 @@ CUSTOM TO THE NEW HOME PAGE
html{ html{
scroll-behavior: smooth !important; scroll-behavior: smooth !important;
} }
.plugin-pages {
.colorModeToggle_---node_modules-\@docusaurus-theme-classic-lib-theme-Navbar-Content-styles-module {
display: none;
}
}
.accordion-button-custom::after { .accordion-button-custom::after {
-ms-flex-shrink: 0; -ms-flex-shrink: 0;
flex-shrink: 0; flex-shrink: 0;

View File

@ -1,6 +1,24 @@
import React from "react"; import React, { useEffect } from "react";
import Layout from "@theme/Layout"; import Layout from "@theme/Layout";
import { MainComp } from "@site/src/components/parts/MainComp"; import { MainComp } from "@site/src/components/parts/MainComp";
import { useColorMode } from '@docusaurus/theme-common';
const ThemeColor = () => {
const { colorMode, setColorMode } = useColorMode();
useEffect(function () {
if (window.location.pathname === '/') {
if (colorMode !== 'dark') {
//force dark theme to home page without overriding user settings
setColorMode('dark', { persist: false })
}
} else {
setColorMode(localStorage.getItem('theme'))
}
});
return null
};
export default function Home() { export default function Home() {
return ( return (
@ -8,6 +26,7 @@ export default function Home() {
title="Free, Secure, and Open-Source Backup for Microsoft 365" title="Free, Secure, and Open-Source Backup for Microsoft 365"
description="Intro, docs, and blog for Corso, an open-source tool, that protects Microsoft 365 data by securely and efficiently backing up all business-critical data to object storage." description="Intro, docs, and blog for Corso, an open-source tool, that protects Microsoft 365 data by securely and efficiently backing up all business-critical data to object storage."
> >
<ThemeColor />
<MainComp /> <MainComp />
</Layout> </Layout>
); );