Skip to content

Commit b9bb16d

Browse files
Implement "docusaurus-theme-github-codeblock" plugin (#373)
1 parent 0cb01dc commit b9bb16d

File tree

4 files changed

+336
-34
lines changed

4 files changed

+336
-34
lines changed

docs/controls/snackbar.md

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,15 @@ sidebar_label: SnackBar
55

66
A lightweight message with an optional action which briefly displays at the bottom of the screen.
77

8-
import Tabs from '@theme/Tabs';
9-
import TabItem from '@theme/TabItem';
10-
118
## Examples
129

1310
[Live example](https://flet-controls-gallery.fly.dev/dialogs/snackbar)
1411

1512
### SnackBar with dynamic message
1613

17-
<Tabs groupId="language">
18-
<TabItem value="python" label="Python" default>
19-
20-
```python
21-
import flet as ft
22-
23-
class Data:
24-
def __init__(self) -> None:
25-
self.counter = 0
26-
27-
d = Data()
28-
29-
def main(page):
30-
31-
page.snack_bar = ft.SnackBar(
32-
content=ft.Text("Hello, world!"),
33-
action="Alright!",
34-
)
35-
36-
def on_click(e):
37-
page.snack_bar = ft.SnackBar(ft.Text(f"Hello {d.counter}"))
38-
page.snack_bar.open = True
39-
d.counter += 1
40-
page.update()
41-
42-
page.add(ft.ElevatedButton("Open SnackBar", on_click=on_click))
43-
44-
ft.app(main)
14+
```python reference
15+
https://github.com/flet-dev/examples/blob/main/python/controls/snack-bar/simple-snack.py
4516
```
46-
</TabItem>
47-
</Tabs>
4817

4918
<img src="/img/docs/controls/snackbar/snackbar-with-custom-content.gif" className="screenshot-40"/>
5019

docusaurus.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@ module.exports = {
1515
heroTitle: 'Build multi-platform apps in Python powered by Flutter',
1616
heroSubTitle: 'Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.',
1717
},
18+
themes: [
19+
'docusaurus-theme-github-codeblock'
20+
],
1821
themeConfig: {
22+
// github codeblock theme configuration
23+
codeblock: {
24+
showGithubLink: true,
25+
githubLinkLabel: 'View on GitHub',
26+
showRunmeLink: false,
27+
runmeLinkLabel: 'Checkout via Runme'
28+
},
1929
docs: {
2030
sidebar: {
2131
hideable: true,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@hcaptcha/react-hcaptcha": "^1.0.0",
1616
"@mdx-js/react": "^3.0.0",
1717
"clsx": "^1.1.1",
18+
"docusaurus-theme-github-codeblock": "^2.0.2",
1819
"prism-react-renderer": "^2.1.0",
1920
"react": "^18.2.0",
2021
"react-dom": "^18.2.0",

0 commit comments

Comments
 (0)