Skip to content
This repository was archived by the owner on Jun 17, 2024. It is now read-only.

Commit d8a829f

Browse files
committed
feat: add home page
1 parent 2a43a73 commit d8a829f

File tree

13 files changed

+110
-99
lines changed

13 files changed

+110
-99
lines changed

app/assets/views/home.xml

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<lcui-app>
33
<ui>
4-
<home>
5-
<w class="nav nav-tabs d-flex justify-content-center" ref="tabs">
6-
<w class="nav-item">
7-
<text class="nav-link active" data-toggle="tab" data-target="preview">Preview</text>
8-
</w>
9-
<w class="nav-item">
10-
<text class="nav-link" data-toggle="tab" data-target="about">About</text>
11-
</w>
12-
<w class="bav-tabs-bottom" />
13-
</w>
14-
<w class="tab-content" ref="tab-content">
15-
<w class="tab-pane active" id="preview">
16-
<resource type="text/xml" src="assets/views/preview.xml" />
17-
</w>
18-
<w class="tab-pane" id="about">
19-
<w class="about-container">
20-
<about />
21-
<w class="input-group">
22-
<textview>Enter a message and save it.</textview>
23-
<textedit ref="input-message" placeholder="eg: hello, world!" />
24-
<button ref="btn-save-message">Save</button>
25-
<textview ref="feedback" class="feedback">Message has been saved!</textview>
26-
</w>
27-
</w>
28-
</w>
29-
</w>
30-
</home>
4+
<w class="v-home__cards container d-flex justify-content-center">
5+
<router-link class="v-home__card" to="/welcome">
6+
<icon class="v-home__card-icon text-pink" name="emoticon-cool-outline" />
7+
<text class="v-home__card-title">Welcome!</text>
8+
</router-link>
9+
</w>
3110
</ui>
3211
</lcui-app>

config/router.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
module.exports = [
22
{
3-
name: 'frame#welcome',
4-
path: 'welcome',
3+
name: 'home',
4+
path: '/',
5+
component: 'home'
6+
},
7+
{
8+
name: 'welcome',
9+
path: '/welcome',
510
component: 'welcome'
611
},
712
{
8-
name: 'frame#about',
9-
path: 'about',
13+
name: 'about',
14+
path: '/about',
1015
component: 'about'
1116
},
1217
{

src/app.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
#include "ui.h"
2-
#include "router.h"
32

43
int main(void)
54
{
65
int ret = -1;
7-
router_t *router;
86

9-
router = router_create_with_config("main", "main");
107
if (UI_Init() == 0) {
118
ret = UI_Run();
129
}
13-
router_destroy(router);
1410
return ret;
1511
}

src/lib/router.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ static void router_add_default_config(router_t *router)
66
router_config_t *config;
77

88
config = router_config_create();
9-
router_config_set_name(config, "frame#welcome");
10-
router_config_set_path(config, "welcome");
9+
router_config_set_name(config, "home");
10+
router_config_set_path(config, "/");
11+
router_config_set_component(config, NULL, "home");
12+
router_add_route_record(router, config, NULL);
13+
router_config_destroy(config);
14+
15+
config = router_config_create();
16+
router_config_set_name(config, "welcome");
17+
router_config_set_path(config, "/welcome");
1118
router_config_set_component(config, NULL, "welcome");
1219
router_add_route_record(router, config, NULL);
1320
router_config_destroy(config);
1421

1522
config = router_config_create();
16-
router_config_set_name(config, "frame#about");
17-
router_config_set_path(config, "about");
23+
router_config_set_name(config, "about");
24+
router_config_set_path(config, "/about");
1825
router_config_set_component(config, NULL, "about");
1926
router_add_route_record(router, config, NULL);
2027
router_config_destroy(config);

src/ui.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int UI_Init(void)
2222
}
2323
root = LCUIWidget_GetRoot();
2424
browser = LCUIWidget_GetById("browser");
25-
BrowserView_Active(browser, BrowserView_Load(browser, NULL));
25+
BrowserView_Active(browser, BrowserView_Load(browser, "/"));
2626
Widget_SetTitleW(root, L"Browser demo");
2727
Widget_Append(root, wrapper);
2828
Widget_Unwrap(wrapper);

src/ui/stylesheets/_variables.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ $theme-colors: map-merge((
7575

7676
$primary-text-color: #202124;
7777
$secondary-text-color: #5f6368;
78+
$border-radius: 4px;
7879
$green: #28a745;
7980

8081
$browser-tabbar-bg: $gray-300;
@@ -91,3 +92,10 @@ $border-color: $gray-200;
9192
$navbar-input-bg: $gray-200;
9293
$navbar-input-bg-hover: $gray-300;
9394
$navbar-input-bg-focus: #fff;
95+
96+
$home-card-width: 112px;
97+
$home-card-spacing: 16px;
98+
$home-card-bg-hover: $gray-100;
99+
$home-card-icon-size: 48px;
100+
$home-card-icon-bg: $gray-300;
101+
$home-card-title-line-height: 24px;

src/ui/stylesheets/_views.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
@import "views/frame";
22
@import "views/browser";
33
@import "views/welcome";
4+
@import "views/home";

src/ui/stylesheets/app.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
@import "components";
33
@import "views";
44

5+
.text-pink {
6+
color: $pink;
7+
}
8+
59
textview, a {
610
color: $primary-text-color;
711
}
Lines changed: 29 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,38 @@
11
.v-home {
2-
.nav-tabs {
3-
border-bottom: 0;
4-
padding-top: 10px;
5-
margin-bottom: 20px;
6-
background-color: #f8f9fa;
72

8-
.nav-item {
9-
z-index: 1;
10-
position: relative;
11-
}
12-
.nav-link {
13-
color: #007bff;
14-
15-
&:hover {
16-
border-top-color: #e9ecef;
17-
border-right-color: #e9ecef;
18-
border-bottom-color: #dee2e6;
19-
border-left-color: #e9ecef;
20-
}
21-
&.active {
22-
color: $primary-text-color;
23-
border-top-color: #dee2e6;
24-
border-right-color: #dee2e6;
25-
border-bottom-color: #fff;
26-
border-left-color: #dee2e6;
27-
}
28-
}
29-
}
30-
31-
.bav-tabs-bottom {
32-
border-bottom: 1px solid #dee2e6;
33-
}
3+
}
344

35-
.nav-item {
36-
display: inline-block;
37-
}
5+
.v-home__card-icon {
6+
display: block;
7+
width: $home-card-icon-size;
8+
height: $home-card-icon-size;
9+
border-radius: $home-card-icon-size / 2;
10+
background-color: $home-card-icon-bg;
11+
line-height: $home-card-icon-size;
12+
font-size: $home-card-icon-size / 2;
13+
text-align: center;
14+
margin: 0 auto $home-card-spacing auto;
15+
}
3816

39-
.tab-pane {
40-
display: none;
17+
.v-home__card-title {
18+
display: block;
19+
text-align: center;
20+
line-height: $home-card-title-line-height;
21+
}
4122

42-
&.active {
43-
display: block;
44-
}
45-
}
23+
.v-home__card {
24+
width: $home-card-width;
25+
padding-top: $home-card-spacing;
26+
margin-bottom: $home-card-spacing;
27+
display: inline-block;
28+
border-radius: $border-radius;
4629

47-
.about-container {
48-
width: 100%;
49-
max-width: 680px;
50-
margin: 15px auto;
30+
&:hover {
31+
background-color: $home-card-bg-hover;
5132
}
52-
.input-group {
53-
padding: 5px;
54-
margin: -5px -5px 5px -5px;
33+
}
5534

56-
textview {
57-
display: block;
58-
margin-bottom: 10px;
59-
}
60-
.feedback {
61-
color: $green;
62-
font-size: 12px;
63-
margin-top: 5px;
64-
}
65-
}
35+
.v-home__cards {
36+
padding-top: 16px;
37+
vertical-align: middle;
6638
}

src/ui/views.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
#include "views/frame.h"
55
#include "views/browser.h"
66
#include "views/welcome.h"
7+
#include "views/home.h"
78

89
void UI_InitViews(void)
910
{
11+
UI_InitHomeView();
1012
UI_InitWelcomeView();
1113
UI_InitBrowserView();
1214
UI_InitFrameView();

0 commit comments

Comments
 (0)