CSS And Javascript example
<?php
namespace CherrycakeApp\CssAndJavascriptGuide;
class CssAndJavascriptGuide extends \Cherrycake\Module {
protected $dependentCoreModules = [
"HtmlDocument"
];
public static function mapActions() {
global $e;
$e->Actions->mapAction(
"cssAndJavascriptBasicExample",
new \Cherrycake\Actions\ActionHtml([
"moduleType" => \Cherrycake\ACTION_MODULE_TYPE_APP,
"moduleName" => "CssAndJavascriptGuide",
"methodName" => "basicExample",
"request" => new \Cherrycake\Actions\Request([
"pathComponents" => [
new \Cherrycake\Actions\RequestPathComponent([
"type" => \Cherrycake\REQUEST_PATH_COMPONENT_TYPE_FIXED,
"string" => "css-and-javascript-guide"
]),
new \Cherrycake\Actions\RequestPathComponent([
"type" => \Cherrycake\REQUEST_PATH_COMPONENT_TYPE_FIXED,
"string" => "basic-example"
])
]
])
])
);
}
function basicExample() {
global $e;
$e->Output->setResponse(new \Cherrycake\Actions\ResponseTextHtml([
"code" => \Cherrycake\Output\RESPONSE_OK,
"payload" =>
$e->HtmlDocument->header().
"This page has some CSS styling, the file base.css has been linked in the <u>Css.config.php</u> configuration file.".
$e->HtmlDocument->footer()
]));
}
}
<?php
namespace Cherrycake;
global $e;
$CssConfig = [
"isMinify" => true,
"sets" => [
"main" => [
"directory" => APP_DIR."/css",
"files" => [
"base.css"
]
]
]
];
body {
background: #f0f0f0;
font-family: Inconsolata, Courier;
font-size: 15px;
margin: 15px;
}
a {
text-decoration: none;
color: #c24;
}
a:hover {
text-decoration: underline;
}
a.button {
display: inline-block;
background: #c24;
color: #fff;
border-radius: 4px;
text-decoration: none;
padding: 0 15px;
line-height: 40px;
vertical-align: middle;
margin: .5em;
}
a.button.grey {
background: #ddd;
color: #555;
}
a.button:hover,
a.button:active {
opacity: .8;
}
u {
text-decoration: none;
background: #888;
color: #fff;
padding: 0 3px;
border-radius: 4px;
}
input.copypaste {
border: solid transparent 1px;
background: rgba(0, 0, 0, 0.05);
padding: 5px;
margin: 2px;
}
input.copypaste:focus {
border: solid rgba(0, 0, 0, 0.5) 1px;
border-radius: 5px;
outline: none;
background: rgba(0, 0, 0, 0.1);
}