Skip to content

Document index.css consistently - #84

Open
ZayanKhan-12 wants to merge 2 commits into
twitter:developfrom
ZayanKhan-12:docs/index-css-comments
Open

ZayanKhan-12 wants to merge 2 commits into
twitter:developfrom
ZayanKhan-12:docs/index-css-comments

Conversation

@ZayanKhan-12

Copy link
Copy Markdown

Fixes #78.

index.css had five comments across 274 lines, written in two different styles (/** x */ and /** x **/), and they named sections without saying what the rules were for. Several blocks that are easy to get wrong carried nothing at all — which is what @nikhilpatil123 reported.

What the comments now say

Rather than restating the declarations, each block records what it styles, where its markup comes from, and what it is coupled to. The couplings are the reason most of this is worth writing down:

  • The sidebar width is four values that must change together#sidebar width 250px, #wrapper.toggled margin-left -250px, #toggle left 250px, and #contents margin-left 270px. Changing one alone misaligns the layout.
  • The collapse transition is duplicated across three selectors (#wrapper, #sidebar, #toggle) and has to stay in sync for them to animate together.
  • Two classes are applied from outside this file. index.js toggles toggled on #wrapper; IndexView.renderNav sets active on the nav group containing the current page. Neither is discoverable from the stylesheet.

The file header records something that is not obvious and changes how you read the whole sheet: IndexView loads this after bootstrap.min.css, so most rules exist to override a Bootstrap default. A rule that looks redundant usually is not — deleting it restores the Bootstrap appearance rather than changing nothing.

I also noted the selectors that appear nowhere in this repository's templates, so they don't read as dead code. .popover-content is generated by Bootstrap's own JavaScript, and .tabs-right / .tabs-below complete a set that services built on Twitter Server can use, of which StackRegistryView renders only .tabs-left.

Grounded in IndexView.scala, index.js and StackRegistryView.scala rather than inferred from selector names, so the comments describe what the code actually does.

Second commit: a bug found while documenting it

The spinner rule declared -animation. A vendor prefix has to name a vendor, so -animation matched nothing, browsers discarded the declaration, and only the -webkit- rule applied — the refresh spinner turned in Chrome and Safari and sat motionless in Firefox. The @keyframes spin rule it referenced was already present and, until now, unreachable.

Confirmed by parsing the declaration with a CSS engine:

declarations the parser kept:  -webkit-animation, animation
  -animation kept?         NO  - dropped as an unknown property

It is a one-word change and the only behaviour change in this PR, so it is a separate commit — drop it if you would rather keep this documentation-only, and I will open it on its own.

Verification

The documentation commit changes no behaviour, and I checked that rather than asserting it: stripping every comment from the file before and after leaves byte-identical CSS.

CSS with all comments stripped is identical: True
comment blocks  before: 5   after: 15

The stylesheet parses without errors (50 rules and at-rules) both before and after.

I could not run sbt clean test — there is no JVM on this machine, and CI's build also needs twitter/dodo-build to build the dependency chain. index.css is served as a static resource from /admin/files/css/, so nothing compiles against it, but the Scala suite is unrun on my side and needs CI to confirm.

I have not added a CLAUDE.md. Writing one that is actually useful means understanding the sbt/Bazel build and the Scala cross-version setup, and I could not build the project here; a file guessing at that would be worse than none.

zk-khan and others added 2 commits September 17, 2026 11:11
The stylesheet had five comments across 274 lines, in two different styles, and
they named sections without saying what the rules were for. Several blocks that
are easy to get wrong carried nothing at all.

Adds a file header recording what the sheet styles and, importantly, that
IndexView loads it after bootstrap.min.css: most rules here exist to override a
Bootstrap default, so one that looks redundant usually is not. Each block now
has a comment in one consistent form covering what it styles, where the markup
comes from, and what it is coupled to.

The couplings are the reason for most of this. The sidebar width is repeated as
four values that have to change together (#sidebar width, #wrapper.toggled
margin-left, #toggle left, #contents margin-left), the collapse transition is
duplicated across three selectors that have to stay in sync, and both the
"toggled" and "active" classes are applied elsewhere -- by index.js and by
IndexView respectively -- which is not discoverable from the stylesheet alone.

Selectors that never appear in this repository's templates are noted rather than
left to look dead: .popover-content is generated by Bootstrap's JavaScript, and
the .tabs-right and .tabs-below variants complete a set that services built on
Twitter Server can use, of which StackRegistryView only renders .tabs-left.

Comments only. Verified by stripping every comment from the file before and
after and confirming the remaining CSS is identical.

Fixes twitter#78

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
.glyphicon-refresh-animate declared "-animation". A vendor prefix has to name a
vendor, so "-animation" matched nothing and browsers dropped the declaration,
leaving only the -webkit- rule. The spinner turned in Chrome and Safari and sat
motionless in Firefox.

Confirmed by parsing the declaration with a CSS engine: "-animation" is
discarded while "animation" and "-webkit-animation" are kept. The @Keyframes
spin rule it refers to was already present and, until now, unreachable.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ZayanKhan-12 pushed a commit to ZayanKhan-12/twitter-server that referenced this pull request Sep 17, 2026
Document index.css consistently (fixes twitter#78)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent Documentation in index.css

3 participants