Skip to content

Commit c57c0c8

Browse files
authored
Material: update the getting-started docs
1 parent caac75d commit c57c0c8

File tree

1 file changed

+62
-62
lines changed

1 file changed

+62
-62
lines changed

ui-libraries/material/docs/src/content/docs/getting-started.mdx

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -14,84 +14,84 @@ import { Steps, Tabs, TabItem } from '@astrojs/starlight/components';
1414
Welcome to the documentation for the Material 3 Design System for Slint. Learn more about
1515
Slint [here](https://slint.dev/).
1616

17-
We recommend using an IDE for development, along with our [LSP-based IDE integration for
18-
.slint files](https://github.com/slint-ui/slint/blob/master/tools/lsp/README.md). You
19-
can also load this project directly in [Visual Studio Code](https://code.visualstudio.com/)
20-
and install our [Slint extension](https://marketplace.visualstudio.com/items?itemName=Slint.slint).
17+
To start a project from scratch, follow the instructions from one of our template reprositories:
2118

22-
<Tabs>
19+
<Tabs syncKey="dev-language">
20+
<TabItem label="C++">
21+
https://github.com/slint-ui/material-cpp-template
22+
</TabItem>
2323
<TabItem label="Rust">
24+
https://github.com/slint-ui/material-rust-template
25+
</TabItem>
26+
<TabItem label="NodeJS">
27+
https://github.com/slint-ui/material-nodejs-template
28+
</TabItem>
29+
<TabItem label="Python" >
30+
https://github.com/slint-ui/material-python-template
31+
</TabItem>
32+
</Tabs>
2433

25-
1. Install Rust by following its [getting-started guide](https://www.rust-lang.org/learn/get-started). Once this is done, you should have the rustc compiler and the cargo build system installed in your `PATH`.
26-
2. Clone the getting-started repository:
27-
```bash
28-
git clone --recurse-submodules https://github.com/slint-ui/material-rust-template.git my-project
29-
cd my-project
30-
```
31-
3. Build the sample application:
32-
```bash
33-
cargo build
34-
```
35-
4. Run the sample application:
36-
```bash
37-
cargo run
38-
```
34+
To use the components in your existing project, download the source code of the material component from
35+
https://material.slint.dev/zip/material-1.0.zip
36+
and extract it into your repository.
37+
Then follow the [documentation to configure the use of `@material` as a library](https://docs.slint.dev/latest/docs/slint/guide/language/coding/file/#component-libraries).
3938

40-
With Rust based Slint apps you can also target Web and Android. For more details, see the [template repository](https://github.com/slint-ui/material-rust-template).
39+
Here's an example of how to configure it for different languages:
4140

42-
</TabItem>
41+
<Tabs syncKey="dev-language">
4342
<TabItem label="C++">
44-
1. Setup the [development environment](https://docs.slint.dev/latest/docs/cpp/cmake).
45-
2. Clone the getting-started repository:
46-
```bash
47-
git clone --recurse-submodules https://github.com/slint-ui/material-cpp-template.git my-project
48-
cd my-project
43+
In your `CMakeLists.txt` file, use `LIBRARY_PATHS` in the `slint_target_sources` function.
44+
45+
```cmake
46+
slint_target_sources(my_application
47+
ui/main.slint
48+
LIBRARY_PATHS
49+
material=${CMAKE_CURRENT_SOURCE_DIR}/material-1.0/material.slint
50+
)
4951
```
50-
3. Build the sample application:
51-
```bash
52-
mkdir build && cd build
53-
cmake .. -G Ninja
54-
cmake --build .
55-
```
56-
4. Run the sample application:
57-
```bash
58-
./my_application
52+
</TabItem>
53+
<TabItem label="Rust">
54+
In your `build.rs`, call `CompilerConfiguration::with_library_paths`
55+
56+
```rust
57+
// build.rs
58+
fn main() {
59+
let config = slint_build::CompilerConfiguration::new().with_library_paths(
60+
std::collections::HashMap::from([(
61+
"material".to_string(),
62+
std::path::Path::new(&std::env::var_os("CARGO_MANIFEST_DIR").unwrap())
63+
.join("material-1.0/material.slint"),
64+
)]),
65+
);
66+
slint_build::compile_with_config("ui/main.slint", config).unwrap();
67+
}
5968
```
6069
</TabItem>
6170
<TabItem label="NodeJS">
62-
63-
1. Install [Node.js](https://nodejs.org/) and [npm](https://www.npmjs.com/).
64-
2. Clone the getting-started repository:
65-
```bash
66-
git clone --recurse-submodules https://github.com/slint-ui/material-nodejs-template.git my-project
67-
cd my-project
68-
```
69-
3. Install the dependencies:
70-
```bash
71-
npm install
72-
```
73-
4. Run the sample application:
74-
```bash
75-
npm start
71+
Provide the `libraryPaths` map with `loadFile`:
72+
73+
```javascript
74+
let ui = slint.loadFile("ui/main.slint", {
75+
libraryPaths: {
76+
"material": path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "material-1.0", "material.slint")
77+
}
78+
});
7679
```
77-
7880
</TabItem>
79-
<TabItem label="Python" >
80-
1. Install [uv](https://docs.astral.sh/uv/).
81-
2. Clone the getting-started repository:
82-
```bash
83-
git clone --recurse-submodules https://github.com/slint-ui/material-python-template.git my-project
84-
cd my-project
85-
```
86-
3. Run the sample application:
87-
```bash
88-
uv run main.py
81+
<TabItem label="Python">
82+
Provide the `library_paths` dict with `load_file`:
83+
84+
```python
85+
ui = slint.load_file(
86+
Path(__file__).parent / "ui" / "main.slint",
87+
library_paths={
88+
"material": Path(__file__).parent / "material-1.0" / "material.slint"
89+
},
90+
)
8991
```
90-
9192
</TabItem>
9293
</Tabs>
9394
94-
9595
## Next Steps
9696
9797
All the documentation for Slint's Material UI components can be found on this site.

0 commit comments

Comments
 (0)