Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Add beginner mode to hide advanced doc chapters #9306

Merged
merged 4 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/Tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,8 @@ After that, the best way to learn react-admin is by reading the introduction cha
- [Preferences](./Store.md)
- [Realtime](./Realtime.md)

**Tip**: React-admin is a large framework, so its documentation is quite large. Don't get intimidated! React-admin works well for projects of any size. To continue your discovery of react-admin, we recommend that you **[enable the beginner mode](#beginner-mode)**, that hides the advanced features from the sidebar. Just remember to disable it when you're ready to go further.

And to help you close the gap between theoretical knowledge and practical experience, take advantage of the react-admin [Demos](./Demos.md). They are great examples of how to use react-admin in a real world application. They also show the best practices for going beyond simple CRUD apps.

<video controls autoplay playsinline muted loop width="100%">
Expand Down
4 changes: 2 additions & 2 deletions docs/Vite.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
layout: default
title: "Vite Integration"
title: "Installing React-admin With Vite"
---

# Vite Integration
# Installing React-admin With Vite

[Vite](https://vitejs.dev/) is a JavaScript bundler which improves speed of dev server and production build compared to Webpack.

Expand Down
51 changes: 38 additions & 13 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/>
<link
rel="stylesheet"
href="{{ '/css/style-v18.css' | relative_url }}"
href="{{ '/css/style-v19.css' | relative_url }}"
/>
<link rel="stylesheet" href="{{ '/css/syntax.css' | relative_url }}" />
<link rel="stylesheet" href="{{ '/css/prism.css' | relative_url }}" />
Expand Down Expand Up @@ -49,42 +49,54 @@
@font-face {
font-display: block;
font-family: Roboto;
src: url(https://assets.brevo.com/font/Roboto/Latin/normal/normal/7529907e9eaf8ebb5220c5f9850e3811.woff2) format("woff2"), url(https://assets.brevo.com/font/Roboto/Latin/normal/normal/25c678feafdc175a70922a116c9be3e7.woff) format("woff")
src: url(https://assets.brevo.com/font/Roboto/Latin/normal/normal/7529907e9eaf8ebb5220c5f9850e3811.woff2)
format('woff2'),
url(https://assets.brevo.com/font/Roboto/Latin/normal/normal/25c678feafdc175a70922a116c9be3e7.woff)
format('woff');
}

@font-face {
font-display: fallback;
font-family: Roboto;
font-weight: 600;
src: url(https://assets.brevo.com/font/Roboto/Latin/medium/normal/6e9caeeafb1f3491be3e32744bc30440.woff2) format("woff2"), url(https://assets.brevo.com/font/Roboto/Latin/medium/normal/71501f0d8d5aa95960f6475d5487d4c2.woff) format("woff")
src: url(https://assets.brevo.com/font/Roboto/Latin/medium/normal/6e9caeeafb1f3491be3e32744bc30440.woff2)
format('woff2'),
url(https://assets.brevo.com/font/Roboto/Latin/medium/normal/71501f0d8d5aa95960f6475d5487d4c2.woff)
format('woff');
}

@font-face {
font-display: fallback;
font-family: Roboto;
font-weight: 700;
src: url(https://assets.brevo.com/font/Roboto/Latin/bold/normal/3ef7cf158f310cf752d5ad08cd0e7e60.woff2) format("woff2"), url(https://assets.brevo.com/font/Roboto/Latin/bold/normal/ece3a1d82f18b60bcce0211725c476aa.woff) format("woff")
src: url(https://assets.brevo.com/font/Roboto/Latin/bold/normal/3ef7cf158f310cf752d5ad08cd0e7e60.woff2)
format('woff2'),
url(https://assets.brevo.com/font/Roboto/Latin/bold/normal/ece3a1d82f18b60bcce0211725c476aa.woff)
format('woff');
}

#sib-container input:-ms-input-placeholder {
text-align: left;
font-family: "Helvetica", sans-serif;
font-family: 'Helvetica', sans-serif;
color: #c0ccda;
}

#sib-container input::placeholder {
text-align: left;
font-family: "Helvetica", sans-serif;
font-family: 'Helvetica', sans-serif;
color: #c0ccda;
}

#sib-container textarea::placeholder {
text-align: left;
font-family: "Helvetica", sans-serif;
font-family: 'Helvetica', sans-serif;
color: #c0ccda;
}
</style>
<link rel="stylesheet" href="{{ '/css/newsletter.css' | relative_url }}">
<link
rel="stylesheet"
href="{{ '/css/newsletter.css' | relative_url }}"
/>
</head>

<body>
Expand Down Expand Up @@ -159,14 +171,27 @@
<script>
window.REQUIRED_CODE_ERROR_MESSAGE = 'Please choose a country code';
window.LOCALE = 'en';
window.GENERIC_INVALID_MESSAGE = window.EMAIL_INVALID_MESSAGE = window.SMS_INVALID_MESSAGE = "The information provided is invalid. Please review the field format and try again.";
window.REQUIRED_ERROR_MESSAGE = "This field is required.";
window.GENERIC_INVALID_MESSAGE = window.EMAIL_INVALID_MESSAGE = window.SMS_INVALID_MESSAGE =
'The information provided is invalid. Please review the field format and try again.';
window.REQUIRED_ERROR_MESSAGE = 'This field is required.';

var AUTOHIDE = Boolean(0);
</script>

<script async defer src="https://unpkg.com/[email protected]/lib/typescript.js"></script>
<script async defer src="https://unpkg.com/[email protected]/standalone.js"></script>
<script async defer src="https://unpkg.com/[email protected]/parser-babel.js"></script>
<script
async
defer
src="https://unpkg.com/[email protected]/lib/typescript.js"
></script>
<script
async
defer
src="https://unpkg.com/[email protected]/standalone.js"
></script>
<script
async
defer
src="https://unpkg.com/[email protected]/parser-babel.js"
></script>
</body>
</html>
14 changes: 14 additions & 0 deletions docs/css/style-v18.css → docs/css/style-v19.css
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,20 @@ ul.sidenav code {
box-shadow: none;
}

.switch label input[type=checkbox]:checked+.lever {
background-color: #85b3df;
}

.switch label .lever:before {
background-color: rgba(38,77,166,0.15);
}

.switch label input[type=checkbox]:checked+.lever:after {
background-color: #145dc2;
}

/* Table of contents */

.table-of-contents {
overflow-y: auto;
height: calc(100% - 75px);
Expand Down
2 changes: 1 addition & 1 deletion docs/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/>
<link
rel="stylesheet"
href="{{ '/css/style-v18.css' | relative_url }}"
href="{{ '/css/style-v19.css' | relative_url }}"
/>
<link rel="stylesheet" href="{{ '/css/syntax.css' | relative_url }}" />
<link rel="stylesheet" href="{{ '/css/prism.css' | relative_url }}" />
Expand Down
48 changes: 48 additions & 0 deletions docs/js/ra-doc-exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,54 @@ function loadNewsletterScript() {
}
}

/**
* Beginner mode
*/

let beginnerMode = window.localStorage.getItem('beginner-mode') === 'true';

function hideNonBeginnerDoc() {
const chapters = document.querySelectorAll('.sidenav > ul li');
chapters.forEach(chapter => {
if (!chapter.classList.contains('beginner')) {
chapter.style.display = 'none';
}
});
document.querySelectorAll('.beginner-mode-on').forEach(el => {
el.style.display = 'block';
});
}

function showNonBeginnerDoc() {
const chapters = document.querySelectorAll('.sidenav > ul li');
chapters.forEach(chapter => {
chapter.style.display = 'list-item';
});
document.querySelectorAll('.beginner-mode-on').forEach(el => {
el.style.display = 'none';
});
}

document
.getElementById('beginner-mode-trigger')
.addEventListener('click', () => {
beginnerMode = !beginnerMode;
if (beginnerMode) {
window.localStorage.setItem('beginner-mode', 'true');
hideNonBeginnerDoc();
} else {
window.localStorage.removeItem('beginner-mode');
showNonBeginnerDoc();
}
});

window.addEventListener('DOMContentLoaded', () => {
document.getElementById('beginner-mode-trigger').checked = beginnerMode;
if (beginnerMode) {
hideNonBeginnerDoc();
}
});

// Replace full page reloads by a fill of the content area
// so that the side navigation keeps its state
// use a global event listener to also catch links inside the content area
Expand Down
Loading