Skip to content

Commit 6b10f6d

Browse files
committed
responsive and translations
1 parent 2d9edfc commit 6b10f6d

File tree

9 files changed

+76
-34
lines changed

9 files changed

+76
-34
lines changed

src/components/appointments/Appointments.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import React, { Component } from 'react'
22
import {Link, Route} from 'react-router-dom'
33
import ReactTooltip from 'react-tooltip'
44
import {colour_contrast, group_by} from '../../utils'
5-
import {If} from '../shared/Tools'
5+
import {If, Bull} from '../shared/Tools'
66
import {CalendarCheck, CalendarPlus, CalendarTimes} from '../shared/Svgs'
77
import AptModal from './AptModal'
88

99
const LS_KEY = '_tcs_user_data_'
10+
// matches value in appointments.scss
11+
const NARROW = 750
1012

1113
const group_appointments = apts => {
1214
// group appointments by month then day
@@ -19,6 +21,7 @@ const group_appointments = apts => {
1921

2022
const Apt = ({apt, props, appointment_attendees}) => {
2123
const full = apt.attendees_max === apt.attendees_count
24+
const narrow = window.innerWidth < NARROW
2225
const colour = full ? '#CCC' : apt.service_colour
2326
let Icon, tip
2427
const spaces_ctx = {spaces: apt.attendees_max - apt.attendees_count}
@@ -35,10 +38,13 @@ const Apt = ({apt, props, appointment_attendees}) => {
3538
<div>
3639
<Icon/>
3740
<span>{props.config.date_fns.format(apt.start, 'HH:mm')}</span>
38-
<span>{apt.topic} ({apt.service_name})</span>
41+
<span>{apt.topic}</span>
42+
{narrow && <br/>}
43+
<span>({apt.service_name})</span>
3944
</div>
40-
<div>
41-
<span>{props.config.format_time_diff(apt.finish, apt.start)}</span>&bull;
45+
<div className="tcs-right">
46+
<span>{props.config.format_time_diff(apt.finish, apt.start)}</span>
47+
{narrow ? <br/> :<Bull/>}
4248
<span>{props.config.format_money(apt.price)}</span>
4349
</div>
4450
</div>

src/components/appointments/AptModal.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@ const AptDetails = ({apt, spaces_available, props}) => (
1111
<div className="tcs-extra">
1212
<div className="tcs-price">
1313
{props.config.format_money(apt.price)}
14-
<div className="tcs-label">Price</div>
14+
<div className="tcs-label">{props.config.get_text('price')}</div>
1515
</div>
1616
</div>
1717
<div className="tcs-content">
1818
<DetailGrid>
19-
<Detail label="Job">{apt.service_name}</Detail>
20-
{apt.attendees_max && <Detail label="Spaces Available">{spaces_available}</Detail>}
21-
<Detail label="Start" className="tcs-new-line">{props.config.format_datetime(apt.start)}</Detail>
22-
<Detail label="Finish">{props.config.format_datetime(apt.finish)}</Detail>
23-
{apt.location && <Detail label="Location">{apt.location}</Detail>}
19+
<Detail label="job" config={props.config}>{apt.service_name}</Detail>
20+
{apt.attendees_max && <Detail label="spaces_available" config={props.config}>{spaces_available}</Detail>}
21+
<Detail label="start" config={props.config} className="tcs-new-line">
22+
{props.config.format_datetime(apt.start)}
23+
</Detail>
24+
<Detail label="finish" config={props.config}>{props.config.format_datetime(apt.finish)}</Detail>
25+
{apt.location && <Detail label="location" config={props.config}>{apt.location}</Detail>}
2426
</DetailGrid>
2527
</div>
2628
</div>
@@ -37,7 +39,7 @@ const AddExisting = ({students, book, booking_allowed, get_text}) => (
3739
</div>
3840
{already_on_apt ? (
3941
<div className="tcs-already-added">
40-
Added <Tick/>
42+
{get_text('added')} <Tick/>
4143
</div>
4244
) : (
4345
<button className="tcs-button tcs-add-button"
@@ -53,7 +55,7 @@ const AddExisting = ({students, book, booking_allowed, get_text}) => (
5355

5456
const AddNew = ({new_student, onChange, book, booking_allowed, get_text}) => (
5557
<div className="tcs-book-new">
56-
<div>Add a new Student to the lesson</div>
58+
<div>{get_text('add_new_student')}</div>
5759
<div className="tcs-book-item">
5860
<input type="text"
5961
className="tcs-default-input"
@@ -161,8 +163,8 @@ class AptModal extends Component {
161163
const apt = this.state.apt
162164
if (!apt) {
163165
return (
164-
<Modal history={this.props.history} title="Appointment not Found">
165-
<p>No Appointment found with id {this.props.id}.</p>
166+
<Modal history={this.props.history} title={this.props.config.get_text('appointment_not_found')}>
167+
<p>{this.props.config.get_text('appointment_not_found_id', {apt_id: this.props.id})}</p>
166168
</Modal>
167169
)
168170
}
@@ -206,7 +208,7 @@ class AptModal extends Component {
206208
{this.state.display_data.nm}
207209
<br/>
208210
<div className="tcs-signout" onClick={this.props.signout}>
209-
Not you? sign out
211+
{this.props.config.get_text('not_you_sign_out')}
210212
</div>
211213
</div>
212214
}

src/components/shared/Modal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class Modal extends Component {
4848
<div className={'tcs-modal-mask' + (this.state.show ? ' tcs-show' : '')} onClick={this.close}>
4949
<div className="tcs-modal" onClick={e => e.stopPropagation()}>
5050
<div className="tcs-header">
51-
<h2>{this.props.title}</h2>
52-
<div className="close" onClick={this.close}>
51+
<h2 className="tcs-h2">{this.props.title}</h2>
52+
<div className="tcs-close" onClick={this.close}>
5353
<Cross/>
5454
</div>
5555
</div>

src/components/shared/Tools.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export const DetailGrid = ({children}) => (
5252
</div>
5353
)
5454

55-
export const Detail = ({label, children, className}) => (
55+
export const Detail = ({label, children,config, className}) => (
5656
<div className={`tcs-detail ${className || ''}`}>
57-
<div className="tcs-label">{label}</div>
57+
<div className="tcs-label">{config.get_text(label)}</div>
5858
<div className="tcs-value">{children}</div>
5959
</div>
6060
)
@@ -73,3 +73,5 @@ export const DisplayExtraAttrs = ({extra_attributes}) => (
7373
))}
7474
</div>
7575
)
76+
77+
export const Bull = () => <span className="tcs-bull">&bull;</span>

src/conf.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ $dft-border-color: #CCC;
2727
$label-colour: #666;
2828
// border colour used for inputs
2929
$input-border-colour: #aaa;
30+
// windows considered small / "mobile"
31+
$window-small: 750px;

src/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ const STRINGS = {
6363
no_spaces_attending: 'Already attending, no more spaces available',
6464
add_existing_students: 'Add your existing Students to the lesson',
6565
add_new_student: 'Add a new Student to the lesson',
66+
appointment_not_found: 'Appointment not Found',
67+
appointment_not_found_id: 'No Appointment found with id {apt_id}.',
68+
price: 'Price',
69+
job: 'Job',
70+
spaces_available: 'Spaces Available',
71+
start: 'Start',
72+
finish: 'Finish',
73+
location: 'Location',
74+
not_you_sign_out: 'Not you? sign out',
75+
added: 'Added',
6676
}
6777

6878
const MODES = ['grid', 'list', 'enquiry', 'enquiry-modal', 'appointments']

src/styles/appointments.scss

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
@import '../conf';
22

3-
.tcs-appointments {
4-
padding: 10px;
5-
}
6-
73
.tcs-apt-group-month {
84
padding: 10px 8px;
95
.tcs-title {
@@ -16,27 +12,43 @@
1612
padding-bottom: 12px;
1713
display: grid;
1814
grid-template-columns: 100px auto;
15+
@media(max-width: $window-small) {
16+
grid-template-columns: 60px auto;
17+
}
1918
.tcs-day {
2019
border-right: 2px solid #DDD;
21-
margin-right: 12px;
22-
padding-right: 12px;
2320
text-align: right;
2421
font-size: 18px;
22+
margin-right: 12px;
23+
padding-right: 12px;
24+
@media(max-width: $window-small) {
25+
margin-right: 6px;
26+
padding-right: 6px;
27+
}
2528
}
2629
.tcs-apt {
2730
margin: 0 0 8px;
2831
padding: 8px 6px 8px 10px;
2932
border-radius: $border-radius;
30-
display: flex;
31-
justify-content: space-between;
33+
display: grid;
34+
grid-template-columns: auto auto;
3235
color: black;
3336
vertical-align: top;
37+
.tcs-svg {
38+
margin-right: 5px;
39+
@media(max-width: $window-small) {
40+
display: none;
41+
}
42+
}
3443
span {
35-
margin: 0 5px;
44+
margin-right: 5px;
3645
}
3746
&.dark {
3847
color: white;
3948
}
49+
.tcs-right {
50+
text-align: right;
51+
}
4052
}
4153
.tcs-item:last-child .tcs-apt {
4254
margin-bottom: 0;

src/styles/modal.scss

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,25 @@
3636

3737
.tcs-header {
3838
margin-bottom: 10px;
39-
padding-bottom: 10px;
39+
padding-bottom: 5px;
4040
border-bottom: 2px solid $dft-border-color;
41-
h2 {
41+
h2.tcs-h2 {
4242
margin-top: 0;
4343
margin-bottom: 0;
4444
display: inline-block;
4545
font-size: 29px;
4646
font-weight: 400;
47-
height: 32px;
47+
height: 39px;
48+
white-space: nowrap;
49+
overflow: hidden;
50+
text-overflow: ellipsis;
51+
width: calc(100% - 40px);
52+
@media(max-width: $window-small) {
53+
font-size: 26px;
54+
height: 35px;
55+
}
4856
}
49-
.close {
57+
.tcs-close {
5058
float: right;
5159
}
5260
}

src/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ export const slugify = text => (
176176
text
177177
.toLowerCase()
178178
.replace(/\s+/g, '-') // Replace spaces with -
179-
.replace(/[^\w-]+/g, '') // Remove all non-word chars
180-
.replace(/--+/g, '-') // Replace multiple - with single -
179+
.replace(/[^\w-]+/g, '') // Remove all non-word chars
180+
.replace(/--+/g, '-') // Replace multiple - with single -
181181
.replace(/^-+/, '') // Trim - from start of text
182182
.replace(/-+$/, '') // Trim - from end of text
183183
)

0 commit comments

Comments
 (0)