Getting ready for an alpha release: WeCSS/Wess improvements

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Getting ready for an alpha release: WeCSS/Wess improvements
« Reply #15, on September 11th, 2012, 06:00 PM »
Quote
(Anyone still reading this topic...? :^^;:)
I doubt it.

There are probably two people in this topic who have any understanding of the consequences of this stuff, and one of those has only a vague understanding of it all.

There is only one way to figure this stuff out. Do it and change it if there's a problem down the line. You're discovering the problem I had, that there's so many twists and complexities to it that there's no best right answer, so go with what your gut tells you then adapt and improve if the situation requires it.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Norodo

  • Oh you Baidu, so randumb. (60 sites being indexed at once? Jeez)
  • Posts: 469

Nao

  • Dadman with a boy
  • Posts: 16,082

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
Re: Getting ready for an alpha release: WeCSS/Wess improvements
« Reply #18, on September 12th, 2012, 01:22 PM »
WeStyle! I'd personally like if with syntax/structure similar to @media queries. Something like
Code: [Select]
@if (browser: IE[6-7]) and $userhaspizza {}

Not sure how feasible that is though, never really looked into We<Whatever name you end up having>
The way it's meant to be

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Getting ready for an alpha release: WeCSS/Wess improvements
« Reply #19, on September 12th, 2012, 03:29 PM »
WeStyle? Hmm... Why not? Except that it sounds like marmoset in French, ah ah...

My current grammar for @if was close to this, but I used '==' instead of ':'. Plus -- I'd really rather use a function for browser names... I think.
I'd suggest you look into common.css and the end of index.css and sections.css (mostly), these have most of the WeCSS peculiarities really.

Anyway, it's currently working locally, but not ready for a commit.
Re: Getting ready for an alpha release: WeCSS/Wess improvements
« Reply #20, on September 12th, 2012, 06:00 PM »
My regex of the month...

Code: [Select]
~@is\s*\(\s*+("(?:[^"@]|@(?!is\s*\())*"|\'(?:[^\'@]|@(?!is\s*\())*\'|(?:[^\'",@]|@(?!is\s*\())(?:[^,@]|@(?!is\s*\())*)\s*+,\s*+("(?:[^"@]|@(?!is\s*\())*"|\'(?:[^\'@]|@(?!is\s*\())*\'|(?:[^\'",@]|@(?!is\s*\())(?:[^,@]|@(?!is\s*\())*)\s*+(?:,\s*+("(?:[^"@]|@(?!is\s*\())*"|\'(?:[^\'@]|@(?!is\s*\())*\'|(?:[^\'")@]|@(?!is\s*\())(?:[^)@]|@(?!is\s*\())*)\s*+)?\)~i

Which should allow for infinite nesting of @is tests.
Fun!
Maybe I should use (?R) instead... But I'm afraid it might be too CPU intensive :P

(And yes, right now the syntax is @is (browser, then, else)... Simplest I could do for now.)

Norodo

  • Oh you Baidu, so randumb. (60 sites being indexed at once? Jeez)
  • Posts: 469

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Getting ready for an alpha release: WeCSS/Wess improvements
« Reply #23, on November 23rd, 2012, 11:06 AM »
So... Regarding @if statements.

Right now, if you didn't follow, there are two things you can do with them:

- Test for a variable's value.

@if $my_variable <= 7
   do_this
@else
   do that
@endif

- Test for a browser. (It's also more flexible, can be done anywhere.)

@if ie[7-8], opera
  do this
@endif

Meaning "If browser is Opera or IE7 or IE8". The syntax is the same as in CSS file suffixes, e.g. "index.ie[7-8],opera.css" in the case above.

So... As usual when I'm a bit lost when resuming work on Wedge, I'm working on 'easy' stuff that I'm very familiar with, currently being the Wedge logo (yes, I've got something else in the works...) and this particular area of Wess.

These are the three additions I made to user agent tests, and I need some suggestions to help with them.

1/ Negative statements, i.e. @if (!ie[7-]) means "If browser is not IE 7 or above". (Parenthesis can be ommitted, of course.)
2/ OS, i.e. @if (win[6.1-]) meaning "if user is running Windows 7 or later".
3/ Logical AND, i.e. @if (opera, chrome && !android), meaning "if browser is Opera, or it's Chrome but not running in Android".

Pretty nice uh...?
Okay, the OS thing is due to two things.
- I've always been bugged by the fact that Wess stores some browsers per OS, like the fact that Safari Mobile's version number is actually the iOS version number because iOS doesn't allow for a different browser engine than Safari Mobile and thus any browser is locked to the OS version.
- There are some cases where a browser will behave differently in two different OSes, usually due to bugs. I like having the ability to specify browser and OS versions.

Okay, so here are my problems...

0/ First of all, with number zero... I know, 'semantics'... As if it's not 'right' to do browser sniffing. But until we're in a perfect universe where all browsers are perfectly compatible and follow standards etc etc, it's going to be a non-issue to me. People who are against browser sniffing and who say that to others have absolutely no idea how much time they're going to take away from them. IE6 being an obvious example... Wess makes it easy to add quick hacks to IE without hurting other browsers. Screw semantics here, they're just a twisted invention.

1/ I don't know what OS versions I should store... Windows is a given, iOS too (see above), Android as well. But what about the rest...? Are there any OSes, mobile or not, that are famous for requiring tweaks to one or more browsers running in them...? Because if I'm only storing Windows, iOS and Android, at least I don't have to create separate CSS files for each obscure OS like Bada or SunOS or whatever.

2/ Linux: should I store this..? If yes, a generic 'linux' entry? And what about the version number? Maybe no OS version at all, given the mess that it is? And I don't think Linux kernel versions have any influence over the browsers...

3/ Is it any actually necessary to store the OS version in the filename every time...? I was thinking of something a bit complex but that could save some space on the hard drive... Let's say we have a @if (win/windows) test in a file. Wess analyzes this, determines whether we're running Windows, and if yes, it tells the cache manager that we have a special behavior for 'windows'. Thus, the cache manager adds a 'windows-6.1' (or whatever version) keyword to the current file. Otherwise, no special keyword. At cache load time, Wess tries to load the 'windows-6.1' version. If it doesn't exist, it tries to load a version without the 'windows-6.1' keyword. Main problems is, I can already smell a really complex implementation (even if I'm up to it, it might be a failure in terms of performance or comprehensiveness in the end...)

4/ Or we could just store the 'main' version numbers, such as Windows shouldn't bother with anything below XP (5), then store only Vista versions (6) for anything above it because I'm not sure 7 or 8 have any significant differences in how they render stuff. Well, I'm mostly thinking of Vista adding things like Segoe UI Light and C fonts by default, or having support (IIRC) for Direct2D rendering in IE9, thus making it a no-brainer to use the ClearType-enabled fonts by default in a skin when instead it's probably wiser to just ommit them from the font stack in XP.

See what I mean...?

I'm just trying to make things 'right' and avoid having more cache files than necessary...

Re: negative statements, it was an annoying implementation, but it seems to be working. It adds quite a lot of lines though... AND statements were easier to add. And funnier, because I'm doing recursive calls for the AND lists. As I said -- fun. Not sure it's going to be liked widely, though... ;)

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Getting ready for an alpha release: WeCSS/Wess improvements
« Reply #25, on November 23rd, 2012, 03:30 PM »
No, no... My example was the very reason I added OS numbers: Vista adds Segoe UI Light & co. Seven adds Calibri & co. For instance I'm a big fan of Calibri but it has a x-height that's not compatible with anything else (except for a few webfonts). So I can't use the usual stack system because I can't define different sizes for each font (the CSS standard is somewhat lacking in that respect.)

This is why I devised something like this...

@if win[6.1-]
  font: 10pt Calibri, sans-serif
@else
  font: 9pt Segoe UI Light, Arial, sans-serif
@endif

See what I mean..?

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Getting ready for an alpha release: WeCSS/Wess improvements
« Reply #27, on November 23rd, 2012, 06:01 PM »
Yeah, it's really always bothered me a bit...

Anyway... I'm pretty much stuck in the mess that I wrote for Wess before. It has variables for is_android and is_iphone (when really it should be is_ios only), and is_tablet -- what's the point in this...? is_tablet is only used PHP-wide in addition to is_iphone, and in JavaScript it can easily be replaced with is_touch and a screen dimension test. As for CSS, a media query is all it takes... (Plus is_touch tests.)

I'm looking at it, and I think I'll have to clean it further...
But I don't really see how I can justify storing this or that version number but not all of them. The only thing I can say is, look at Chrome... It has so many versions in my cache files, it's frightening.

Frak. I don't know where to go from there... -_-
Perhaps I should just forget about Windows version numbers for now. Only store version numbers for iOS because of the whole "browser engine is always Safari Mobile thanks to Apple" story that means new browser features are discovered with new iOS versions, rather than browser updates. Android, well... There are plenty of features added on each new version, but I guess it can be done by "@if (android && opera[7-], android && chrome[20-])", etc...
Maybe just store Windows version for Windows 7 and up -- and state it as "7" rather than "6.1", except of course if Microsoft decides to name Windows 9 differently, ah ah... You never know with them...

What do you think...?

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278

Nao

  • Dadman with a boy
  • Posts: 16,082