1 module uim.css; 2 3 import std.string; 4 5 public import uim.core; 6 public import uim.oop; 7 /* public import uim.json; 8 public import uim.json; */ 9 10 // uim.css packages 11 public import uim.css.classes; 12 public import uim.css.helpers; 13 14 // uim.css modules 15 public import uim.css.containers; 16 public import uim.css.container; 17 public import uim.css.declaration; 18 public import uim.css.obj; 19 public import uim.css.rule; 20 public import uim.css.rules; 21 public import uim.css.media; 22 23 /* class DCSSx : DCSSRules { 24 this() { super(); } 25 this(DCSSObj[] someRules) { this(); } 26 27 override protected void _init() { super._init; } 28 29 string[] _properties; 30 // CSS background properties 31 struct Background { 32 DCSS css; 33 this(DCSS owner) { 34 css = owner; 35 } 36 37 auto color(string color) { 38 css.backgroundColor(color); 39 return this; 40 } 41 42 auto image(string image) { 43 css.backgroundImage(image); 44 return this; 45 } 46 auto repeat(string repeat) { 47 css.backgroundRepeat(repeat); 48 return this; 49 } 50 auto attachment(string attachment) { 51 css.backgroundAttachment(attachment); 52 return this; 53 } 54 auto position(string position) { 55 css.backgroundPosition(position); 56 return this; 57 } 58 } 59 auto background() { 60 return Background(this); 61 } 62 auto backgroundColor(string color) { 63 _properties ~= "background-color: "~color; 64 return this; 65 } 66 auto backgroundImage(string image) { 67 _properties ~= "background-image: "~image; 68 return this; 69 } 70 auto backgroundRepeat(string repeat) { 71 _properties ~= "background-repeat: "~repeat; 72 return this; 73 } 74 auto backgroundAttachment(string attachment) { 75 _properties ~= "background-attachment: "~attachment; 76 return this; 77 } 78 auto backgroundPosition(string position) { 79 _properties ~= "background-position: "~position; 80 return this; 81 } 82 83 // CSS Border properties 84 struct Border { 85 DCSS css; 86 this(DCSS owner) { 87 css = owner; 88 } 89 auto color(string color) { 90 css.borderColor(color); 91 return this; 92 } 93 auto style(string style) { 94 css.borderStyle(style); 95 return this; 96 } 97 auto topStyle(string style) { 98 css.borderTopStyle(style); 99 return this; 100 } 101 auto rightStyle(string style) { 102 css.borderRightStyle(style); 103 return this; 104 } 105 auto bottomStyle(string style) { 106 css.borderBottomStyle(style); 107 return this; 108 } 109 auto leftStyle(string style) { 110 css.borderLeftStyle(style); 111 return this; 112 } 113 auto width(string width) { 114 css.borderWidth(width); 115 return this; 116 } 117 } 118 auto border() { 119 return Border(this); 120 } 121 auto borderColor(string color) { 122 _properties ~= "border-color: "~color; 123 return this; 124 } 125 auto borderStyle(string style) { 126 _properties ~= "border-style: "~style; 127 return this; 128 } 129 auto borderTopStyle(string style) { 130 _properties ~= "border-style: "~style; 131 return this; 132 } 133 auto borderRightStyle(string style) { 134 _properties ~= "border-style: "~style; 135 return this; 136 } 137 auto borderBottomStyle(string style) { 138 _properties ~= "border-style: "~style; 139 return this; 140 } 141 auto borderLeftStyle(string style) { 142 _properties ~= "border-style: "~style; 143 return this; 144 } 145 auto borderWidth(string width) { 146 _properties ~= "border-width: "~width; 147 return this; 148 } 149 auto border(string properties) { 150 _properties ~= "border: "~properties; 151 return this; 152 } 153 154 // CSS Text properties 155 struct Text { 156 DCSS css; 157 this(DCSS owner) { css = owner; } 158 auto color(string color) { 159 css.color(color); 160 return this; 161 } 162 auto align_(string val) { 163 css.textAlign(val); 164 return this; 165 } 166 auto decoration(string decoration) { // values: overline, line-through, underline 167 css.textDecoration(decoration); 168 return this; 169 } 170 auto textTransform(string transform) { // values: uppercase, lowercase, capitalize 171 css.textTransform(transform); 172 return this; 173 } 174 auto indent(string indent) { 175 css.textIndent(indent); 176 return this; 177 } 178 auto letterSpacing(string spacing) { 179 css.letterSpacing(spacing); 180 return this; 181 } 182 auto lineHeight(string height) { 183 css.lineHeight(height); 184 return this; 185 } 186 auto direction(string dir) { 187 css.direction(dir); 188 return this; 189 } 190 auto wordSpacing(string spacing) { 191 css.wordSpacing(spacing); 192 return this; 193 } 194 auto shadow(string shadow) { 195 css.textShadow(shadow); 196 return this; 197 } 198 } 199 auto text() { 200 return Text(this); 201 } 202 203 auto color(string color) { 204 _properties ~= "color: "~color; 205 return this; 206 } 207 auto textAlign(string val) { 208 _properties ~= "text-align: "~val; 209 return this; 210 } 211 auto textDecoration(string decoration) { // values: overline, line-through, underline 212 _properties ~= "text-decoration: "~decoration; 213 return this; 214 } 215 auto textTransform(string transform) { // values: uppercase, lowercase, capitalize 216 _properties ~= "text-transform: "~transform; 217 return this; 218 } 219 auto textIndent(string indent) { 220 _properties ~= "text-indent: "~indent; 221 return this; 222 } 223 auto letterSpacing(string spacing) { 224 _properties ~= "letter-spacing: "~spacing; 225 return this; 226 } 227 auto lineHeight(T)(T height) { 228 _properties ~= "line-height: %s".format(height); 229 return this; 230 } 231 auto lineHeight(string height) { 232 _properties ~= "line-height: "~height; 233 return this; 234 } 235 auto direction(string dir) { 236 _properties ~= "direction: "~dir; 237 return this; 238 } 239 auto wordSpacing(string spacing) { 240 _properties ~= "word-spacing: "~spacing; 241 return this; 242 } 243 auto textShadow(string shadow) { 244 _properties ~= "text-shadow: "~shadow; 245 return this; 246 } 247 override string toString() { 248 string result = _properties.join(";"); 249 _properties = []; 250 return result; 251 } 252 } 253 //auto CSS() { return new DCSS(); } 254 //auto CSS(CSSObj[] someRules) { return new DCSS(someRules); } 255 256 enum CS3Colors : string { 257 Red = "red", 258 Green = "green", 259 Blue = "blue", 260 Orange = "orange", 261 Yellow = "yellow", 262 Cyan = "cyan" 263 } 264 265 unittest { 266 writeln("Testing ", __MODULE__); 267 // 268 // auto css = CSSRuleSet; 269 // 270 // auto media = CSSMedia("screen and (min-width: 480px)"); 271 // media.rules = media.rules ~ CSSRule("body", ["background-color": "lightgreen"]); 272 // css.add(media); 273 // 274 // media = CSSMedia("screen and (min-width: 480px)"); 275 // media.rules = media.rules ~ CSSRule(".h1", ["background-color": "lightgreen"]); 276 // css.add(media); 277 // 278 // css.add(CSSRule("#tt", ["background-color": "lightgreen"])); 279 // writeln(css); 280 281 // auto css3 = CSS 282 // .media("screen and (min-width: 480px)", [ 283 // CSSRule("img", ["background-color": "lightgreen"]), 284 // CSSRule("xxs", ["background-color": "lightgreen"]) 285 // ]) 286 // .media("screen and (min-width: 490px)", [CSSRule("img", ["background-color": "lightgreen"])]); 287 288 289 /* string css_text = CSS 290 .background 291 .image("xxx") 292 .color("lightgreen"); 293 * / 294 } 295 296 unittest { 297 } */