Skip to content

Commit

Permalink
20230930-SurrealismUI_V0.1.5✅
Browse files Browse the repository at this point in the history
  • Loading branch information
syf20020816 committed Sep 30, 2023
1 parent 1edc41a commit a28293c
Show file tree
Hide file tree
Showing 17 changed files with 556 additions and 51 deletions.
84 changes: 81 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<img src="https://img.shields.io/badge/SurrealismUI-0.1.4-orange?style=flat-square&logo=rust&logoColor=%23fff&labelColor=%23DEA584&color=%23DEA584"> <img src="https://img.shields.io/badge/License-MIT-orange?style=flat-square&logoColor=%23fff&labelColor=%2323B898&color=%2323B898">
<img src="https://img.shields.io/badge/SurrealismUI-0.1.5-orange?style=flat-square&logo=rust&logoColor=%23fff&labelColor=%23DEA584&color=%23DEA584"> <img src="https://img.shields.io/badge/License-MIT-orange?style=flat-square&logoColor=%23fff&labelColor=%2323B898&color=%2323B898">

# SurrealismUI

Expand All @@ -21,6 +21,10 @@ SurrealismUI is a third-party component library built entirely using Slint

### Updates

- V0.1.5
- add `SURMenu`
- enhance `SURTip` (the location of the tip can be changed now and you can show it with hover ! )

- V0.1.4
- add `SURTip`
- add `SURLoading`
Expand Down Expand Up @@ -1602,6 +1606,8 @@ A tip provides supplemental, contextual information elevated near its target com

* `in property <Themes> theme` : Surrealism Theme
* `in property <string> content` : tip content
* `in-out property <bool> show-tip` : hover and tip will show
* `in property <TipPosition> pos` : the position of the tip

#### functions

Expand All @@ -1622,24 +1628,53 @@ import {Themes} from "../../themes/index.slint";
component TestWindow inherits Window {
height: 400px;
width: 400px;
SURTip{
y: 80px;
height:inner0.height;
width: inner0.width;
theme: Dark;
pos:Top;
content:"this is a \n........tip window";
show-tip:inner0.has-hover;
inner0:=SURButton {
content: "click";
}
}
SURTip{
height:inner.height;
width: inner.width;
theme: Dark;
content:"this is a \ntip window";
pos:Left;
content:"this is a \n........tip window";
inner:=SURButton {
content: "click";
clicked => {
parent.clicked();
}
}
}
SURTip{
y: 300px;
height:inner2.height;
width: inner2.width;
theme: Dark;
pos:Top;
content:"this is a \n........tip window";
inner2:=SURButton {
content: "click";
clicked => {
parent.clicked();
}
}
}
}
```

![image-20230916101547495](https://github.com/syf20020816/SurrealismUI/blob/main/README/imgs/image-20230916101547495.png)

![image-20230930183024974](https://github.com/syf20020816/SurrealismUI/blob/main/README/imgs/image-20230930183024974.png)

### SURLoading (some error in animation)

This is a loading component that you can embed anywhere you want to add a loading animation (now animation have some error)
Expand Down Expand Up @@ -1778,3 +1813,46 @@ component TestDialog inherits Window {
```

![image-20230919091100568](https://github.com/syf20020816/SurrealismUI/blob/main/README/imgs/image-20230919091100568.png)

### SURMenu
SURMenu is a menu bar located on the left side that you can quickly generate through the menu-data property
#### properties
- `in-out property <length> icon-box-size` : menu item size ⛔
- `in-out property <length> icon-size` : menu item icon size ⛔;
- `in property <[MenuData]> menu-data` : menu item data (generate menus through it)
- `in-out property <int> active` : which item is active
- `private property <brush> hover-icon-color` : menu item icon color changed when hover
#### callbacks
- `callback change(int,MenuData)` : run if you click menu item
- `callback clicked-account()` : run if you click account icon
- `callback clicked-setting()` : run if you click setting icon

#### example

```
import { SURMenu , SURIcon} from "../../index.slint";
import {IconSources} from "../../themes/index.slint";
component TestMenu inherits Window {
height: 600px;
width: 300px;
Rectangle {
x: 0;
y: 0;
height:parent.height;
width: menu.width;
menu:=SURMenu {
theme: Dark;
change(index,item)=>{
debug(index);
debug(item);
}
clicked-account()=>{
debug("clicked account");
}
}
}
}
```

![image-20230930181846475](https://github.com/syf20020816/SurrealismUI/blob/main/README/imgs/image-20230930181846475.png)
Binary file modified README.pdf
Binary file not shown.
Binary file removed README/imgs/image-20230916101547495.png
Binary file not shown.
Binary file added README/imgs/image-20230930181846475.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added README/imgs/image-20230930183024974.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions index.slint
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import { SURRadio } from "./src/radio/index.slint";
import { SURBadge,Position } from "./src/badge/index.slint";
import { SURPersona } from "./src/persona/index.slint";
import { SURProgress } from "./src/progress/index.slint";
import { SURTip } from "./src/tip/index.slint";
import { SURTip,TipPosition } from "./src/tip/index.slint";
import { SURLoading } from "./src/loading/index.slint";
import { SURDialog } from "./src/dialog/index.slint";
import { SURMenu,MenuData } from "./src/menu/index.slint";

export {
SURText,
Expand Down Expand Up @@ -53,5 +54,8 @@ export {
SURProgress,
SURTip,
SURLoading,
SURDialog
SURDialog,
SURMenu,
MenuData,
TipPosition
}
1 change: 1 addition & 0 deletions src/button/button.slint
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export component Button inherits SURCard {
in property <bool> font-italic:ROOT-STYLES.sur-font.font-italic;
in property <int> font-weight:ROOT-STYLES.sur-font.font-weight;
in property <string> font-family:ROOT-STYLES.sur-font.font-family;
out property <bool> has-hover <=>toucharea.has-hover;
in-out property <string> content : "SURButton";

states [
Expand Down
3 changes: 2 additions & 1 deletion src/icon/dev.slint
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ global IconSources {
Link_left:@image-url("../../icons/link-left.svg"),
Preview_close:@image-url("../../icons/preview-close.svg"),
Preview_open:@image-url("../../icons/preview-open.svg"),
Close_one:@image-url("../../icons/close-one.svg")
Close_one:@image-url("../../icons/close-one.svg"),
Setting_two:@image-url("../../icons/setting-two.svg")
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/icon/icon.slint
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export component Icon inherits Rectangle {
pure public function get-icon()->bool {
icon==@image-url("") ? true:false
}

callback clicked;
clicked => {}
states [
Expand Down Expand Up @@ -101,6 +102,7 @@ export component Icon inherits Rectangle {
}
}
}

]
toucharea:=TouchArea{
mouse-cursor: pointer;
Expand Down
3 changes: 3 additions & 0 deletions src/menu/index.slint
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Menu,MenuData } from "./menu.slint";

export { Menu as SURMenu,MenuData }
146 changes: 146 additions & 0 deletions src/menu/menu.slint
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/**
* ============================================
* @author:syf20020816@outlook.com
* @since:20230930
* @version:0.1.5
* @type:interface
* @description:
* # SURMenu
* SURMenu is a menu bar located on the left side that you can quickly generate through the menu-data property
* ## properties
* - in-out property <length> icon-box-size : menu item size ⛔
* - in-out property <length> icon-size : menu item icon size ⛔;
* - in property <[MenuData]> menu-data : menu item data (generate menus through it)
* - in-out property <int> active : which item is active
* - private property <brush> hover-icon-color : menu item icon color changed when hover
* ## callbacks
* - callback change(int,MenuData) : run if you click menu item
* - callback clicked-account() : run if you click account icon
* - callback clicked-setting() : run if you click setting icon
* ============================================
*/
import { SURCard } from "../card/index.slint";
import { SURIcon } from "../icon/index.slint";
import {IconSources,ROOT-STYLES,Themes} from "../../themes/index.slint";
import { SURTip } from "../tip/index.slint";

export struct MenuData {
id:int,
icon : image,
name : string,
}

component MenuItem inherits Rectangle {
in property <brush> hover-icon-color;
in property <image> icon;
in property <length> icon-size;
in property <Themes> theme;
in property <bool> active;
out property <bool> has-hover <=> area.has-hover;
states [
hover when area.has-hover:{icon.icon-color : hover-icon-color;}
]
callback clicked();

area:=TouchArea {
mouse-cursor: pointer;
z: 116;
clicked => {
root.clicked();
}
}
if active:SURCard {
x: 0;
height: root.height;
width: 2px;
theme: root.theme;
border: None;
border-radius: 0;
background: ROOT-STYLES.radio-active;
drop-shadow-blur: 0;
drop-shadow-color: ROOT-STYLES.radio-active;
drop-shadow-offset-x: 0;
drop-shadow-offset-y: 0;
}
icon:=SURIcon {
theme: root.theme;
height:root.icon-size;
width: root.icon-size;
icon: root.icon;
}
}

export component Menu inherits SURCard {
height: 100%;
width: 60px;
border-radius: 0;

in-out property <length> icon-box-size : 60px;
in-out property <length> icon-size : ROOT-STYLES.sur-font.font-size * 2 ;
in property <[MenuData]> menu-data : [
{id:0,icon:@image-url("../../icons/file-code.svg"),name:"Code"},
{id:1,icon:@image-url("../../icons/search.svg"),name:"Search"},
{id:2,icon:@image-url("../../icons/bug.svg"),name:"Debug"},
];
in-out property <int> active : 0;
private property <brush> hover-icon-color : empty.icon-color.brighter(1);
// params :
// 1. index
// 2. menu item
callback change(int,MenuData);
callback clicked-account();
callback clicked-setting();
VerticalLayout {
top-view:=VerticalLayout {
height: parent.height - bottom-view.height;
alignment: start;
for item[index] in menu-data: SURTip {
height: menu-item.height;
width: icon-box-size;
content: item.name;
theme: root.theme;
pos: Right;
show-tip : menu-item.has-hover;
menu-item:=MenuItem{
active: item.id == root.active;
height: icon-box-size;
icon: item.icon;
icon-size: root.icon-size;
theme: root.theme;
clicked => {
root.active = item.id;
root.change(index,item);
}
}
}
}
bottom-view:=VerticalLayout{
height:empty-box.height + 120px ;
empty-box:=Rectangle{
height: icon-size * 2;
empty:=SURIcon{
theme: root.theme;
icon: IconSources.icons.Null;
}
}
account-box:=MenuItem{
height: icon-box-size;
icon: IconSources.icons.Avatar;
icon-size: root.icon-size;
theme: root.theme;
clicked => {
root.clicked-account();
}
}
setting-box:=MenuItem{
height: icon-box-size;
icon: IconSources.icons.Setting-two;
icon-size: root.icon-size;
theme: root.theme;
clicked => {
root.clicked-setting();
}
}
}
}
}
4 changes: 2 additions & 2 deletions src/tip/index.slint
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Tip } from "./tip.slint";
import { Tip,TipPosition } from "./tip.slint";

export { Tip as SURTip }
export { Tip as SURTip,TipPosition }
Loading

0 comments on commit a28293c

Please sign in to comment.