[3.0] Theme split (wave 2, part 7) — Use logical properties for the float and alignment utilities - #9356
Conversation
Theme::loadCss() has been asking for variables.css since 3.0 Alpha, at order_pos -2 so it lands ahead of index.css, but the default theme never shipped the file. The request is quietly dropped, so nothing breaks and nothing happens either. This adds it. The first group of tokens covers what index.css sets before it gets to any particular part of the forum: the html and body backgrounds, the body font and colour, the selection colours, form controls in their normal, hover, focus and disabled states, fieldsets and their legends, strong, headings, and the horizontal rule. Every value is the one that rule already had, so this changes no pixels. That is the point: it puts the vocabulary in place, with the names the new theme uses, so the parts that follow can convert their own section of index.css without also arguing about what the value ought to be. Changing what the forum looks like is a separate job from giving its values names. Verified by comparing computed styles across eight pages - board index, board, topic, posting form, search, profile, admin and help - for the eighteen selectors these rules reach and the fourteen properties they set. 1316 comparisons, no differences. Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
Second group of tokens: the .button family, which the quickbuttons and the inline moderation checkbox share the same rules with. Normal, hover, focus and active states, plus the border, radius, shadow, cursor, font size, text transform and the text shadow the active button carries. As with the first group, every value is the one the rule already had, so nothing changes on screen. The two hard-coded values left in these rules are deliberate: .pagesection .button uses the body link colour rather than a button colour, and the SimpleMachines#222 in the shared hover rule only ever reaches the quickbuttons, because the very next rule overrides it for .button. Neither has an honest name in this vocabulary yet. Verified two ways. Each of the nineteen tokens resolves to exactly the literal it replaced, read back from :root in the browser. Then computed styles for eleven button variants - plain, active, quickbutton, inline mod check, first and last in a buttonrow, inside a cat_bar, smalltext, and the three of those that can hold focus - across twenty properties. 220 comparisons, no differences. Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
Third group: the containers every page is built out of. The cat bar and its heading, the title bar, the sub bar, the roundframe, the information box, and the windowbg together with the backgrounds it takes when a topic is locked, sticky, both, or waiting for approval. Same rule as the earlier groups - every value is the one that rule already had, and nothing changes on screen. One thing worth knowing for the parts that follow. Three of these rules set a border on a single side: div.cat_bar and .sub_bar have a border-bottom, and .information has all four minus the top. Rewriting those as the border-color / border-style / border-width triple looks equivalent and is not: it leaves style and colour set on the sides whose width is zero, so a later rule that gives one of those sides a width would paint a border that could not have appeared before. The single-side shorthand is kept. Two values are left hard-coded. The shared rule for h3.titlebg and h3.subbg sets one colour and one font family for both bars, so tokenising it means choosing which of the two names it belongs to; that is a decision for whoever changes the palette. And what the theme calls the even row is this theme's odd one, so #fdfdfd is --window-odd-bg here rather than borrowing a name that would then mean the opposite. Verified the same two ways as the earlier parts. All 48 tokens resolve to the literal they replaced, and computed styles for 22 container variants across 23 properties, including all four border widths and colours and each corner radius separately: 506 comparisons, no differences. The border point above is not theoretical - the first attempt at these rules produced 14 of them, which is how it was found. Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
Fourth group: the boxes SMF talks to people through - error, notice, info and desc - and the two bars, the generic one used for stats and the progress bar with its four colours. Every value is the one the rule already had, so nothing changes on screen. The error, notice and info boxes each carry a border on the top and bottom only, so they keep their two single-side shorthands for the reason the previous part ran into: writing them as border-color, border-style and border-width would leave a style and a colour on the left and right sides, where today there is none. .errorbox sets no colour of its own, so there is no --errorbox-color to add yet; it inherits, and that is worth keeping visible rather than inventing a value for it. Verified as before. All 40 tokens resolve to the literal they replaced, and computed styles for 23 elements - each box, the error box heading, its alert paragraph and its span, both bars, their inner bar, the vertical variant and the four progress colours - across 27 properties, with every border side read separately. 621 comparisons, no differences. Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
Fifth group: what BBC produces inside a post. Blockquote and its cite, the standard and alternate quote backgrounds, the code block, and the underline on a BBC link in both its states. Every value is the one the rule already had, so nothing changes on screen. Two of these rules do carry a border on every side, unlike the ones in the previous parts, so the border-color, border-style and border-width triple is the right shape for them and reproduces what the shorthands were doing: blockquote is 1px 2px in #d6dfe2 #aaa, and .bbc_code is 2px 1px 3px in #bbb #dfdfdf #aaa. The single-side borders on blockquote cite and .bbc_link keep their shorthand. .codeheader and .quoteheader share one rule and one set of values, so tokenising it means choosing whether it belongs to the code vocabulary or the quote one - the same situation as the title bar and sub bar headings in the third part, and left the same way, for whoever changes the palette. Verified as before. All 21 tokens resolve to the literal they replaced, and computed styles for 11 elements across 23 properties, every border side read separately: 253 comparisons, no differences. Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
Sixth group: the things that sit on top of a page rather than inside it. The AJAX notification bar and its link, the popup container, window, heading and content, the search result highlight, and the moderation link. Every value is the one the rule already had, so nothing changes on screen. One value is deliberately not a token. .highlight has background-color: inherit, and a custom property cannot hold that: inherit is a CSS-wide keyword, so --searchhighlight-bg: inherit on :root asks to inherit from an element that has no parent, resolves to the guaranteed-invalid value, and every var() reading it falls back to transparent. Close enough to invisible in most places to pass a screenshot, and wrong wherever the highlight sits inside something coloured. It stays a literal, with a comment saying why. Verified as before, plus one extra check for that case: a .highlight inside a parent painted rgb(1, 2, 3) still computes to rgb(1, 2, 3) rather than transparent. All 24 remaining tokens resolve to the literal they replaced, and computed styles for nine elements across 26 properties: 234 comparisons, no differences. Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
First of the RTL parts. .floatright, .floatleft, .clear_left, .clear_right, .righttext, .lefttext and .bbc_list say inline-start and inline-end rather than left and right, so they follow the writing direction on their own and rtl.css no longer has to flip them. Seven overrides go with them. Left to right is untouched: twelve geometry probes, no differences. Right to left changes in one place, and it is a fix. .righttext and .lefttext set an auto margin as well as a text alignment, and rtl.css only ever flipped the alignment. So in an RTL forum a .righttext block has been hugging the right edge - the start side - while its own text aligned left. Measured in a 400px container, the box sat 300px from the left before and sits at 0 now, which is the end side, where its text already was. The alignment itself does not move: the same probe measuring where the text lands inside the block reports no change in either direction. Verified with lang_rtl set on en_US, before and after, on both branches. Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
|
This PR does what it is supposed to do, so the following issue is not a problem with the PR itself. Rather, this PR has brought to my attention an issue that already existed and that we might as well fix now. The .bbc_float.floatleft {
float: left;
}
.bbc_float.floatright {
float: right;
}This is a change that should probably also be implemented in SMF 2.1, but that is outside of the scope of this PR. |
Co-authored-by: Jon Stovell <jonstovell@gmail.com>
Sesquipedalian
left a comment
There was a problem hiding this comment.
I have implemented my suggested changes myself.
Description
Part of the #7933 split, wave 2 part 7 — the first of the RTL parts. Stacked on #9350 through #9355, in that merge order.
rtl.cssexists to flip physical properties. Where a rule can sayinline-startandinline-endinstead ofleftandright, it follows the writing direction on its own and the override is not needed. This does that for the float and alignment utilities:Seven overrides drop out of
rtl.css, which goes from 686 to 665 lines. #7933 ends up at 414, so this is the first bite of that.Left to right is untouched, right to left gets a fix
LTR is unchanged: twelve geometry probes, no differences.
RTL changes in one place, and it is a repair.
.righttextand.lefttextset an auto margin as well as a text alignment, andrtl.cssonly ever flipped the alignment:So in an RTL forum a
.righttextblock has been hugging the right edge — the start side — while its own text aligns left. Measured in a 400px container, the box sat 300px from the left before and sits at 0 now, which is the end side, where its text already was.The alignment itself does not move. The same run measured where the text lands inside the block, for
.righttext,.lefttextand.bbc_list, and reports no change in either direction — only the box position changed.Testing
Fresh install on MySQL, Docker environment, with
lang_rtlset onen_USto getdir="rtl". Captured on both branches, in both directions.Geometry rather than computed styles, deliberately:
getComputedStylereturnsfloat: inline-endas authored rather than resolving it, so a computed-style comparison reports a difference for every converted declaration and proves nothing either way.getBoundingClientRectmeasures what actually happened. Each probe records the box's distance from both edges of a fixed 400px parent, its vertical offset and its width — so a float that lands on the wrong side, a clear that fails to clear, and an alignment that does not move all show up as numbers..righttextand.lefttextbox position, described aboveError log clean. The unit suite does not reach CSS, so there is no test to add here.
Issues References (Fixes|Related|Closes)
Related to #7933, #9350, #9351, #9352, #9353, #9354, #9355