Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit a51e8d6

Browse files
hubert-derivHubert Koster
andauthored
Hubert / Fixing design real account form (#6541)
* removing buggy code * fixing form input alignment and fixing js styling code causing bugs. * some fixes * adding functionality to center text in select inputs * fixing form, aligning everything left * fixing also realws form * styling on select fix * centering text only on real account creation mobile * removing text indent, breaking on safari * refactoring code Co-authored-by: Hubert Koster <hubertkoster@Huberts-MacBook-Pro.local>
1 parent 8ce9960 commit a51e8d6

File tree

5 files changed

+83
-14
lines changed

5 files changed

+83
-14
lines changed

src/javascript/app/common/content_visibility.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,23 @@ const ContentVisibility = (() => {
202202
};
203203

204204
const centerSelect = ($el) => {
205-
const option_width = getTextWidth($el.children(':selected').html());
206-
const empty_space = '280' - option_width; // in mobile all select drop-downs are hardcoded to be at 280px in css
207-
$el.css('text-indent', (empty_space / 2) - 7); // 7px is for the drop-down arrow
205+
const option_width = getTextWidth($el.children(':selected').text());
206+
const center_option_text = option_width / 2;
207+
$el.css('text-indent', `calc(50% - ${center_option_text}px)`);
208208
};
209209

210210
const centerAlignSelect = (should_init) => {
211211
$(window).off('resize', centerAlignSelect);
212-
$center_select_m = ((typeof should_init === 'boolean' && should_init) || !$center_select_m) ? $('.center-select-m') : $center_select_m;
212+
$('#frm_real #trading_experience_form select, #frm_real #financial_info_form select').addClass('center-select-m');
213+
$center_select_m = ((typeof should_init === 'boolean' && should_init) || !$center_select_m) ? $('#frm_real .center-select-m') : $center_select_m;
213214

214215
if ($(window).width() <= 480) {
216+
const financial_form_selects = $('#frm_real select');
217+
financial_form_selects.get().forEach((element) => {
218+
const option_width = getTextWidth($(element).children(':selected').text());
219+
const center_option_text = option_width / 2;
220+
$(element).css('text-indent', `calc(50% - ${center_option_text}px)`);
221+
});
215222
$center_select_m.on('change', function() {
216223
centerSelect($(this));
217224
});

src/sass/app/websocket_pages.scss

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,51 @@
9191
}
9292
}
9393

94-
#financial-form {
94+
#financial-form, .realws-content {
95+
#lbl_residence {
96+
text-align: left;
97+
margin-left: 0.5rem;
98+
}
99+
#date_of_birth {
100+
margin: 0;
101+
text-indent: 0;
102+
}
103+
input:not([type=checkbox]), .select-dropdown, #citizen {
104+
width: 260px;
105+
}
106+
#citizen, #address_postcode {
107+
box-sizing: unset;
108+
-webkit-box-sizing: unset;
109+
}
110+
95111
@media screen and (max-width: 480px) {
96-
div.select {
97-
width: calc(100% - 3rem);
112+
select, div.select {
113+
width: 100%;
114+
height: 2rem;
115+
}
116+
.place_of_birth_container .gr-8 {
117+
text-align: left;
118+
}
119+
div.select:after {
120+
top: 12px;
121+
}
122+
input:not([type=checkbox]), #citizen {
123+
width: calc(100% - 1.2rem);
124+
height: 1.5rem;
125+
text-align: left;
126+
}
127+
#source_of_wealth {
128+
min-width: 0;
129+
}
130+
.select2-container {
131+
width: 100% !important;
132+
}
133+
.select2-selection {
134+
text-align: left;
135+
}
136+
div.select + span {
137+
width: 100%;
138+
height: 1.9rem;
98139
}
99140
}
100141
}
@@ -335,12 +376,27 @@
335376
}
336377

337378
.realws-content {
338-
div.select-dropdown {
339-
width: 100%;
379+
#lbl_residence {
380+
margin-left: 0.5rem;
381+
text-align: left;
382+
}
383+
#date_of_birth {
384+
margin: 0;
385+
text-indent: 0;
340386
}
341387

342388
@media screen and (max-width: 480px) {
343-
width: 280px !important;
389+
#lbl_residence {
390+
text-align: center;
391+
margin-left: -0.5rem;
392+
}
393+
#address_form #address_postcode {
394+
width: calc(100% - 1.2rem);
395+
height: 1.5rem;
396+
}
397+
#secret_answer, .select2-selection, input:not([type=checkbox]) {
398+
text-align: center;
399+
}
344400
}
345401
}
346402

src/templates/_common/components/forms_common_rows.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ export const Residence = ({ className, row_class, row_id }) => (
7272
className={className || ''}
7373
label={it.L('Country of residence')}
7474
>
75-
<label id='lbl_residence' />
75+
<div id='residence_container'>
76+
<label id='lbl_residence' />
77+
</div>
7678
</FormRow>
7779
);
7880

@@ -158,7 +160,7 @@ export const Phone = ({ hint, row_class, row_id }) => (
158160
);
159161

160162
export const SecretQuestion = () => (
161-
<FormRow type='select' id='secret_question' label={it.L('Secret question')}>
163+
<FormRow type='select' id='secret_question' className='center-select-m' label={it.L('Secret question')}>
162164
<option value='Favourite dish'>{it.L('Favourite dish')}</option>
163165
<option value="Mother's maiden name">{it.L('Mother\'s maiden name')}</option>
164166
<option value='Name of your pet'>{it.L('Name of your pet')}</option>

src/templates/app/new_account/financial.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ const Financial = () => (
4343
<LastName className='input-disabled' />
4444
<DateOfBirth className='input-disabled' />
4545
<Citizenship />
46-
<FormRow type='select' id='place_of_birth' label={it.L('Place of birth')} attributes={{ single: 'single' }} />
46+
<div className='place_of_birth_container'>
47+
<FormRow type='select' id='place_of_birth' label={it.L('Place of birth')} attributes={{ single: 'single' }} />
48+
</div>
4749
<Residence />
4850
<AccountOpeningReason />
4951
<Phone />

src/templates/app/new_account/real.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ const Real = () => (
3737
<LastName className='input-disabled' />
3838
<DateOfBirth className='input-disabled' />
3939
<Citizenship row_class='invisible' />
40-
<FormRow type='select' id='place_of_birth' label={it.L('Place of birth')} attributes={{ single: 'single' }} />
40+
<div className='place_of_birth_container'>
41+
<FormRow type='select' id='place_of_birth' label={it.L('Place of birth')} attributes={{ single: 'single' }} />
42+
</div>
4143
<Residence />
4244
<Phone />
4345
<AccountOpeningReason />

0 commit comments

Comments
 (0)