Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some more fixes in trackhacks.css #166

Merged
merged 5 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions noshadows.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,25 @@ def skip_whitespace(nodes):
return filter(lambda node: node.type != "whitespace", nodes)


SHADOW_CSS_PROPERTIES = {
"box-shadow",
"text-shadow",
}


def has_shadow(rule):
if not rule.content:
return False

for a, b, c in tripletwise(skip_whitespace(rule.content)):
if isinstance(a, tokens.IdentToken) and a.value == "box-shadow":
if isinstance(a, tokens.IdentToken) and a.value in SHADOW_CSS_PROPERTIES:
assert isinstance(
c, (tokens.IdentToken, tokens.DimensionToken, tokens.NumberToken)
), f"Unexpected node type {c.type}"
return isinstance(c, (tokens.DimensionToken, tokens.NumberToken))
if isinstance(c, (tokens.DimensionToken, tokens.NumberToken)):
return True

return False


def find_shadow(rules):
Expand Down Expand Up @@ -138,16 +147,21 @@ def test_skip_whitespace(self):
) # attr, colon, value, semicolon

def test_has_shadow(self):
(rule,) = parse_stylesheet("html {box-shadow: 10px 5px 5px red;}")
self.assertTrue(has_shadow(rule))

def test_has_shadow_with_box_shadow_none(self):
(rule,) = parse_stylesheet("html {box-shadow: none;}")
self.assertFalse(has_shadow(rule))

def test_has_shadow_empty_rule(self):
(rule,) = parse_stylesheet("html {}")
self.assertFalse(has_shadow(rule))
for expected, css in [
(True, "html {box-shadow: 10px 5px 5px red;}"),
(True, "html {text-shadow: 1px 1px 2px pink;}"),
(True, "html {text-shadow: 5px 5px #558ABB;}"),
(False, "html {box-shadow: none;}"),
(False, "html {text-shadow: none;}"),
(True, "html {text-shadow: 5px 5px #558ABB; box-shadow: none;}"),
(True, "html {text-shadow: none; box-shadow: 10px 5px 5px red;}"),
(False, "html {}"),
(False, "html {color: red; font-weight: bold;}"),
]:
with self.subTest(css=css, expected=expected):
(rule,) = parse_stylesheet(css)
assert_method = self.assertTrue if expected else self.assertFalse
assert_method(has_shadow(rule))

def test_selector_str_tag(self):
(rule,) = parse_stylesheet("html {}")
Expand Down Expand Up @@ -191,6 +205,7 @@ def test_selector_str_pseudoclass_nonstandard(self):
// fit well with our design.
@mixin noshadow {
box-shadow: none;
text-shadow: none;
border-radius: unset;
}
"""
Expand Down
4 changes: 3 additions & 1 deletion scss/_noshadows.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Generated by noshadows.py on 2024-01-18T15:52:50.928155
// Generated by noshadows.py on 2024-01-26T15:44:23.711667

// Trac uses box-shadow and text-shadow everywhere but their 90s look doesn't
// fit well with our design.
@mixin noshadow {
box-shadow: none;
text-shadow: none;
border-radius: unset;
}

Expand Down Expand Up @@ -80,6 +81,7 @@ fieldset,
#mainnav,
div.trac-content,
.foldable :link, .foldable :visited,
fieldset > legend.foldable :link, fieldset > legend.foldable :visited,
#prefs,
pre.wiki, pre.literal-block,
table.wiki,
Expand Down
8 changes: 7 additions & 1 deletion scss/trachacks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ div.trac-content {
max-width: 1400px;
}

#changelog h3 {
#ticketchange h3.change, #changelog h3.change {
margin-top: 10px;
margin-bottom: 5px;
padding: 5px;
background: $green-very-light;

&:target {
background: $green-light;
}
}

#changelog p {
Expand Down Expand Up @@ -403,6 +408,7 @@ div[role="main"]{
tr {
td {
padding: 0.5em !important; // :(
text-indent: 0 !important; // Used on the /rpc page
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions trac-env/templates/django_theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@
# if resourcepath_template:
# include resourcepath_template ignore missing
# endif

# if chrome.ctxtnav:
<div id="ctxtnav" class="nav">
<h2>${_("Context Navigation")}</h2>
# if chrome.ctxtnav:
<ul>
# for elm in chrome.ctxtnav:
<li ${{'class': {'first': loop.first, 'last': loop.last}}|htmlattr}>${
elm}</li>
# endfor
</ul>
# endif
<hr />
</div>
# endif

${jmacros.warnings(chrome.warnings)}

Expand Down