Skip to content

Commit

Permalink
Add minor improvements to style properties and avoid inline styles
Browse files Browse the repository at this point in the history
  • Loading branch information
viliket committed Sep 8, 2024
1 parent 7dd5cc7 commit ad223ad
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 39 deletions.
7 changes: 4 additions & 3 deletions src/components/StationTimeTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ function StationTimeTableRow({
onClick={() => tableRowOnClick(trainNumber, departureDate)}
>
<TableCell scope="row">
<span
style={{
<Box
component="span"
sx={{
display: 'flex',
alignItems: 'center',
}}
Expand Down Expand Up @@ -99,7 +100,7 @@ function StationTimeTableRow({
departureDate={departureDate}
/>
</Box>
</span>
</Box>
</TableCell>
<TableCell>
<Link
Expand Down
10 changes: 3 additions & 7 deletions src/components/TimeTableRowTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ function TimeTableRowTime({ row }: TimeTableRowTimeProps) {
{
fontWeight: '500',
},
delayInMinutes > 0
? {
color: 'error.main',
}
: {
color: null,
},
delayInMinutes > 0 && {
color: 'error.main',
},
]}
>
{format(actualTime, 'HH:mm')}
Expand Down
4 changes: 2 additions & 2 deletions src/components/TopNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export function TopNavBar() {
marginRight: 'auto',
display: 'inline-flex',
alignItems: 'center',
color: 'inherit',
textDecoration: 'none',
}}
component={Link}
color="inherit"
style={{ textDecoration: 'none' }}
href="/"
>
<Box
Expand Down
38 changes: 16 additions & 22 deletions src/components/TrainComposition.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Typography } from '@mui/material';
import { Box, ButtonBase, Typography } from '@mui/material';
import { orderBy } from 'lodash';
import {
BagChecked,
Expand Down Expand Up @@ -192,9 +192,9 @@ function TrainComposition({
},
}}
>
<div
<Box
className="composition"
style={{
sx={{
display: 'flex',
flexDirection:
trainDirection === TrainDirection.Decreasing
Expand All @@ -211,10 +211,10 @@ function TrainComposition({
// Note: Should never be null
<span key={i}>?</span>
) : (
<button
<ButtonBase
key={`${w.location}-${w.compositionStatus}`}
onClick={() => onWagonClick(w)}
style={{
sx={{
display: 'inline-flex',
flexDirection: 'column',
alignItems: 'center',
Expand All @@ -229,7 +229,9 @@ function TrainComposition({
margin: 0,
padding: 0,
backgroundColor: 'transparent',
cursor: 'pointer',
'&.Mui-focusVisible': {
outline: 'revert',
},
}}
>
<span>
Expand Down Expand Up @@ -279,7 +281,7 @@ function TrainComposition({
isCommuterTrain={!!train.commuterLineid}
/>
</Box>
</button>
</ButtonBase>
)
)}
<Box
Expand All @@ -288,20 +290,12 @@ function TrainComposition({
display: 'flex',
color: 'primary.main',
},
trainDirection === TrainDirection.Increasing
? {
marginRight: '-1rem',
}
: {
marginRight: null,
},
trainDirection === TrainDirection.Decreasing
? {
marginLeft: '-1rem',
}
: {
marginLeft: null,
},
trainDirection === TrainDirection.Increasing && {
marginRight: '-1rem',
},
trainDirection === TrainDirection.Decreasing && {
marginLeft: '-1rem',
},
]}
>
{trainDirection === TrainDirection.Decreasing ? (
Expand All @@ -310,7 +304,7 @@ function TrainComposition({
<ChevronRight />
)}
</Box>
</div>
</Box>
{hasStationRow && (
<Box
className="stopping-sectors"
Expand Down
4 changes: 2 additions & 2 deletions src/components/TrainStationTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ const TrainStationTimeline = ({
</Grid>
<Grid size={12}>
{realTimeTrain && (
<div style={{ textAlign: 'center' }}>
<Box sx={{ textAlign: 'center' }}>
<TrainComposition
train={realTimeTrain}
stationTimeTableRowGroup={g}
onWagonClick={onWagonClick}
/>
</div>
</Box>
)}
{stationMessages &&
stationMessages[station.shortCode]?.length > 0 && (
Expand Down
7 changes: 4 additions & 3 deletions src/components/TrainSubNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ function TrainSubNavBar({ train }: TrainSubNavBarProps) {
{train.trainNumber}
</Avatar>
)}
<span
style={{
<Box
component="span"
sx={{
display: 'flex',
flexDirection: 'column',
}}
Expand All @@ -88,7 +89,7 @@ function TrainSubNavBar({ train }: TrainSubNavBarProps) {
train
)} - ${getTrainDestinationStationName(train)}`}
</Box>
</span>
</Box>
</>
)}
</h4>
Expand Down

0 comments on commit ad223ad

Please sign in to comment.