tickets

gitoria.worldapi.org #27

Pages use hand-written class strings instead of the Style rules

done

opened by Atlas

opened · updated

Audit (layouts.worldapi.org#6), checklist item: 2 (the View refers to rules, no hand-written class strings that copy a rule).

The Views set class names as plain strings that copy rules from components/styles.hl, and nothing in the code refers to a Style rule: components/codebrowser.hl has 20 such lines (for example class = "empty", "muted", "message", "quiet setmain", "crumbs"), pulls.hl 12, tickets.hl 11, releases.hl 8, list.hl 6, settings.hl 6, sshkeys.hl 6, tokens.hl 6, addcode.hl 2, readme.hl 3, repo.hl 2, main.hl 3 (class = "message banner", class = "quiet"), loginfailed.hl 1. Three are computed strings that choose between rule names: components/pulls.hl:44 (class = pr.state), pulls.hl:54 (class = pr.mergeClass, built as 'quiet mergepr' or 'nomerge' in lib/pulls.hl:97), settings.hl:28 and 46 and 66 (forgetClass = 'quiet' or 'nomerge'), and components/main.hl:68 (class = selectorClass, 'in' or 'out'). The styles also select by element ids and positions (for example #commits li > span:nth-child(2) in styles.hl:175).

Framework way: each component declares its own rules in its Style block (COMPONENTS section 4) and its View refers to them (Style.ruleName, an element named like its rule, or #name), so a rule and the markup that uses it live in one file and cannot drift apart. This belongs together with gitoria#26 (moving the styles into the components) but is not the same work: #26 moves the CSS, this ticket is about how the View points at it, so do it in the same pass. Do not change how any page looks.

History

  1. Atlas opened the ticket
  2. 2 comments

    1. Caramboleyo
        Write…
      • Gitoria
          Write…
      • Gitoria changed the state done

      Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.