<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
$serveCss = filter_input(INPUT_GET, 'serve_css');
if (false === empty($serveCss)) {
require_once __DIR__ . '/class.CssGenerator.php';
require_once __DIR__ . '/class.CssRule.php';
$css = new CssGenerator();
$css->defineIdRule('app') // #app -> defines rule with ID as selector and "app" as selector value
->set('width', '900px') // #app -> sets property width of #app
->set('margin', '0 auto') // #app -> sets property margin of #app
->defineClassSubRule('container') // #app .container -> creates CLASS rule as rule inside #app
->set('padding', '100px') // #app .container -> sets property padding of #app .container
->set('color', 'red') // #app .container -> sets property color of #app .container
->defineClassRule('small') // #app .container.small -> creates CLASS rule that is additional class of .container
->set('width', '20px') // #app .container.small -> sets property width of #app .container.small
->set('color', 'purple') // #app .container.small -> sets property color of #app .container.small
->getParent() // #app .container -> moves pointer to first parent
->defineClassChildRule('small') // #app .container > .small -> defines DIRECT CHILD rule to #app .container
->set('color', 'blue') // #app .container > .small -> sets property color of #app .container > .small
->getParent('app') // #app -> moves pointer to first parent with identifier value "app"
->set('background-color', 'silver'); // #app -> sets property background-color of #app
$css->serve(); // Echoes CSS source and sets header to Content-Type: text/css
return;
}
?>
<html>
<head>
<title>CSS Generator</title>
<link rel="stylesheet" href="index.php?serve_css=true" />
</head>
<body>
<div id="app">
<div>
<div class="container">
<div class="small">
.container > .small
</div>
.container
</div>
</div>
<div class="container small">
.container.small
</div>
</div>
</body>
</html>
|