Add markdown light/darkmode element

This commit is contained in:
Sacha Weatherstone 2022-04-07 19:59:15 +10:00
parent 83c612f011
commit 0d56796882
4 changed files with 268 additions and 193 deletions

View file

@ -0,0 +1,49 @@
---
id: markdown-features
title: Style Guide - Markdown Features
sidebar_label: Markdown-Features
---
import { Dark, Light } from '/src/components/ColorMode';
## Overview
We have developed several [React](https://reactjs.org/) components for assisting with writing documentation.
## Features
### Light/Dark Mode Switch
#### Usage:
```jsx
import { Dark, Light } from '/src/components/ColorMode';
<Dark>
<p>Dark</p>
</Dark>
<Light>
<p>Light</p>
</Light>
```
#### Demo:
<Dark>
<div className="not-prose rounded-lg bg-primary shadow-md">
<p className="p-2 text-lg font-medium">This is only shown in dark mode.</p>
<img
src="https://picsum.photos/id/101/600/200"
className="w-full rounded-lg shadow-md"
/>
</div>
</Dark>
<Light>
<div className="not-prose rounded-lg border bg-primary shadow-md">
<p className="p-2 text-lg font-medium">This is only shown in dark mode.</p>
<img
src="https://picsum.photos/id/1028/600/200"
className="w-full rounded-lg shadow-md"
/>
</div>
</Light>

View file

@ -1,312 +1,313 @@
module.exports = {
About: {
"About Meshtastic": [
"about/overview",
'About Meshtastic': [
'about/overview',
{
Concepts: [
"about/concepts/overview",
"about/concepts/channels",
"about/concepts/clients",
"about/concepts/external-devices",
"about/concepts/internet",
"about/concepts/mesh",
'about/concepts/overview',
'about/concepts/channels',
'about/concepts/clients',
'about/concepts/external-devices',
'about/concepts/internet',
'about/concepts/mesh',
],
},
"about/expectations",
'about/expectations',
{
FAQs: [
"faq/faq",
"faq/antenna",
"faq/bluetooth",
"faq/channel",
'faq/faq',
'faq/antenna',
'faq/bluetooth',
'faq/channel',
{
Clients: [
"faq/client-android",
"faq/client-python-cli",
"faq/client-ios",
"faq/client-web",
'faq/client-android',
'faq/client-python-cli',
'faq/client-ios',
'faq/client-web',
],
},
"faq/device",
'faq/device',
{
"Flashing Firmware": ["faq/m-flasher"],
'Flashing Firmware': ['faq/m-flasher'],
},
"faq/mesh",
"faq/mqtt",
"faq/modules",
"faq/wifi",
'faq/mesh',
'faq/mqtt',
'faq/modules',
'faq/wifi',
],
},
],
},
Software: {
Software: [
"software/overview",
'software/overview',
{
"Meshtastic device": [
"software/device/device-firmware",
"software/device/device-channels",
"software/device/device-remote-admin",
"software/device/remote-hardware-service",
"software/device/device-power",
"software/device/critical-error-codes",
"software/device/ham",
'Meshtastic device': [
'software/device/device-firmware',
'software/device/device-channels',
'software/device/device-remote-admin',
'software/device/remote-hardware-service',
'software/device/device-power',
'software/device/critical-error-codes',
'software/device/ham',
],
},
{
"Meshtastic Android": [
"software/android/android-installation",
"software/android/android-usage",
'Meshtastic Android': [
'software/android/android-installation',
'software/android/android-usage',
],
},
{
"Meshtastic Apple": [
"software/apple/ios-development",
"software/apple/ios",
"software/apple/ipados",
"software/apple/macos",
'Meshtastic Apple': [
'software/apple/ios-development',
'software/apple/ios',
'software/apple/ipados',
'software/apple/macos',
],
},
{
"Meshtastic.js": [
"software/js/getting-started",
"software/js/connecting",
"software/js/events",
"software/js/http-api",
'Meshtastic.js': [
'software/js/getting-started',
'software/js/connecting',
'software/js/events',
'software/js/http-api',
{
type: "link",
label: "API Docs",
href: "https://js.meshtastic.org",
type: 'link',
label: 'API Docs',
href: 'https://js.meshtastic.org',
},
],
},
{
"Meshtastic-python": [
"software/python/python-installation",
"software/python/python-standalone",
"software/python/python-cli",
"software/python/python-uses",
"software/python/python-stream",
'Meshtastic-python': [
'software/python/python-installation',
'software/python/python-standalone',
'software/python/python-cli',
'software/python/python-uses',
'software/python/python-stream',
{
type: "link",
label: "API Docs",
href: "https://python.meshtastic.org/",
type: 'link',
label: 'API Docs',
href: 'https://python.meshtastic.org/',
},
],
},
{
Modules: [
"software/modules/modules",
"software/modules/range-test-module",
"software/modules/ext-notif-module",
"software/modules/canned-message-module",
"software/modules/serial-module",
"software/modules/store-forward-module",
"software/modules/telemetry-module",
'software/modules/modules',
'software/modules/range-test-module',
'software/modules/ext-notif-module',
'software/modules/canned-message-module',
'software/modules/serial-module',
'software/modules/store-forward-module',
'software/modules/telemetry-module',
],
},
{
"Web interface": [
"software/web/web-app-software",
"software/web/web-partitions-software",
"software/web/web-development-software",
'Web interface': [
'software/web/web-app-software',
'software/web/web-partitions-software',
'software/web/web-development-software',
],
},
{
"Community projects": [
"software/community/community-overview",
"software/community/community-atak",
"software/community/community-pygui",
"software/community/community-go",
'Community projects': [
'software/community/community-overview',
'software/community/community-atak',
'software/community/community-pygui',
'software/community/community-go',
],
},
{
Other: [
"software/other/sw-design",
"software/other/remote-hardware-service",
"software/other/rak815",
"software/other/power",
"software/other/pinetab",
"software/other/nrf52-TODO",
"software/other/mqtt",
"software/other/install-OSX",
"software/other/esp32-arduino-build",
"software/other/ant",
"software/other/docker",
'software/other/sw-design',
'software/other/remote-hardware-service',
'software/other/rak815',
'software/other/power',
'software/other/pinetab',
'software/other/nrf52-TODO',
'software/other/mqtt',
'software/other/install-OSX',
'software/other/esp32-arduino-build',
'software/other/ant',
'software/other/docker',
],
},
],
"Additional Documentation": [
{ type: "ref", id: "getting-started/overview" },
{ type: "ref", id: "settings/overview" },
{ type: "ref", id: "hardware/overview" },
{ type: "ref", id: "developers/overview" },
{ type: "ref", id: "developers/maintaining-documentation/overview" },
{ type: "ref", id: "legal/overview" },
'Additional Documentation': [
{ type: 'ref', id: 'getting-started/overview' },
{ type: 'ref', id: 'settings/overview' },
{ type: 'ref', id: 'hardware/overview' },
{ type: 'ref', id: 'developers/overview' },
{ type: 'ref', id: 'developers/maintaining-documentation/overview' },
{ type: 'ref', id: 'legal/overview' },
],
},
Configuration: {
"Getting Started": [
"getting-started/overview",
'Getting Started': [
'getting-started/overview',
{
"Flashing firmware": [
"getting-started/flashing-firmware",
"getting-started/meshtastic-flasher",
'Flashing firmware': [
'getting-started/flashing-firmware',
'getting-started/meshtastic-flasher',
{
"Manual Method": [
"getting-started/flashing-esp32",
"getting-started/flashing-nrf52",
'Manual Method': [
'getting-started/flashing-esp32',
'getting-started/flashing-nrf52',
],
},
],
},
{
"Connect to Device": ["getting-started/clients"],
'Connect to Device': ['getting-started/clients'],
},
"getting-started/first-steps",
'getting-started/first-steps',
],
"Device Settings": [
"settings/overview",
"settings/channel",
"settings/gps",
"settings/ham",
"settings/mqtt",
"settings/power",
"settings/router",
"settings/wifi",
'Device Settings': [
'settings/overview',
'settings/channel',
'settings/gps',
'settings/ham',
'settings/mqtt',
'settings/power',
'settings/router',
'settings/wifi',
{
Modules: [
"settings/canned-message-module",
"settings/input-broker-module",
"settings/external-notification-module",
"settings/range-test-module",
"settings/serial-module",
"settings/store-and-forward-module",
"settings/telemetry-module",
'settings/canned-message-module',
'settings/input-broker-module',
'settings/external-notification-module',
'settings/range-test-module',
'settings/serial-module',
'settings/store-and-forward-module',
'settings/telemetry-module',
],
Advanced: ["settings/channel-advanced", "settings/misc"],
Advanced: ['settings/channel-advanced', 'settings/misc'],
},
],
"Additional Documentation": [
{ type: "ref", id: "hardware/overview" },
{ type: "ref", id: "software/overview" },
{ type: "ref", id: "developers/overview" },
{ type: "ref", id: "developers/maintaining-documentation/overview" },
{ type: "ref", id: "legal/overview" },
'Additional Documentation': [
{ type: 'ref', id: 'hardware/overview' },
{ type: 'ref', id: 'software/overview' },
{ type: 'ref', id: 'developers/overview' },
{ type: 'ref', id: 'developers/maintaining-documentation/overview' },
{ type: 'ref', id: 'legal/overview' },
],
},
Hardware: {
Hardware: [
"hardware/overview",
'hardware/overview',
{
type: "link",
label: "Hardware List",
href: "/hardware",
type: 'link',
label: 'Hardware List',
href: '/hardware',
},
{
"Supported Hardware": [
"hardware/supported/tbeam",
"hardware/supported/lora",
"hardware/supported/heltec",
"hardware/supported/techo",
"hardware/supported/wisBlock",
"hardware/supported/linux",
'Supported Hardware': [
'hardware/supported/tbeam',
'hardware/supported/lora',
'hardware/supported/heltec',
'hardware/supported/techo',
'hardware/supported/wisBlock',
'hardware/supported/linux',
],
},
"hardware/buttons",
"hardware/battery",
"hardware/gpsmodule",
'hardware/buttons',
'hardware/battery',
'hardware/gpsmodule',
{
Antennas: [
"hardware/antenna/antenna",
"hardware/antenna/aerials",
"hardware/antenna/non-aerial",
"hardware/antenna/antenna-testing",
"hardware/antenna/resources",
'hardware/antenna/antenna',
'hardware/antenna/aerials',
'hardware/antenna/non-aerial',
'hardware/antenna/antenna-testing',
'hardware/antenna/resources',
],
},
],
"Additional Documentation": [
{ type: "ref", id: "getting-started/overview" },
{ type: "ref", id: "settings/overview" },
{ type: "ref", id: "software/overview" },
{ type: "ref", id: "developers/overview" },
{ type: "ref", id: "developers/maintaining-documentation/overview" },
{ type: "ref", id: "legal/overview" },
'Additional Documentation': [
{ type: 'ref', id: 'getting-started/overview' },
{ type: 'ref', id: 'settings/overview' },
{ type: 'ref', id: 'software/overview' },
{ type: 'ref', id: 'developers/overview' },
{ type: 'ref', id: 'developers/maintaining-documentation/overview' },
{ type: 'ref', id: 'legal/overview' },
],
},
Contribute: {
Developers: [
"developers/overview",
'developers/overview',
{
Protobufs: ["developers/protobufs/api"],
Protobufs: ['developers/protobufs/api'],
},
"developers/api",
"developers/publish",
'developers/api',
'developers/publish',
{
Firmware: [
"developers/firmware/build",
"developers/firmware/stacktrace-decode",
"developers/firmware/device-api",
"developers/firmware/radio-settings",
"developers/firmware/mesh-alg",
"developers/firmware/encryption",
"developers/firmware/portnum",
"developers/firmware/module-api",
"developers/firmware/http-api",
"developers/firmware/documents",
'developers/firmware/build',
'developers/firmware/stacktrace-decode',
'developers/firmware/device-api',
'developers/firmware/radio-settings',
'developers/firmware/mesh-alg',
'developers/firmware/encryption',
'developers/firmware/portnum',
'developers/firmware/module-api',
'developers/firmware/http-api',
'developers/firmware/documents',
],
},
{
"Android App": [
"developers/android/build-app",
"developers/android/mapbox",
'Android App': [
'developers/android/build-app',
'developers/android/mapbox',
],
"Maintaining Documentation": [
"developers/maintaining-documentation/overview",
'Maintaining Documentation': [
'developers/maintaining-documentation/overview',
{
Dependencies: [
"developers/maintaining-documentation/docusaurus",
"developers/maintaining-documentation/github",
"developers/maintaining-documentation/vercel",
'developers/maintaining-documentation/docusaurus',
'developers/maintaining-documentation/github',
'developers/maintaining-documentation/vercel',
],
},
{
Examples: [
"developers/maintaining-documentation/serve-docs-locally",
'developers/maintaining-documentation/serve-docs-locally',
],
},
{
"Style Guides": [
"developers/maintaining-documentation/style-guides/style-guide-settings",
'Style Guides': [
'developers/maintaining-documentation/style-guides/markdown-features',
'developers/maintaining-documentation/style-guides/style-guide-settings',
],
},
],
},
],
"Additional Documentation": [
{ type: "ref", id: "getting-started/overview" },
{ type: "ref", id: "settings/overview" },
{ type: "ref", id: "hardware/overview" },
{ type: "ref", id: "software/overview" },
{ type: "ref", id: "legal/overview" },
{ type: "ref", id: "developers/overview" },
'Additional Documentation': [
{ type: 'ref', id: 'getting-started/overview' },
{ type: 'ref', id: 'settings/overview' },
{ type: 'ref', id: 'hardware/overview' },
{ type: 'ref', id: 'software/overview' },
{ type: 'ref', id: 'legal/overview' },
{ type: 'ref', id: 'developers/overview' },
],
},
Legal: {
Legal: [
"legal/overview",
"legal/licensing",
"legal/trademark",
"legal/privacy",
'legal/overview',
'legal/licensing',
'legal/trademark',
'legal/privacy',
],
"Additional Documentation": [
{ type: "ref", id: "getting-started/overview" },
{ type: "ref", id: "settings/overview" },
{ type: "ref", id: "hardware/overview" },
{ type: "ref", id: "software/overview" },
{ type: "ref", id: "developers/overview" },
'Additional Documentation': [
{ type: 'ref', id: 'getting-started/overview' },
{ type: 'ref', id: 'settings/overview' },
{ type: 'ref', id: 'hardware/overview' },
{ type: 'ref', id: 'software/overview' },
{ type: 'ref', id: 'developers/overview' },
],
},
};

View file

@ -0,0 +1,13 @@
import React from 'react';
export interface ColorModeProps {
children: React.ReactNode;
}
export const Dark = ({ children }: ColorModeProps): JSX.Element => {
return <div className="hideLight">{children}</div>;
};
export const Light = ({ children }: ColorModeProps): JSX.Element => {
return <div className="hideDark">{children}</div>;
};

View file

@ -137,6 +137,18 @@ a + .navbar__link > svg {
}
[data-theme="dark"] .markdown {
@apply prose-invert;
@apply prose-invert;
}
[data-theme="dark"] .hideDark {
@apply hidden
}
[data-theme="dark"] .hideLight {
@apply block
}
.hideLight {
@apply hidden
}
.hideDark {
@apply block
}
}