Skip to content

Commit 0e1611e

Browse files
committed
Add collapsible code sections
1 parent 7349920 commit 0e1611e

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

docs_headless/ec.config.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineEcConfig } from 'astro-expressive-code';
2+
import { pluginCollapsibleSections } from '@expressive-code/plugin-collapsible-sections';
3+
4+
export default defineEcConfig({
5+
plugins: [pluginCollapsibleSections()],
6+
defaultProps: {
7+
collapseStyle: 'collapsible-auto',
8+
},
9+
});

docs_headless/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@astrojs/mdx": "^4.3.1",
1414
"@astrojs/starlight": "^0.34.8",
1515
"@astrojs/starlight-tailwind": "^4.0.1",
16+
"@expressive-code/plugin-collapsible-sections": "^0.41.3",
1617
"@tailwindcss/vite": "^4.1.11",
1718
"astro": "^5.6.1",
1819
"astro-expressive-code": "^0.41.3",

docs_headless/src/content/docs/mui/guides/Architecture.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,18 @@ React-admin avoids components that accept an overwhelming number of props, which
139139

140140
For example, while you cannot directly pass a list of actions to the `<Edit>` component, you can achieve the same result by passing an `actions` component:
141141

142-
```jsx
142+
```jsx "actions={<PostEditActions />}" collapse={1-4, 8-11}
143143
// File name: src/PostEdit.tsx
144144
import { Button } from '@mui/material';
145-
import { TopToolbar, ShowButton } from 'react-admin';
145+
import { ShowButton, TextInput, TopToolbar } from 'react-admin';
146+
import { RichTextInput } from 'ra-input-rich-text';
146147

147148
export const PostEdit = () => (
148149
<Edit actions={<PostEditActions />}>
149-
...
150+
<SimpleForm>
151+
<TextInput source="title" />
152+
<RichTextInput source="body" />
153+
</SimpleForm>
150154
</Edit>
151155
);
152156

@@ -163,7 +167,7 @@ This approach enables you to override specific parts of the logic of a component
163167
The trade-off with this approach is that sometimes react-admin may require you to override several components just to enable one specific feature. For instance, to override the Menu, you must first create a custom layout using your menu as the `<Layout menu>` prop, then pass it as the `<Admin layout>` prop:
164168

165169
::: code-group labels=[src/MyLayout.tsx, src/App.tsx]
166-
```tsx
170+
```tsx "import { Menu } from './Menu';" "menu={Menu}"
167171
import { Layout } from 'react-admin';
168172
import { Menu } from './Menu';
169173

@@ -173,7 +177,7 @@ export const MyLayout = ({ children }) => (
173177
</Layout>
174178
);
175179
```
176-
```tsx
180+
```tsx "import { MyLayout } from './MyLayout';" "layout={MyLayout}"
177181
import { Admin } from 'react-admin';
178182
import { MyLayout } from './MyLayout';
179183

yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,6 +2184,15 @@ __metadata:
21842184
languageName: node
21852185
linkType: hard
21862186

2187+
"@expressive-code/plugin-collapsible-sections@npm:^0.41.3":
2188+
version: 0.41.3
2189+
resolution: "@expressive-code/plugin-collapsible-sections@npm:0.41.3"
2190+
dependencies:
2191+
"@expressive-code/core": "npm:^0.41.3"
2192+
checksum: 28050a5822c15f7ac24f857bf975662671a9097805fc9f7cf049c41be73a7da2211fa927b2638a2aad1357830171624fe7d0049e2cea8ce46d1636786429a2e9
2193+
languageName: node
2194+
linkType: hard
2195+
21872196
"@expressive-code/plugin-frames@npm:^0.41.3":
21882197
version: 0.41.3
21892198
resolution: "@expressive-code/plugin-frames@npm:0.41.3"
@@ -19159,6 +19168,7 @@ __metadata:
1915919168
"@astrojs/mdx": "npm:^4.3.1"
1916019169
"@astrojs/starlight": "npm:^0.34.8"
1916119170
"@astrojs/starlight-tailwind": "npm:^4.0.1"
19171+
"@expressive-code/plugin-collapsible-sections": "npm:^0.41.3"
1916219172
"@tailwindcss/vite": "npm:^4.1.11"
1916319173
astro: "npm:^5.6.1"
1916419174
astro-expressive-code: "npm:^0.41.3"

0 commit comments

Comments
 (0)