Skip to content

Commit aa71267

Browse files
Remove non-pure css selectors from scss modules (#145)
1 parent 7b57894 commit aa71267

14 files changed

Lines changed: 127 additions & 106 deletions

File tree

next.config.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,6 @@ const {
1111

1212
const scenariosFilePath = path.join(".", "scenarios.json");
1313

14-
// See https://github.com/vercel/next.js/issues/10142#issuecomment-648974042
15-
const hackStylesToSupportNonPureDeclarations = (config) => {
16-
const oneOf = config.module.rules.find((rule) => typeof rule.oneOf === "object");
17-
18-
const fixUse = (use) => {
19-
const { loader, options } = use;
20-
if (options && options.modules && loader && loader.indexOf("css-loader") >= 0) {
21-
options.modules.mode = "local";
22-
}
23-
};
24-
25-
if (oneOf) {
26-
oneOf.oneOf.forEach((rule) => {
27-
if (Array.isArray(rule.use)) {
28-
rule.use.map(fixUse);
29-
} else if (rule.use && rule.use.loader) {
30-
fixUse(rule.use);
31-
}
32-
});
33-
}
34-
};
35-
3614
const loadScenariosJsonStringFromFile = () => {
3715
return fs.readFileSync(scenariosFilePath);
3816
};
@@ -79,7 +57,6 @@ module.exports = (phase) => {
7957
if (shouldWriteScenariosWithWebpack) {
8058
config.plugins.push(createWriteScenariosPlugin());
8159
}
82-
hackStylesToSupportNonPureDeclarations(config);
8360
return config;
8461
},
8562
};

package-lock.json

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@types/heap": "^0.2.34",
5151
"@types/node": "^22.10.2",
5252
"@types/react": "^18.0.0",
53+
"@types/smoothscroll-polyfill": "^0.3.4",
5354
"@typescript-eslint/eslint-plugin": "^7.3.0",
5455
"@typescript-eslint/parser": "^7.3.0",
5556
"ajv": "^7.2.4",

src/components/AppFrame/AppFrame.module.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
display: flex;
55
flex-direction: column;
66
min-height: 100vh;
7+
78
@include mobile {
89
font-size: 15px;
910
}
@@ -18,6 +19,7 @@
1819
color: white;
1920
overflow: hidden;
2021
z-index: 2;
22+
2123
@include mobile {
2224
flex-direction: column;
2325
align-items: flex-start;
@@ -30,12 +32,15 @@
3032
display: flex;
3133
align-items: center;
3234
font-size: 16px;
35+
3336
a,
3437
a:hover {
3538
color: white;
3639
}
40+
3741
a {
3842
text-decoration: none;
43+
3944
&:hover {
4045
text-decoration: underline;
4146
}
@@ -45,7 +50,8 @@
4550
.breadcrumb {
4651
display: flex;
4752
align-items: center;
48-
> span {
53+
54+
>span {
4955
line-height: 1em;
5056
margin: 0 10px;
5157
}

src/components/FrequencyTimeline/FrequencyTimeline.module.scss

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
@import '../../styles/base.scss';
22

3-
:root {
4-
--arrival-width: 8px;
5-
}
6-
7-
@include mobile {
8-
:root {
9-
--arrival-width: 6px;
10-
}
11-
}
12-
13-
$arrival-width: var(--arrival-width);
3+
$arrival-width: 8px;
4+
$mobile-arrival-width: 6px;
145

156
.timeline {
167
display: flex;
@@ -30,12 +21,14 @@ $arrival-width: var(--arrival-width);
3021
top: 0;
3122
height: 60%;
3223
transform: translateX(-1px);
24+
3325
:global(.hairline) {
3426
position: relative;
3527
height: 100%;
3628
width: 1px;
3729
border-right: 1px solid #ddd;
3830
}
31+
3932
:global(.label) {
4033
position: absolute;
4134
bottom: -5px;
@@ -44,6 +37,7 @@ $arrival-width: var(--arrival-width);
4437
color: #999;
4538
white-space: nowrap;
4639
user-select: none;
40+
4741
@include mobile {
4842
font-size: 10px;
4943
}
@@ -67,6 +61,11 @@ $arrival-width: var(--arrival-width);
6761
border-radius: $arrival-width;
6862
margin-bottom: 5px;
6963
box-sizing: border-box;
64+
65+
@include mobile {
66+
width: $mobile-arrival-width;
67+
height: $mobile-arrival-width;
68+
}
7069
}
7170

7271
.baselineArrival {

src/components/Home/Home.module.scss

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
.subtitle {
6767
font-style: italic;
6868
text-align: center;
69+
6970
@include mobile {
7071
font-size: 14px;
7172
}
@@ -75,6 +76,7 @@
7576
height: 30px;
7677
z-index: 1;
7778
margin-bottom: 20px;
79+
7880
@include mobile {
7981
margin-bottom: 0;
8082
height: 20px;
@@ -98,7 +100,8 @@
98100
font-weight: bold;
99101
letter-spacing: 0.01em;
100102

101-
&:hover, &:active {
103+
&:hover,
104+
&:active {
102105
background: white;
103106
color: $darker-rr-purple;
104107
}
@@ -122,6 +125,7 @@
122125
display: flex;
123126
flex-direction: column;
124127
align-items: center;
128+
125129
@include mobile {
126130
width: 100%;
127131
margin: 10px 0;
@@ -132,6 +136,7 @@
132136
display: grid;
133137
grid-template-columns: repeat(3, 1fr);
134138
column-gap: 60px;
139+
135140
@include mobile {
136141
display: flex;
137142
flex-direction: column;
@@ -173,6 +178,7 @@
173178
margin: 0;
174179
line-height: 1.5em;
175180
text-align: center;
181+
176182
@include mobile {
177183
font-size: 14px;
178184
}
@@ -185,4 +191,4 @@
185191

186192
.scrollSnapEnd {
187193
scroll-snap-align: end;
188-
}
194+
}

src/components/Home/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Button } from "@ariakit/react/button";
44
import { GiElectric } from "react-icons/gi";
55
import { IoMdTimer } from "react-icons/io";
66
import { MdGridOn } from "react-icons/md";
7+
import { CgChevronDoubleDown } from "react-icons/cg";
78
import smoothscroll from "smoothscroll-polyfill";
89

910
import { useAppContext, useViewport } from "hooks";
@@ -12,7 +13,6 @@ import { LiveNetworkVisualizer, PowerText, SuggestedJourneys } from "components"
1213
import OverviewCircle from "./OverviewCircle";
1314

1415
import styles from "./Home.module.scss";
15-
import { CgChevronDoubleDown } from "react-icons/cg";
1616

1717
const Home = () => {
1818
const { viewportHeight } = useViewport();

src/components/JourneySummaryCard/JourneySummaryCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const getJourneyDuration = (journey: JourneyInfo) => {
6565
};
6666

6767
const Text = (props) => {
68-
return <text fontFamily="Helvetica,sans-serif" fill="white" {...props} />;
68+
return <text fill="white" {...props} />;
6969
};
7070

7171
const JourneySummaryCard = (props: Props) => {

src/components/JourneyTimeline/JourneyTimeline.module.scss

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ $expand-control-size: 30px;
88
$start-end-point-size: 16px;
99

1010
@mixin circle-on-line-with-label($circle-size) {
11-
$circle-left: ($travel-transfer-station-size - $circle-size) / 2;
11+
$circle-left: (
12+
$travel-transfer-station-size - $circle-size) / 2;
1213
display: flex;
1314
align-items: center;
1415

@@ -31,33 +32,38 @@ $start-end-point-size: 16px;
3132

3233
.journeyTimeline {
3334
position: relative;
35+
3436
@include mobile {
3537
font-size: 13px;
3638
}
39+
40+
@include line-colors;
3741
}
3842

3943
.travelSegment {
4044
display: flex;
4145
flex-direction: column;
4246
justify-content: space-between;
4347
position: relative;
48+
4449
:global(.stem) {
4550
position: absolute;
46-
height: calc(100% - #{$travel-transfer-station-size});
47-
top: $travel-transfer-station-size / 2;
48-
left: $travel-transfer-station-size / 2;
49-
transform: translateX(-50%);
50-
width: $stem-width;
51-
background: currentColor;
52-
}
51+
height: calc(100% - #{$travel-transfer-station-size}
52+
);
53+
top: $travel-transfer-station-size / 2;
54+
left: $travel-transfer-station-size / 2;
55+
transform: translateX(-50%);
56+
width: $stem-width;
57+
background: currentColor;
58+
}
5359

54-
:global(.inner) {
55-
padding: 10px 0;
56-
display: flex;
57-
flex-direction: column;
58-
justify-content: space-around;
59-
flex-grow: 1;
60-
}
60+
:global(.inner) {
61+
padding: 10px 0;
62+
display: flex;
63+
flex-direction: column;
64+
justify-content: space-around;
65+
flex-grow: 1;
66+
}
6167
}
6268

6369
.travelSegmentPassedStation {
@@ -98,6 +104,7 @@ $start-end-point-size: 16px;
98104

99105
&:hover {
100106
cursor: pointer;
107+
101108
:global(.label) {
102109
text-decoration: underline;
103110
}
@@ -132,6 +139,7 @@ $start-end-point-size: 16px;
132139
font-weight: normal;
133140
margin-left: 0.5em;
134141
white-space: nowrap;
142+
135143
@include mobile {
136144
margin-left: auto;
137145
}
@@ -158,14 +166,17 @@ $start-end-point-size: 16px;
158166

159167
:global(.start-end-point) {
160168
@include circle-on-line-with-label($start-end-point-size);
169+
161170
:global(.circle) {
162171
box-sizing: border-box;
163172
background: white;
164173
border: 2px solid cornflowerblue;
165174
}
175+
166176
:global(.label) {
167177
font-weight: bold;
168178
display: flex;
179+
169180
:global(.time) {
170181
font-weight: normal;
171182
margin-left: 0.5em;
@@ -183,7 +194,7 @@ $start-end-point-size: 16px;
183194
border: 1px dashed cornflowerblue;
184195
}
185196

186-
& > :global(.label) {
197+
&> :global(.label) {
187198
display: flex;
188199
flex-direction: column;
189200
justify-content: center;
@@ -197,6 +208,7 @@ $start-end-point-size: 16px;
197208
a.stationName {
198209
color: inherit;
199210
text-decoration: none;
211+
200212
&:hover {
201213
text-decoration: underline;
202214
}

src/components/JourneyTimeline/JourneyTimeline.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const TravelSegment = (props: { segment: JourneyTravelSegment }) => {
106106

107107
return (
108108
<div className={classNames(styles.travelSegment, textColor(color))}>
109-
<div className="stem" />
109+
<div className={"stem"} />
110110
{renderEndpoint(startStation, startTime)}
111111
<div className="inner" style={expanded ? { minHeight: height } : { height }}>
112112
{renderInnerContents()}

0 commit comments

Comments
 (0)