Difference between revisions of "Dn-css-2"

From EncyclopAtys

Jump to: navigation, search
m (β†’β€Žmy approach)
 
(2 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
===Paragraph===
 
===Paragraph===
 
Biggest problem I see here horizontal line. Not line but its color. If we would use standard wiki markup we can not change its color. It appears at highest level.. Then it is there no more:
 
Biggest problem I see here horizontal line. Not line but its color. If we would use standard wiki markup we can not change its color. It appears at highest level.. Then it is there no more:
βˆ’
<syntaxhighlight>
+
<syntaxhighlight lang='css'>
 
PROVIDE EXAMPLES
 
PROVIDE EXAMPLES
βˆ’
</syntaxhighlight>
+
</syntaxhighlight lang='css'>
  
 
=1=
 
=1=
Line 25: Line 25:
 
===Table===
 
===Table===
 
No HTML table here, only CSS! Tables are used for grid-ish layout. On our wiki is it not often used but there are some features were it is used as 'mark plates': [[Template:Homin|Template: Homin]]
 
No HTML table here, only CSS! Tables are used for grid-ish layout. On our wiki is it not often used but there are some features were it is used as 'mark plates': [[Template:Homin|Template: Homin]]
βˆ’
<syntaxhighlight>
+
<syntaxhighlight lang='css'>
 
PROVIDE EXAMPLES
 
PROVIDE EXAMPLES
 
</syntaxhighlight>
 
</syntaxhighlight>
  
βˆ’
===Text box===
 
βˆ’
A text box with an border.
 
βˆ’
Here I would like to propose my version of [[Template:ContentBox]]. My goal is to simplify the code, make it more readable.
 
βˆ’
lets start with:
 
βˆ’
====The original====
 
βˆ’
<syntaxhighlight>
 
βˆ’
<includeonly>
 
βˆ’
<div style="
 
βˆ’
position:relative; left:4px; right: 4px; top:2px;
 
βˆ’
border:1px solid #{{ColorAtys|group={{{palette}}}}};
 
βˆ’
height:25px;
 
βˆ’
background: #{{ColorAtys|type=bg|group={{{palette}}}}};
 
βˆ’
background: linear-gradient(to right, #{{ColorAtys|type=bg|group={{{palette}}}}}, #{{ColorAtys|type=light|group={{{palette}}}}});
 
βˆ’
border: thin solid #{{ColorAtys|type=bg|group={{{palette}}}}};
 
βˆ’
border-bottom: thin outset #{{ColorAtys|type=dark|group={{{palette}}}}};
 
βˆ’
color: #{{ColorAtys|type=fg|group={{{palette}}}}};
 
βˆ’
font-weight: bold;
 
βˆ’
font-size: 1.25em;
 
βˆ’
text-align: center;
 
βˆ’
">
 
βˆ’
<div style="position:absolute; left:5px; top:-5px;">[[File:{{{image}}}|38px|link=]]</div>
 
βˆ’
<div style="position:absolute; left:40px; top:2px; right:0px"><h2 {{#if:{{{id|}}} | id="{{{id}}}Head"| }} style="margin:0; border-bottom:0; font-size:120%; font-weight:bold; text-align:left; padding:.15em .4em;
 
βˆ’
text-shadow: #{{ColorAtys|type=light|group={{{palette}}}}} -0.1em -0.1em 0.2em, #{{ColorAtys|type=dark|group={{{palette}}}}} 0.1em 0.1em 0.2em;">{{{title}}}</h2></div></div>
 
βˆ’
|-
 
βˆ’
|<div {{#if:{{{id|}}}|id="{{{id}}}"|}} style="padding-left:10px; padding-bottom:5px; padding-top:0px;">
 
βˆ’
{{{content}}}
 
βˆ’
{{#if:{{{link|}}}|<div align="right">{{{link}}}</div>|}}
 
βˆ’
</div>
 
βˆ’
|-
 
βˆ’
</includeonly>
 
βˆ’
</syntaxhighlight>
 
βˆ’
====my approach====
 
βˆ’
Before I propose anything... I will like to share my way of approaching such template. Here I will try to present all steps I took before I get to final result.
 
βˆ’
First step is to understand why was this template created. This one is easy, as template documentation explains it all: we want to have a box with colored ribbon with an icon, title and content. Template call is nicely done as well, and it is crystal clear. We will have to work with 6 parameters (this is more like pseudo code, a working and tested version of the code will be in dnContentBox-template): <syntaxhighlight>
 
βˆ’
|title=
 
βˆ’
|id=
 
βˆ’
|image=
 
βˆ’
|content=
 
βˆ’
|link=
 
βˆ’
|palette=
 
βˆ’
</syntaxhighlight>
 
βˆ’
Lets try to read template code... Eheum... Lets don't. Lets dissect it, that can work:
 
βˆ’
<syntaxhighlight>
 
βˆ’
<includeonly>
 
βˆ’
<div style="
 
βˆ’
position:relative; left:4px; right: 4px; top:2px;
 
βˆ’
border:1px solid #{{ColorAtys|group={{{palette}}}}};
 
βˆ’
height:25px;
 
βˆ’
background: #{{ColorAtys|type=bg|group={{{palette}}}}};
 
βˆ’
background: linear-gradient(to right, #{{ColorAtys|type=bg|group={{{palette}}}}}, #{{ColorAtys|type=light|group={{{palette}}}}});
 
βˆ’
border: thin solid #{{ColorAtys|type=bg|group={{{palette}}}}};
 
βˆ’
border-bottom: thin outset #{{ColorAtys|type=dark|group={{{palette}}}}};
 
βˆ’
color: #{{ColorAtys|type=fg|group={{{palette}}}}};
 
βˆ’
font-weight: bold;
 
βˆ’
font-size: 1.25em;
 
βˆ’
text-align: center;
 
βˆ’
">
 
βˆ’
</syntaxhighlight>
 
βˆ’
Lets pull out stuff that looks suspicious:
 
βˆ’
<syntaxhighlight>
 
βˆ’
border:1px solid #{{ColorAtys|group={{{palette}}}}};
 
βˆ’
</syntaxhighlight>
 
βˆ’
Ok, we are setting color to border here... '''''<nowiki>#{{ColorAtys|group={{{palette}}}}}</nowiki>'''''... Altho idea is good, this looks a bit too complicated for me, plus putting '''''<nowiki>#</nowiki>''''' in front of a template, I am not sure that that's the best practice... as hash sign here is a integral part of the hex-color. Maintain colors is a discussion on it self... Lets just assume that Colors can be defined with two parameters: pallete and function. So same line in my code would look like:
 
βˆ’
<syntaxhighlight>
 
βˆ’
border:1px solid {{:{{{Pallete}}}{{varColorsBorder}}}};
 
βˆ’
</syntaxhighlight>
 
βˆ’
I would apply same logic to rest of that <div> and try to bring 'stuff' together, with this result:
 
βˆ’
<syntaxhighlight>
 
βˆ’
position:relative; left:4px; right: 4px; top:2px; height:25px;
 
βˆ’
border:1px solid {{:{{{Pallete}}}{{varColorsBorder}}}};
 
βˆ’
background: {{:{{{Pallete}}}{{varColorsBackGround}}}};
 
βˆ’
background: linear-gradient(to right, {{:{{{Pallete}}}{{varColorsLight}}}}, {{:{{{Pallete}}}{{varColorsDark}}}});
 
βˆ’
border: thin solid {{:{{{Pallete}}}{{varColorsBorder}}}};
 
βˆ’
border-bottom: thin outset {{:{{{Pallete}}}{{varColorsDark}}}};
 
βˆ’
color: {{:{{{Pallete}}}{{varColorsTextColor}}}};
 
βˆ’
font-weight: bold;
 
βˆ’
font-size: 1.25em;
 
βˆ’
text-align: center;
 
βˆ’
</syntaxhighlight>
 
βˆ’
and as it bothers me to look at it while reading rest of code:
 
βˆ’
<syntaxhighlight>
 
βˆ’
<div style={{:dnContentBox/css|Pallete={{{Pallete}}}}}">
 
βˆ’
<div style="position:absolute; left:5px; top:-5px;">[[File:{{{image}}}|38px|link=]]</div>
 
βˆ’
<div style="position:absolute; left:40px; top:2px; right:0px"><h2 {{#if:{{{id|}}} | id="{{{id}}}Head"| }} style="margin:0; border-bottom:0; font-size:120%; font-weight:bold; text-align:left; padding:.15em .4em;
 
βˆ’
text-shadow: #{{ColorAtys|type=light|group={{{palette}}}}} -0.1em -0.1em 0.2em, #{{ColorAtys|type=dark|group={{{palette}}}}} 0.1em 0.1em 0.2em;">{{{title}}}</h2></div></div>
 
βˆ’
|-
 
βˆ’
|<div {{#if:{{{id|}}}|id="{{{id}}}"|}} style="padding-left:10px; padding-bottom:5px; padding-top:0px;">
 
βˆ’
{{{content}}}
 
βˆ’
{{#if:{{{link|}}}|<div align="right">{{{link}}}</div>|}}
 
βˆ’
</div>
 
βˆ’
|-
 
βˆ’
</includeonly></syntaxhighlight>
 
βˆ’
Not gonna go into detail here.. but rest needs the same, imo:
 
βˆ’
<syntaxhighlight>
 
βˆ’
<div style={{:dnContentBox/css|Pallete={{{Pallete}}}}}">
 
βˆ’
{{:dnContentBox/image|Image={{{Image}}}|Pallete={{{Pallete}}}}}
 
βˆ’
{{:dnContentBox/title|Title={{{Title}}}|Pallete={{{Pallete}}}}}
 
βˆ’
{{:dnContentBox/content|Content={{{Content}}}|Pallete={{{Pallete}}}}}
 
βˆ’
</div>
 
βˆ’
</syntaxhighlight>
 
βˆ’
Ta Da!!! I can read that :-)
 
βˆ’
 
βˆ’
 
βˆ’
 
βˆ’
[[dn-text-box]]
 
  
βˆ’
===Article===
 
βˆ’
<syntaxhighlight>
 
βˆ’
PROVIDE EXAMPLES
 
βˆ’
</syntaxhighlight>
 
βˆ’
===Navigation===
 
βˆ’
<syntaxhighlight>
 
βˆ’
PROVIDE EXAMPLES
 
βˆ’
</syntaxhighlight>
 
βˆ’
===Page box===
 
βˆ’
<syntaxhighlight>
 
βˆ’
PROVIDE EXAMPLES
 
βˆ’
</syntaxhighlight>
 
βˆ’
==Layouts==
 
βˆ’
===Main Page===
 
βˆ’
This page should be attractive enough to invite people to read its content as informative as possible.
 
βˆ’
* Proposal A
 
βˆ’
<syntaxhighlight>
 
βˆ’
PROVIDE EXAMPLES
 
βˆ’
</syntaxhighlight>
 
βˆ’
* Proposal B
 
βˆ’
<syntaxhighlight>
 
βˆ’
PROVIDE EXAMPLES
 
βˆ’
</syntaxhighlight>
 
βˆ’
----<br/>
 
 
{{:dn-menu-buttons
 
{{:dn-menu-buttons
 
|CellCount=2
 
|CellCount=2

Latest revision as of 16:04, 23 November 2021

Page elements

A nice concept of separated text in a box! Lets make it a bit more modern:

Paragraph

Biggest problem I see here horizontal line. Not line but its color. If we would use standard wiki markup we can not change its color. It appears at highest level.. Then it is there no more:

PROVIDE EXAMPLES
</syntaxhighlight lang='css'>

=1=
111111
==2==
2222222
===3===
3333333
----

That's why I would consider using an alternative approach.
====4====
{{:dn-paragraph
|Header=Some HEADER
|Content=Some text
|Pallete=RT
}}

===Table===
No HTML table here, only CSS! Tables are used for grid-ish layout. On our wiki is it not often used but there are some features were it is used as 'mark plates': [[Template:Homin|Template: Homin]]
<syntaxhighlight lang='css'>
PROVIDE EXAMPLES