Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl committed Nov 4, 2022
2 parents 4542906 + 52666a8 commit a3873b4
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 8 deletions.
18 changes: 17 additions & 1 deletion docs/content/troubleshooting/documentation-error.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
# Documentation Error
# Troubleshooting Documentation Errors

## React Hook Errors

If you have installed the dependencies in the root of the Medusa repository (that is, if you have a `node_modules` directory at the root of the Medusa repository), this will cause an error when running the documentation website.

This is because the content resides in `docs/content`. When that content is being imported from there, a mix up can happen between the dependencies in the root of the Medusa repository and the dependencies in `www/docs` which causes an `invalid hook call` error.

For that reason, when the `start` and `build` scripts in `www/docs` are used, the `clean-node-modules` script is called. This script deleted the `node_modules` directory in the root of the Medusa repository.

## Out of Memory Error

If you receive the following error when you run the `build` command in `www/docs`:

```bash
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
```

Then, run the `build` command with the `NODE_OPTIONS` environment variable set:

```bash npm2yarn
NODE_OPTIONS="--max-old-space-size=8192" npm run build
```
4 changes: 4 additions & 0 deletions www/docs/src/css/_sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,8 @@ html:not([data-theme="dark"]) .menu__list-item.topright-icon .menu__link.menu__l

.navbar-github-link {
overflow: visible;
}

.sidebar-desktop:not(.scrolling) nav::-webkit-scrollbar {
--ifm-scrollbar-size: 0px;
}
4 changes: 2 additions & 2 deletions www/docs/src/theme/CodeBlock/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {isValidElement} from 'react';
import React, {isValidElement, useCallback, useEffect, useState} from 'react';
import useIsBrowser from '@docusaurus/useIsBrowser';
import useBaseUrl from '@docusaurus/useBaseUrl';
import ElementContent from '@theme/CodeBlock/Content/Element';
Expand Down Expand Up @@ -36,7 +36,7 @@ export default function CodeBlock({children: rawChildren, ...props}) {
<div className='code-wrapper'>
<div className='code-header'>
<Tooltip text="Report Incorrect Code">
<a href={`${reportCodeLinkPrefix}&title=${encodeURIComponent(`Docs(Code Issue): Code Issue in ${isBrowser ? document?.title : ''}`)}`} target="_blank" className='report-code code-action img-url'>
<a href={`${reportCodeLinkPrefix}&title=${encodeURIComponent(`Docs(Code Issue): Code Issue in ${isBrowser ? location.pathname : ''}`)}`} target="_blank" className='report-code code-action img-url'>
<ThemedImage alt='Report Incorrect Code' sources={{
light: useBaseUrl('/img/alert-code.png'),
dark: useBaseUrl('/img/alert-code-dark.png')
Expand Down
9 changes: 7 additions & 2 deletions www/docs/src/theme/ColorModeToggle/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import clsx from 'clsx';
import useIsBrowser from '@docusaurus/useIsBrowser';
import {useColorMode} from '@docusaurus/theme-common';
import {useThemeConfig} from '@docusaurus/theme-common';

const allowedModes = [
'light',
Expand All @@ -11,13 +11,18 @@ const allowedModes = [

function ColorModeToggle({className, onChange}) {
const isBrowser = useIsBrowser();
const [storageColorMode, setStorageColorMode] = useState('light')
const { colorMode } = useThemeConfig();
const [storageColorMode, setStorageColorMode] = useState('');

useEffect(() => {
if (isBrowser) {
const previousSelected = window.localStorage.getItem('selected-color-mode') || window.localStorage.getItem('theme')
if (previousSelected && allowedModes.includes(previousSelected)) {
setStorageColorMode(previousSelected)
} else if (colorMode.respectPrefersColorScheme) {
setStorageColorMode('auto')
} else {
setStorageColorMode(colorMode.defaultMode || 'light')
}
}
}, [isBrowser])
Expand Down
40 changes: 37 additions & 3 deletions www/docs/src/theme/DocSidebar/Desktop/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react';
import React, { useEffect, useRef } from 'react';
import clsx from 'clsx';
import {useThemeConfig} from '@docusaurus/theme-common';
import Logo from '@theme/Logo';
import CollapseButton from '@theme/DocSidebar/Desktop/CollapseButton';
import Content from '@theme/DocSidebar/Desktop/Content';
import styles from './styles.module.css';
import DocSidebarItem from '@theme/DocSidebarItem';
import SearchBar from '../../SearchBar'
import SearchBar from '../../SearchBar';
import useIsBrowser from '@docusaurus/useIsBrowser';

function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}) {
const {
Expand All @@ -16,14 +17,47 @@ function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}) {
},
sidebarFooter = [],
} = useThemeConfig();
const isBrowser = useIsBrowser()
const sidebarRef = useRef(null)

useEffect(() => {
console.log("here1", isBrowser, sidebarRef.current)
if (isBrowser && sidebarRef.current) {
console.log("here2")
function handleScroll () {
console.log("handlescroll")
if (!sidebarRef.current.classList.contains('scrolling')) {
console.log("scrolling")
sidebarRef.current.classList.add('scrolling');
const intervalId = setInterval(() => {
console.log("interval")
if (!sidebarRef.current.matches(':hover')) {
console.log("remove class")
sidebarRef.current.classList.remove('scrolling');
clearInterval(intervalId);
}
}, 300)
}
}

const navElement = sidebarRef.current.querySelector('nav');
navElement.addEventListener('scroll', handleScroll);

return () => {
navElement?.removeEventListener('scroll', handleScroll);
}
}
}, [isBrowser, sidebarRef.current])

return (
<div
className={clsx(
styles.sidebar,
'sidebar-desktop',
hideOnScroll && styles.sidebarWithHideableNavbar,
isHidden && styles.sidebarHidden,
)}>
)}
ref={sidebarRef}>
{hideOnScroll && <Logo tabIndex={-1} className={styles.sidebarLogo} />}
<div className={styles.sidebarSearchContainer}>
<SearchBar />
Expand Down
Binary file modified www/docs/static/img/info-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified www/docs/static/img/tip-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a3873b4

Please sign in to comment.