Skip to content

Commit d9d9968

Browse files
committed
Removed text-shadow completely
The noshadows.py script now handles text-shadow also. Fixes #153
1 parent 5eea970 commit d9d9968

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

noshadows.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,25 @@ def skip_whitespace(nodes):
4949
return filter(lambda node: node.type != "whitespace", nodes)
5050

5151

52+
SHADOW_CSS_PROPERTIES = {
53+
'box-shadow',
54+
'text-shadow',
55+
}
56+
57+
5258
def has_shadow(rule):
5359
if not rule.content:
5460
return False
5561

5662
for a, b, c in tripletwise(skip_whitespace(rule.content)):
57-
if isinstance(a, tokens.IdentToken) and a.value == "box-shadow":
63+
if isinstance(a, tokens.IdentToken) and a.value in SHADOW_CSS_PROPERTIES:
5864
assert isinstance(
5965
c, (tokens.IdentToken, tokens.DimensionToken, tokens.NumberToken)
6066
), f"Unexpected node type {c.type}"
61-
return isinstance(c, (tokens.DimensionToken, tokens.NumberToken))
67+
if isinstance(c, (tokens.DimensionToken, tokens.NumberToken)):
68+
return True
69+
70+
return False
6271

6372

6473
def find_shadow(rules):
@@ -140,8 +149,14 @@ def test_skip_whitespace(self):
140149
def test_has_shadow(self):
141150
for expected, css in [
142151
(True, "html {box-shadow: 10px 5px 5px red;}"),
152+
(True, "html {text-shadow: 1px 1px 2px pink;}"),
153+
(True, "html {text-shadow: 5px 5px #558ABB;}"),
143154
(False, "html {box-shadow: none;}"),
155+
(False, "html {text-shadow: none;}"),
156+
(True, "html {text-shadow: 5px 5px #558ABB; box-shadow: none;}"),
157+
(True, "html {text-shadow: none; box-shadow: 10px 5px 5px red;}"),
144158
(False, "html {}"),
159+
(False, "html {color: red; font-weight: bold;}")
145160
]:
146161
with self.subTest(css=css, expected=expected):
147162
(rule,) = parse_stylesheet(css)
@@ -190,6 +205,7 @@ def test_selector_str_pseudoclass_nonstandard(self):
190205
// fit well with our design.
191206
@mixin noshadow {
192207
box-shadow: none;
208+
text-shadow: none;
193209
border-radius: unset;
194210
}
195211
"""

scss/_noshadows.scss

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// Generated by noshadows.py on 2024-01-18T15:52:50.928155
1+
// Generated by noshadows.py on 2024-01-26T15:44:23.711667
22

33
// Trac uses box-shadow and text-shadow everywhere but their 90s look doesn't
44
// fit well with our design.
55
@mixin noshadow {
66
box-shadow: none;
7+
text-shadow: none;
78
border-radius: unset;
89
}
910

@@ -80,6 +81,7 @@ fieldset,
8081
#mainnav,
8182
div.trac-content,
8283
.foldable :link, .foldable :visited,
84+
fieldset > legend.foldable :link, fieldset > legend.foldable :visited,
8385
#prefs,
8486
pre.wiki, pre.literal-block,
8587
table.wiki,

0 commit comments

Comments
 (0)