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

Fix #4106: Showing color preview in Edit Profile #4212

Merged
merged 4 commits into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fields container width fix for firefox
  • Loading branch information
saurabhdaware committed Oct 3, 2019
commit 3c4eb465bcc94c754bcf6d38e2ac23b2507214a9
26 changes: 12 additions & 14 deletions app/assets/stylesheets/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -166,39 +166,37 @@
}
}
.settings-color-select-container{
display:flex;
display: flex;
width:100%;
.color-select-fields{
flex:1;
width:50%;
.select-field-wrapper{
display:flex;
display: flex;
width:100%;
.color-select-textbox{
flex:1;
min-width:70px;
}
input[type="color"] {
-webkit-appearance: none;
box-sizing:border-box;
border: none;
border-radius:0px;
padding:10px;
height:28px;
padding:3px;
width:50px;
height:48px;
cursor:pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper {
padding: 0;
}
input[type="color"]::-webkit-color-swatch {
border: none;
}
}
}
.color-select-preview{
flex:1;
text-align:center;
padding:20px;
#color-select-preview-logo{
background-color:#111111;
fill:#fff;
padding:25px 20px;
border-radius:7px;
margin-top:20px;
display:none; /* Changes to inline-block when javascript loads preview */
}
}

Expand Down
7 changes: 4 additions & 3 deletions app/javascript/packs/colorPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,19 @@ function watchColorFields() {

// When text fields change -> updateColorField values and refresh preview
function watchTextFields(e) {
if (e.target.value.match(/[0-9a-f]{6}/gi)) {
if (e.target.value.match(/#[0-9a-f]{6}/gi)) {
updateColorFields();
updatePreview();
}
}

// Event Listeners
colorField.bgColor.addEventListener('change', watchColorFields);
colorField.textColor.addEventListener('change', watchColorFields);
colorField.bgColor.addEventListener('input', watchColorFields);
colorField.textColor.addEventListener('input', watchColorFields);
textField.bgColor.addEventListener('keyup', watchTextFields);
textField.textColor.addEventListener('keyup', watchTextFields);

// on init
updateColorFields();
updatePreview();
preview.style.display = 'inline-block';
2 changes: 1 addition & 1 deletion app/views/users/_profile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
</div>
<div class="color-select-preview">
<span style="display:block;">PREVIEW</span>
<svg id="color-select-preview-logo" xmlns="http://www.w3.org/2000/svg" version="1" width="100px" viewBox="0 0 132.000000 65.000000" role="img" aria-labelledby="aldzs1ucwkayuyoa6rxtxo2ikd8bpr0q" class="logo"><title id="aldzs1ucwkayuyoa6rxtxo2ikd8bpr0q">App logo</title><path d="M0 33v32h11.3c12.5 0 17.7-1.6 21.5-6.5 3.8-4.8 4.4-9 4-28-.3-16.8-.5-18.2-2.7-21.8C30.3 2.5 26.1 1 12 1H0v32zm23.1-19.1c2.3 1.9 2.4 2.3 2.4 18.5 0 15.7-.1 16.7-2.2 18.8-1.7 1.6-3.5 2.2-7 2.2l-4.8.1-.3-20.8L11 12h4.9c3.3 0 5.6.6 7.2 1.9zM46.1 3.6c-2 2.6-2.1 3.9-2.1 29.6v26.9l2.5 2.4c2.3 2.4 2.9 2.5 16 2.5H76V54.1l-10.2-.3-10.3-.3v-15l6.3-.3 6.2-.3V27H55V12h21V1H62.1c-13.9 0-14 0-16 2.6zM87 15.2c2.1 7.9 5.5 20.8 7.6 28.8 3.2 12.3 4.3 15 7 17.7 1.9 2 4.2 3.3 5.7 3.3 3.1 0 7.1-3.1 8.5-6.7 1-2.6 15.2-55.6 15.2-56.8 0-.3-2.8-.5-6.2-.3l-6.3.3-5.6 21.5c-3.5 13.6-5.8 20.8-6.2 19.5C105.9 40 96 1.9 96 1.4c0-.2-2.9-.4-6.4-.4h-6.4L87 15.2z"></path></svg>
<svg id="color-select-preview-logo" xmlns="http://www.w3.org/2000/svg" version="1" width="90px" viewBox="0 0 132.000000 65.000000" role="img" aria-labelledby="aldzs1ucwkayuyoa6rxtxo2ikd8bpr0q" class="logo"><title id="aldzs1ucwkayuyoa6rxtxo2ikd8bpr0q">App logo</title><path d="M0 33v32h11.3c12.5 0 17.7-1.6 21.5-6.5 3.8-4.8 4.4-9 4-28-.3-16.8-.5-18.2-2.7-21.8C30.3 2.5 26.1 1 12 1H0v32zm23.1-19.1c2.3 1.9 2.4 2.3 2.4 18.5 0 15.7-.1 16.7-2.2 18.8-1.7 1.6-3.5 2.2-7 2.2l-4.8.1-.3-20.8L11 12h4.9c3.3 0 5.6.6 7.2 1.9zM46.1 3.6c-2 2.6-2.1 3.9-2.1 29.6v26.9l2.5 2.4c2.3 2.4 2.9 2.5 16 2.5H76V54.1l-10.2-.3-10.3-.3v-15l6.3-.3 6.2-.3V27H55V12h21V1H62.1c-13.9 0-14 0-16 2.6zM87 15.2c2.1 7.9 5.5 20.8 7.6 28.8 3.2 12.3 4.3 15 7 17.7 1.9 2 4.2 3.3 5.7 3.3 3.1 0 7.1-3.1 8.5-6.7 1-2.6 15.2-55.6 15.2-56.8 0-.3-2.8-.5-6.2-.3l-6.3.3-5.6 21.5c-3.5 13.6-5.8 20.8-6.2 19.5C105.9 40 96 1.9 96 1.4c0-.2-2.9-.4-6.4-.4h-6.4L87 15.2z"></path></svg>
</div>
</div>
<div class="field">
Expand Down