Skip to content

Commit

Permalink
gender picker setting
Browse files Browse the repository at this point in the history
  • Loading branch information
singharaj-usai committed Oct 1, 2024
1 parent 3e26d73 commit 299fb70
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
20 changes: 20 additions & 0 deletions client/html/pages/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,29 @@ <h3 class="panel-title">Appearance</h3>
<option value="cyborg">Dark Mode</option>
</select>
</div>

<div class="form-group">
<label>Gender</label>
<div id="gender-picker">
<label>
<input type="radio" name="gender" value="male">
<i class="bi bi-gender-male"></i> Male
</label>
<label>
<input type="radio" name="gender" value="female">
<i class="bi bi-gender-female"></i> Female
</label>
<label>
<input type="radio" name="gender" value="other">
<i class="bi bi-gender-trans"></i> Other
</label>
</div>
</div>
<button id="save-settings" class="btn btn-primary">Save Settings</button>
</div>
</div>


</div>

<!-- Scripts -->
Expand Down
16 changes: 16 additions & 0 deletions client/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,36 @@ $(document).ready(function() {
App.init();
loadUserSettings();

// gender picker
$('.gender-option').on('click', function() {
$('.gender-option').removeClass('selected');
$(this).addClass('selected');
});

// Handle save settings button click
$('#save-settings').on('click', saveUserSettings);

});

function loadUserSettings() {
const theme = localStorage.getItem('theme') || 'cyborg';
$('#theme-select').val(theme);
applyTheme(theme);

const gender = localStorage.getItem('gender') || 'other';
$(`#gender-picker input[value="${gender}"]`).prop('checked', true);

}

function saveUserSettings() {
const theme = $('#theme-select').val();
const gender = $('#gender-picker input:checked').val();

localStorage.setItem('theme', theme);
localStorage.setItem('gender', gender);

applyTheme(theme);

showAlert('Settings saved successfully!', 'success');
}

Expand Down

0 comments on commit 299fb70

Please sign in to comment.