Skip to content

Commit

Permalink
catalog, slider update
Browse files Browse the repository at this point in the history
  • Loading branch information
syf20020816 committed May 24, 2024
1 parent 6d57496 commit e0f1484
Show file tree
Hide file tree
Showing 17 changed files with 350 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<img src="https://img.shields.io/badge/SurrealismUI-0.4.3-orange?style=for-the-badge&logo=rust&logoColor=%23fff&labelColor=%23DEA584&color=%23DEA584"> <img src="https://img.shields.io/badge/License-MIT-orange?style=for-the-badge&logoColor=%23fff&labelColor=%2323B898&color=%2323B898">
<img src="https://img.shields.io/badge/SurrealismUI-0.4.5-orange?style=for-the-badge&logo=rust&logoColor=%23fff&labelColor=%23DEA584&color=%23DEA584"> <img src="https://img.shields.io/badge/License-MIT-orange?style=for-the-badge&logoColor=%23fff&labelColor=%2323B898&color=%2323B898">

# SurrealismUI

- author:syf20020816@outlook.com
- createDate:20230908
- updateDate:20240407
- version:0.4.3
- updateDate:20240526
- version:0.4.5
- email:syf20020816@outlook.com
- discord:[Surrealism-UI](https://discord.gg/KSQqrSMCnU)

Expand Down
8 changes: 4 additions & 4 deletions index.html

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- [SPersona](./components/data/persona.md)
- [SBadge](./components/data/badge.md)
- [SProgress](./components/data/progress.md)
- [SSlider](./components/data/slider.md)
- [STree](./components/data/tree.md)
- [SFile](./components/data/file.md)
- [SStep](./components/data/step.md)
Expand All @@ -48,6 +49,7 @@
- [SMenu](./components/nav/menu.md)
- [STab](./components/nav/tab.md)
- [STabbar](./components/nav/tabbar.md)
- [SCatalog](./components/nav/catalog.md)
- [Feedback](./components/feedback/feedback.md)
- [Result](./components/feedback/result.md)
- [SPopup](./components/feedback/popup.md)
Expand All @@ -63,4 +65,8 @@
- [Schemas](./build-in/global/schema.md)
- [Struct Enum](./build-in/struct.md)
- [Function](./build-in/function.md)
- [Examples](./examples/index.md)
- [Inherits](./examples/inherits/index.md)
- [All Inherits](./examples/inherits/all.md)
- [Partial Inherits](./examples/inherits/partial.md)
- [Updates](./updates.md)
31 changes: 31 additions & 0 deletions src/build-in/global/defaults.md
Original file line number Diff line number Diff line change
Expand Up @@ -878,3 +878,34 @@ export global DefaultSTreeProps {
};
}
```

## DefaultSCatalogProps

```rust
export global DefaultSCatalogProps {
in property <PaddingType> padding-type: PaddingType.Normal;
in property <Themes> theme: GlobalProps.theme;
in property <[CatalogItem]> items;
in property <length> font-size: GlobalProps.font.font-size;
in property <int> font-wight: GlobalProps.font.font-weight;
in property <string> font-family: GlobalProps.font.font-family;
in property <bool> font-italic: GlobalProps.font.font-italic;
in property <length> spacing;
in property <brush> active-color;
out property <length> real-height: items.length * root.item-height;
in-out property <length> item-height;
}
```

## DefaultSSliderProps

```rust
export global DefaultSSliderProps {
in property <Orientation> orientation: Orientation.horizontal;
in property <Themes> theme :DefaultSProgressProps.theme;
in-out property <float> progress : 0;
in-out property <length> stroke-width: DefaultSProgressProps.stroke-width;
in-out property <brush> stroke-color: UseSurrealismFn.get-color(root.theme, ColorLevel.Normal);
in property <length> border-radius: 6px;
}
```
44 changes: 44 additions & 0 deletions src/build-in/struct.md
Original file line number Diff line number Diff line change
Expand Up @@ -1013,4 +1013,48 @@ export struct STimeLineProps {
font-size: length,
active: bool,
}
```

## SSliderProps

```rust
export struct SSliderProps {
orientation: Orientation,
theme :Themes,
progress : float,
stroke-width: length,
stroke-color: brush,
border-radius: length,
}
```

## SCatalogProps
```rust
export struct SCatalogProps {
padding-type: PaddingType,
theme: Themes,
items: [CatalogItem],
font-size: length,
font-wight: int,
font-family: string,
font-italic: bool,
spacing: length,
active-color: brush,
real-height: length,
item-height: length,
}
```

### CatalogItem
```rust
export struct CatalogItem {
left-icon: image,
show-left-icon: bool,
label: string,
show-label: bool,
value: string,
right-icon: image,
show-right-icon: bool,
align: LayoutAlignment,
}
```
4 changes: 3 additions & 1 deletion src/components/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@
- `STimeLine`:The timeline component is mainly used to display the changes of data over time, and it is usually used in data visualization to visually represent time series data
- `SNumberInput`:A numeric input component that inherits from SCard, designed for inputting numerical values within a specified range. It allows adjustments through increment and decrement actions.
- `SCalendar`:A calendar component that inherits from SCard. It is designed to display a month view with the ability to navigate and select dates.
- `STabbar`: provide bottom operation bar for page switching
- `STabbar`: provide bottom operation bar for page switching
- `SSlider`: The Slider component is used for creating a slider control that allows users to select a value within a range. It supports customization of orientation, theme, and visual properties.
- `SCatalog`: The Catalog component is used to display a series of catalog items, each of which can contain labels and icons, and has click interaction functionality.
100 changes: 100 additions & 0 deletions src/components/data/slider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# SSlider
The Slider component is used for creating a slider control that allows users to select a value within a range. It supports customization of orientation, theme, and visual properties.

![](../../static/slider.gif)
## example
```rust
import {SSlider, SButton} from "../../index.slint";


component TestSlider inherits Window{
height: 400px;
width: 400px;
VerticalLayout {
spacing: 20px;
padding: 20px;
SSlider {
theme: Light;
width: 360px;
height: 40px;
stroke-width: 16px;
progress: 0.3;
}
SSlider {
width: 360px;
height: 40px;
progress: 80%;
}

HorizontalLayout {
spacing: 30px;
slider:= SSlider {
theme: Success;
width: 30px;
height: 220px;
stroke-width: 220px;
progress: 30%;
orientation: Orientation.vertical;
moved(progress) => {
debug(progress);
}
}
VerticalLayout {
spacing: 20px;
HorizontalLayout {
spacing: 20px;
SButton{
text: "set";
clicked => {
slider.set(0.45);
}
}
SButton{
text: "add";
clicked => {
slider.add(0.1);
}
}
}
HorizontalLayout {
spacing: 20px;
SButton{
text: "sub";
clicked => {
slider.sub(0.1);
}
}
SButton{
text: "full";
clicked => {
slider.full();
}
}
SButton{
text: "clear";
clicked => {
slider.clear();
}
}
}
}
}
}
}
```

## properties
- `in property <Orientation> orientation` : Sets the orientation of the slider.
- `in property <Themes> theme` : Sets the theme of the slider.
- `in-out property <float> progress` : Controls the progress value of the slider.
- `in-out property <length> stroke-width` : Sets the stroke width of the slider.
- `in-out property <brush> stroke-color` : Sets the stroke color of the slider.
- `in property <length> border-radius` : Sets the border radius of the slider bar, linked to bar.border-radius.
## functions
- `public function set(progress: float)` : Sets the slider progress to a specific value and triggers the moved callback.
- `public function add(len: float)` : Increases the slider progress by a specified value and triggers the moved callback.
- `public function sub(len: float)` : Decreases the slider progress by a specified value and triggers the moved callback.
- `public function full()` : Sets the slider progress to 1 (full) and triggers the moved callback.
- `public function clear()` : Sets the slider progress to 0 (empty) and triggers the moved callback.
## callbacks
- `callback moved(float)` : Triggered when the slider is moved, passing the current progress value as a float.
116 changes: 116 additions & 0 deletions src/components/nav/catalog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# SCatalog

The Catalog component is used to display a series of catalog items, each of which can contain labels and icons, and has click interaction functionality.

![](../../static/catalog.gif)

## example

```rust
import {SCatalog} from "../../index.slint";
import { CatalogItem, UseIcons } from "../../use/index.slint";
component TestCatalog inherits Window{
height: 480px;
width: 400px;
in property <CatalogItem> base: {
left-icon: UseIcons.icons.Attention,
show-left-icon: true,
label: "Attention",
show-label: true,
value: "8uyf23rfgd",
right-icon: UseIcons.icons.Right,
show-right-icon: true,
align: LayoutAlignment.space-between,
};

VerticalLayout {
spacing: 10px;
SCatalog {
height: self.real-height;
items: [
{
left-icon: UseIcons.icons.Attention,
show-left-icon: true,
label: "Attention",
show-label: true,
value: "8uyf23rfgd",
right-icon: UseIcons.icons.Right,
show-right-icon: true,
align: LayoutAlignment.space-between,
},
{
left-icon: UseIcons.icons.Help,
show-left-icon: true,
label: "Help",
show-label: true,
value: "8uyf23rfgd1",
right-icon: UseIcons.icons.Right,
show-right-icon: true,
align: LayoutAlignment.space-between,
},
{
left-icon: UseIcons.icons.More,
show-left-icon: true,
label: "More",
show-label: true,
value: "8uyf23rfgd2",
right-icon: UseIcons.icons.Right,
show-right-icon: true,
align: LayoutAlignment.space-between,
}
];
}
SCatalog {
theme: Primary;
height: self.real-height;
items: [
base,
{
left-icon: UseIcons.icons.Folder-filled,
show-left-icon: true,
label: "Folder",
show-label: true,
value: "8uyf23rfgd2",
right-icon: UseIcons.icons.Right,
show-right-icon: false,
align: LayoutAlignment.center,
},
base,
base,
{
left-icon: UseIcons.icons.More,
show-left-icon: true,
label: "More",
show-label: false,
value: "8uyf23rfgd2",
right-icon: UseIcons.icons.Right,
show-right-icon: true,
align: LayoutAlignment.space-between,
},
base,
];
clicked(index, item) => {
debug(index);
debug(item.value);
}
}
}
}
```

## properties
- `in property <PaddingType> padding-type` : catalog padding type
- `in property <Themes> theme` : SurrealismUI theme
- `in property <[CatalogItem]> items` : catalog items see `CatalogItem`
- `in property <length> font-size` : catalog label font size, which affect the height of the catalog item
- `in property <int> font-wight` : catalog label font weight
- `in property <string> font-family` : catalog label font family
- `in property <bool> font-italic` : catalog label font italic
- `in property <length> spacing` : spacing between left icon and label
- `in property <brush> active-color` : catalog item active color
- `out property <length> real-height` : real height of the catalog, you can use it to set the height of the catalog (recommend)
- `in-out property <length> item-height` : height of the catalog item
## functions
- `pure function has-active(hover: bool, pressed: bool) -> bool` : judge whether the catalog item is active
## callbacks
- `callback clicked(int, CatalogItem)`: click event callback, return the index of the clicked item and the item object
3 changes: 3 additions & 0 deletions src/components/over-all.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
|SPersona(个人信息组件)|This component is used to display simple user introduction information|
|SBadge(勋章组件)|SBadge is a quick way to display user status or events|
|SProgress(进度条组件)|SProgress is commonly used to display download progress or event processing progress.And you can fully control it through the progress property|
|SSlider(滑块组件)| The Slider component is used for creating a slider control that allows users to select a value within a range. It supports customization of orientation, theme, and visual properties.|
|STree(树型组件)|STree can be used to display directory structure, forming a parent-child relationship, and can be easily displayed|
|SFile(文件组件)|SFile can help users present file selectors GUI|
|SStep(步骤组件)|The Step component visualizes the progress of a sequence by breaking it down into individual steps. It allows for custom theming and supports indicating the current, completed, and pending steps through visual cues.|
Expand All @@ -44,6 +45,7 @@
|SSwitch(选项组件)|SSwitch is a switch used for simple judgment scenarios|
|SSwitchGroup(选项组组件)|SSwitchGroup switch group can contain more switch cases|
|SNumberInput(数字选择器)|A numeric input component that inherits from SCard, designed for inputting numerical values within a specified range. It allows adjustments through increment and decrement actions.|

## Nav Components

|name|description|
Expand All @@ -52,6 +54,7 @@
|SMenu(菜单组件)|SMenu is a menu bar located on the left side that you can quickly generate through the menu-data property|
|STab(标签页组件)|provide tab functionality, so that users can switch between different content sections|
|STabbar(底部导航栏组件)|provide bottom operation bar for page switching|
|SCatalog(目录组件)|The Catalog component is used to display a series of catalog items, each of which can contain labels and icons, and has click interaction functionality|

## Feedback Components

Expand Down
4 changes: 4 additions & 0 deletions src/ecology.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

- [slint_learn](https://github.com/syf20020816/slint_learn): Help everyone quickly learn Slint

## Video for SurrealismUI

[video url](https://www.bilibili.com/video/BV14U411f7LX/)

## Video for Slint Learn

- [Easy](https://www.bilibili.com/video/BV1r14y1k7T5/?spm_id_from=333.999.0.0&vd_source=9c2ae08297163e79152407c969f04717)
Expand Down
4 changes: 4 additions & 0 deletions src/examples/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Examples (comming soon)

- How to inherits SurrealismUI Widget
- Outlook (use SurrealismUI build Outlook email platform)
Loading

0 comments on commit e0f1484

Please sign in to comment.