Skip to content

Commit 63d889b

Browse files
committed
hamburger
1 parent 02dba87 commit 63d889b

File tree

6 files changed

+47
-3
lines changed

6 files changed

+47
-3
lines changed

src/Tqdev/PhpCrudUi/Controller/RecordController.php

+7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class RecordController
1818
public function __construct(Router $router, Responder $responder, RecordService $service)
1919
{
2020
$router->register('GET', '/', array($this, 'home'));
21+
$router->register('GET', '/menu', array($this, 'menu'));
2122
$router->register('GET', '/*/create', array($this, 'createForm'));
2223
$router->register('POST', '/*/create', array($this, 'create'));
2324
$router->register('GET', '/*/read/*', array($this, 'read'));
@@ -39,6 +40,12 @@ public function home(ServerRequestInterface $request): ResponseInterface
3940
return $this->responder->success($result);
4041
}
4142

43+
public function menu(ServerRequestInterface $request): ResponseInterface
44+
{
45+
$result = $this->service->menu();
46+
return $this->responder->success($result);
47+
}
48+
4249
public function createForm(ServerRequestInterface $request): ResponseInterface
4350
{
4451
$table = RequestUtils::getPathSegment($request, 1);

src/Tqdev/PhpCrudUi/Record/RecordService.php

+5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public function home(): TemplateDocument
4848
return new TemplateDocument('layouts/default', 'record/home', array());
4949
}
5050

51+
public function menu(): TemplateDocument
52+
{
53+
return new TemplateDocument('layouts/menu', 'record/menu', array());
54+
}
55+
5156
public function createForm(string $table, string $action): TemplateDocument
5257
{
5358
$types = $this->definition->getTypes($table, $action);

templates/layouts/default.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
<!--<link rel="stylesheet" type="text/css" href="{{base}}/css/music.css">-->
99
</head>
1010

11-
<body>
11+
<body class="{{table}}">
1212
<div class="content">
1313
<div class="navigation">
1414
<a href="{{base}}/" class="title"><span>{{info.title}}</span>{{info.x-subtitle}}</a>
15-
<a class="hamburger" href="{{base}}/"></a>
15+
<a class="hamburger" href="{{base}}/menu" title="Close menu"><span></span><span></span><span></span></a>
1616
</div>
1717
<div class="body">
1818
{{content}}

templates/layouts/menu.html

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<title>{{info.title}}</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<link rel="stylesheet" type="text/css" href="{{base}}/css/style.css">
8+
<!--<link rel="stylesheet" type="text/css" href="{{base}}/css/music.css">-->
9+
</head>
10+
11+
<body class="{{table}}">
12+
<div class="content">
13+
<div class="navigation">
14+
<a href="{{base}}/" class="title"><span>{{info.title}}</span>{{info.x-subtitle}}</a>
15+
<a class="hamburger close" href="javascript:window.history.go(-1);"
16+
title="Open menu"><span></span><span></span></a>
17+
</div>
18+
<div class="body">
19+
{{content}}
20+
</div>
21+
</div>
22+
</body>
23+
24+
</html>

templates/record/menu.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<br />
2+
<ul class="home">
3+
{{for:item:menu}}
4+
<li>
5+
<a href="{{base}}/{{item}}/list">{{item|humanize}}</a>
6+
</li>
7+
{{endfor}}
8+
</ul>

webroot/css/style.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ body {font-size: 1rem; line-height: 1.4;}
1616
.title {padding: 0.5rem 2rem; color: black; text-decoration: none;}
1717
.title span {font-weight: bold; display: block;}
1818
.body {padding: 6rem 2rem; flex-grow: 1; padding-bottom: 10rem;}
19-
.hamburger {padding: 0 1rem 0.5rem; margin: 0.3rem 1rem; display: inline-block; text-decoration: none; color: black; font-size: 2.25rem; line-height: 1.2; transform: scaleX(1.5);}
19+
.hamburger {padding: 1rem; margin: 0.3rem 1rem; display: inline-block; text-decoration: none; color: black; font-size: 2.25rem; line-height: 1.2; transform: scaleX(1.5);}
2020

2121
th.selected::after {content: " ▾";}
2222

0 commit comments

Comments
 (0)