Skip to content

Commit b4a050c

Browse files
committed
Fix juliuste#17: Add a button to calendar and day view to switch departure and arrival location
1 parent 6c18e42 commit b4a050c

File tree

3 files changed

+44
-8
lines changed

3 files changed

+44
-8
lines changed

assets/styles/base.css

+18
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,24 @@ body{
5050
text-decoration: underline;
5151
}
5252

53+
#reverse-direction {
54+
color: #000;
55+
text-decoration: none;
56+
border: 1px solid #044;
57+
padding: .2rem;
58+
margin: 0 .5rem;
59+
border-radius: 4px;
60+
}
61+
62+
#reverse-direction span {
63+
transition: transform .2s ease-in-out;
64+
display: inline-block;
65+
}
66+
67+
#reverse-direction:hover span, #reverse-direction:focus span, #reverse-direction:active span {
68+
transform: rotate(180deg);
69+
}
70+
5371
#footer {
5472
position: absolute;
5573
font-size: 100%;

src/lib/routes/calendar/template.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import mdf from 'moment-duration-format'
55
import * as helpers from '../helpers.js'
66

77
const head = (api, data) => {
8-
const title = generateSubTitleRoute(data).join('') + ' | Kalender'
8+
const title = generateSubTitleRoute(api, data).join('') + ' | Kalender'
99
const elements = [
1010
...helpers.staticHeader(api),
1111
h('title', `${title} | ${api.settings.title}`),
@@ -15,10 +15,19 @@ const head = (api, data) => {
1515
return h('head', elements)
1616
}
1717

18-
const generateSubTitleRoute = (data) => {
18+
const generateSubTitleRoute = (api, data) => {
19+
const reverseTravelLink = h('a', {
20+
href: (
21+
'?origin=' + data.input.destination.name +
22+
'&destination=' + data.input.origin.name +
23+
'&weeks=' + data.input.weeks +
24+
'&' + (api.options.url(data.input).join('&'))
25+
),
26+
id: 'reverse-direction',
27+
}, h('span', ' → '))
1928
return [
2029
data.input.origin.name,
21-
' → ',
30+
reverseTravelLink,
2231
data.input.destination.name,
2332
]
2433
}
@@ -121,7 +130,7 @@ const createTemplate = api => (data, error) => {
121130
h('body', [
122131
h('div#page', [
123132
h('div#header', [h('a', { href: './start', title: 'Preiskalender' }, [h('h1', 'Preiskalender')])]),
124-
h('div', { id: 'route', class: 'subtitle' }, [h('span', generateSubTitleRoute(data))]),
133+
h('div', { id: 'route', class: 'subtitle' }, [h('span', generateSubTitleRoute(api, data))]),
125134
h('div', { id: 'options', class: 'subtitle' }, generateSubTitleOptions(api, data)),
126135
calendar(api, data),
127136
h('div#more', moreLink(api, data)),

src/lib/routes/day/template.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as helpers from '../helpers.js'
1010
const productIndex = ['Bus', 'BUS', 'RB', 'RE', 'IRE', 'IC', 'IEC', 'EC', 'ICE']
1111

1212
const head = (api, data) => {
13-
const title = generateSubTitleRoute(data).join('') + ' | Tagesansicht'
13+
const title = generateSubTitleRoute(api, data).join('') + ' | Tagesansicht'
1414
const elements = [
1515
...helpers.staticHeader(api),
1616
h('title', `${title} | ${api.settings.title}`),
@@ -138,10 +138,19 @@ const generateSubTitleDate = (data) => {
138138
]
139139
}
140140

141-
const generateSubTitleRoute = (data) => {
141+
const generateSubTitleRoute = (api, data) => {
142+
const reverseTravelLink = h('a', {
143+
href: (
144+
'?origin=' + data.input.destination.name +
145+
'&destination=' + data.input.origin.name +
146+
'&date=' + data.input.date.format('DD.MM.YYYY') +
147+
'&' + (api.options.url(data.input).join('&'))
148+
),
149+
id: 'reverse-direction',
150+
}, h('span', ' → '))
142151
return [
143152
data.input.origin.name,
144-
' → ',
153+
reverseTravelLink,
145154
data.input.destination.name,
146155
]
147156
}
@@ -161,7 +170,7 @@ const createTemplate = api => data => {
161170
h('body', [
162171
h('div#page', [
163172
h('div#header', [h('a', { href: './start', title: 'Preiskalender' }, [h('h1', 'Preiskalender')])]),
164-
h('div', { class: 'subtitle' }, [h('span', generateSubTitleRoute(data))]),
173+
h('div', { class: 'subtitle' }, [h('span', generateSubTitleRoute(api, data))]),
165174
h('div', { id: 'date', class: 'subtitle' }, generateSubTitleDate(data)),
166175
h('div', { id: 'options', class: 'subtitle' }, generateSubTitleOptions(api, data)),
167176
journeyTable(api, data),

0 commit comments

Comments
 (0)