Skip to content

Commit 8abaf32

Browse files
committed
Multiple updates
1 parent 49a7c9c commit 8abaf32

32 files changed

+196
-143
lines changed

README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
# Silverstripe Style Guide
22

3-
Creates a page listing common elements to developers style.
4-
3+
Creates a page listing common elements to help developers style.
4+
55
## Installation
6-
7-
```
8-
composer require plato-creative/silverstripe-styleguide 1.*
6+
7+
Composer is the recommended way of installing SilverStripe modules.
98
```
10-
11-
Run Dev Build
12-
13-
The styles will be available at /styleguide
9+
composer require plato-creative/silverstripe-styleguide
10+
```
11+
12+
Flush
13+
14+
## Requirements
15+
16+
- silverstripe/framework 3.*
17+
- silverstripe/cms 3.*
18+
- joshtronic/php-loremipsum 3.*

_config/routes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Name: styleguideroutes
33
---
44
Director:
55
rules:
6-
'styleguide': 'StyleGuide'
6+
styleguide: 'StyleGuideController'

code/controllers/StyleGuide.php

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?php
2+
3+
/**
4+
* StyleGuideController
5+
* @package silverstripe
6+
* @subpackage silverstripe-styleguide
7+
*/
8+
class StyleGuideController extends Page_Controller
9+
{
10+
private static $title = 'Style Guide';
11+
12+
private static $show_contents = true;
13+
14+
/**
15+
* Defines methods that can be called directly
16+
* @var array
17+
*/
18+
private static $allowed_actions = array(
19+
'index'
20+
);
21+
22+
public function index()
23+
{
24+
if(Director::isLive() && !Permission::check('CMS_ACCESS_CMSMain')) {
25+
return Security::permissionFailure($this);
26+
}
27+
28+
Requirements::css(STYLEGUIDE_DIR . '/css/styleguide.css');
29+
30+
return $this->renderWith(array(
31+
__CLASS__,
32+
'Page'
33+
));
34+
}
35+
36+
public function getStyles()
37+
{
38+
$config = SiteConfig::current_site_config();
39+
$theme = $config->Theme;
40+
if ($theme) {
41+
Config::inst()->update('SSViewer', 'theme_enabled', true);
42+
Config::inst()->update('SSViewer', 'theme', $theme);
43+
}
44+
45+
$manifest = SS_TemplateLoader::instance()->getManifest();
46+
47+
$templates = ArrayList::create();
48+
49+
foreach($manifest->getTemplates() as $templateName => $templateInfo) {
50+
$themeexists = $theme && isset($templateInfo['themes'][$theme]) && isset($templateInfo['themes'][$theme]['Styles']);
51+
52+
if ((isset($templateInfo['Styles']) || $themeexists) && !isset($templates[$templateName])) {
53+
$templates->push(ArrayData::create(array(
54+
'Anchor' => $this->Link . '#' . trim($templateName),
55+
'AnchorAttr' => 'id="' . trim($templateName) .'"',
56+
'Name' => trim(str_replace('_', ' ',$templateName)),
57+
'Layout' => $this->renderWith(array($templateName))
58+
)));
59+
}
60+
}
61+
62+
return $templates;
63+
}
64+
65+
public function getShowContents()
66+
{
67+
return $this->config()->get('show_contents');
68+
}
69+
70+
public function getLink()
71+
{
72+
return Controller::join_links('styleguide');
73+
}
74+
75+
public function getTitle()
76+
{
77+
return $this->config()->get('title');
78+
}
79+
80+
public function getMenuTitle()
81+
{
82+
return $this->Title;
83+
}
84+
85+
public function Word()
86+
{
87+
$lorem = new joshtronic\LoremIpsum();
88+
return $lorem->word();
89+
}
90+
91+
public function Words($count = 5)
92+
{
93+
$lorem = new joshtronic\LoremIpsum();
94+
return $lorem->words($count);
95+
}
96+
97+
public function Sentence()
98+
{
99+
$lorem = new joshtronic\LoremIpsum();
100+
return $lorem->sentence();
101+
}
102+
103+
public function Sentences($count = 5)
104+
{
105+
$lorem = new joshtronic\LoremIpsum();
106+
return $lorem->sentences($count);
107+
}
108+
109+
public function Paragraph()
110+
{
111+
$lorem = new joshtronic\LoremIpsum();
112+
return $lorem->paragraph();
113+
}
114+
115+
public function Paragraphs($count = 5)
116+
{
117+
$lorem = new joshtronic\LoremIpsum();
118+
return $lorem->paragraphs($count);
119+
}
120+
}

composer.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@
44
"type": "silverstripe-module",
55
"keywords": ["silverstripe", "style", "guide", "development"],
66
"license": "BSD-3-Clause",
7-
"authors": [
8-
{
9-
"name": "Gorrie Coe",
10-
"email": "gorriecoe@gmail.com"
11-
}
12-
],
137
"require":
148
{
15-
"silverstripe/framework": "3.*",
16-
"silverstripe/cms": "3.*"
9+
"silverstripe/framework": "^3.5",
10+
"silverstripe/cms": "^3.5",
11+
"joshtronic/php-loremipsum": "^1.0"
1712
},
1813
"extra": {
1914
"installer-name": "styleguide"

css/styleguide.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/styleguide.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scss/styleguide.scss

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,18 @@ $grey: #808080;
22
$dark-grey: #222;
33
$white: #fff;
44
$font-family: "HelveticaNeue","Helvetica","Arial",sans-serif;
5+
$font-size: 14px;
56

67
.styleGuideMaster{
78
border: 1px solid $grey;
89
padding: 1em;
9-
position: fixed;
10-
top: 0;
11-
right: 0;
12-
bottom: 0;
13-
left: 0;
14-
z-index: 9999;
15-
background-color: $white;
1610
overflow: auto;
11+
position: relative;
1712
}
1813

19-
.styleGuideNav{
20-
position: fixed;
21-
top: 0;
22-
bottom: 0;
23-
left: 0;
24-
width: 20%;
14+
.styleGuideContents{
2515
margin: 0;
26-
background: $dark-grey none repeat scroll 0% 0%;
27-
color: $white;
28-
font-family: $font-family;
16+
font-family: $font-family !important;
2917
text-transform: uppercase;
3018
overflow: auto;
3119
ul{
@@ -39,26 +27,27 @@ $font-family: "HelveticaNeue","Helvetica","Arial",sans-serif;
3927
display: block;
4028
}
4129
a{
42-
font-size: 14px!important;
43-
color: $grey;
30+
font-size: $font-size !important;
31+
color: $grey !important;
4432
text-decoration: none;
4533
display: block;
46-
line-height: 1;
47-
padding: 0.5em 1em;
34+
line-height: $font-size * 3 !important;
35+
padding: 0 1em;
4836
transition: color 0.15s ease-out 0s;
4937
cursor: pointer;
5038
&:hover,
5139
&:focus{
52-
color: $white;
53-
background: $dark-grey none repeat scroll 0% 0%;
40+
color: $white !important;
41+
background: $dark-grey none repeat scroll 0% 0% !important;
5442
}
5543
}
5644
}
45+
5746
.styleGuideGroups{
58-
position: absolute;
5947
left: 20%;
6048
padding: 2em;
6149
}
50+
6251
.styleGuideGroup{
6352
clear: both;
6453
&:after{
@@ -67,12 +56,13 @@ $font-family: "HelveticaNeue","Helvetica","Arial",sans-serif;
6756
clear: both;
6857
}
6958
}
59+
7060
.styleGuideTitle{
7161
margin: 2em 0px;
72-
font-family: $font-family;
73-
font-size: 14px!important;
62+
font-family: $font-family !important;
63+
font-size: $font-size !important;
7464
text-transform: uppercase;
7565
font-weight: normal;
7666
padding: 1em 0px;
77-
border-bottom: 1px solid $grey;
67+
border-bottom: 1px solid $grey !important;
7868
}

templates/Layout/StyleGuide.ss

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<div class="styleGuideMaster">
2+
<% if Styles %>
3+
<h1>{$Title}</h1>
4+
<% if ShowContents %>
5+
<div class="styleGuideContents">
6+
<ul>
7+
<% loop Styles %>
8+
<li>
9+
<a href="{$Anchor}">
10+
{$Name}
11+
</a>
12+
</li>
13+
<% end_loop %>
14+
</ul>
15+
</div>
16+
<% end_if %>
17+
18+
<div class="styleGuideGroups">
19+
<% loop Styles %>
20+
<div {$AnchorAttr} class="styleGuideGroup">
21+
<p class="styleGuideTitle">{$Name}</p>
22+
<div class="styleGuideLayout">
23+
{$Layout}
24+
</div>
25+
</div>
26+
<% end_loop %>
27+
</div>
28+
<% else %>
29+
<p>
30+
No styles found
31+
</p>
32+
<% end_if %>
33+
</div>

0 commit comments

Comments
 (0)