Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented word count for setting bio #398

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
implemented word count for setting bio
  • Loading branch information
ispykenny committed Jul 9, 2024
commit 952f556eb2edf5b5e9928853775b85fc71421167
20 changes: 19 additions & 1 deletion hushline/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1147,15 +1147,33 @@ p.helper {
outline-offset: 2px;
}

.label-with-wordcount {
display: flex;
justify-content: space-between;
gap: 8px;
flex-direction: column;
margin-bottom: .5rem;
}

.label-with-wordcount label {
margin-bottom: 0;
}

button[name="update_directory_visibility"] {
visibility: hidden;
display: none;
}

@media(min-width: 480px) {
.label-with-wordcount {
flex-direction: row;
align-items: center;
}
}

@media only screen and (max-width: 480px) {
#searchInput {
min-width: 100%;

}

.search-box {
Expand Down
5 changes: 5 additions & 0 deletions hushline/static/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ document.addEventListener('DOMContentLoaded', function() {
// Tab functionality
const tabs = document.querySelectorAll('.tab');
const tabContents = document.querySelectorAll('.tab-content');
const bioCountEl = document.querySelector('.bio-count');

function removeActiveClasses() {
tabs.forEach(tab => tab.classList.remove('active'));
Expand Down Expand Up @@ -37,4 +38,8 @@ document.addEventListener('DOMContentLoaded', function() {
document.querySelector("button[name='update_directory_visibility']").click();
}, 200)
});

document.getElementById('bio').addEventListener('keyup', function(e) {
bioCountEl.textContent = e.target.value.length;
});
});
5 changes: 4 additions & 1 deletion hushline/templates/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ <h3>Public User Directory</h3>
<h3>Add Your Bio</h3>
<form method="POST" action="{{ url_for('settings.index') }}">
<div class="form-group">
<label for="bio">Bio (up to 250 characters):</label>
<div class="label-with-wordcount">
<label for="bio">Bio (up to 250 characters):</label>
<span><span class="bio-count">0</span>/250</span>
</div>
<textarea id="bio" name="bio" rows="4" maxlength="250">{{ user.bio or '' }}</textarea>
</div>
<button type="submit" name="update_bio">Update Bio</button>
Expand Down
Loading