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
Next Next commit
color preview ui done
  • Loading branch information
saurabhdaware committed Oct 2, 2019
commit af7c1cbf0cdc8a8b762fcb33e37fe723a437e655
38 changes: 38 additions & 0 deletions app/assets/stylesheets/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,44 @@
}
}
}
.settings-color-select-container{
display:flex;
width:100%;
.color-select-fields{
flex:1;
width:50%;
.select-field-wrapper{
display:flex;
input[type="color"] {
-webkit-appearance: none;
border: none;
border-radius:0px;
padding:10px;
height:28px;
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:#0099ff;
fill:#fff;
padding:25px 20px;
border-radius:7px;
margin-top:20px;
}
}

}
.checkbox-field {
display: flex;
flex-direction: column;
Expand Down
5 changes: 5 additions & 0 deletions app/javascript/packs/colorPreview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// const bgColorField = document.getElementById('bg-color-colorfield');
// const textColorField = document.getElementById('text-color-colorfield');

// const bgTextField = document.getElementById('bg-color-textfield');
// const colorTextField = document.getElementById('text-color-textfield');
36 changes: 24 additions & 12 deletions app/views/users/_profile.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= javascript_pack_tag "colorPicker", defer: true %>
<%= javascript_pack_tag "colorPreview", defer: true %>

<% unless @user.identities.exists?(provider: 'github') %>
<div class="field">
Expand Down Expand Up @@ -71,17 +71,29 @@
<%= f.label :summary %>
<%= f.text_area :summary, placeholder: "a short bio.", maxlength: 200 %>
</div>
<div class="field">
<% @user.bg_color_hex = user_colors(@user)[:bg] if @user.bg_color_hex.blank? %>
<%= f.label :bg_color_hex, "background color" %>
<%= f.text_field :bg_color_hex, placeholder: "#000000", class: "color-picker" %>
<div class="color-palette"></div>
</div>
<div class="field">
<% @user.bg_color_hex = user_colors(@user)[:text] if @user.text_color_hex.blank? %>
<%= f.label :text_color_hex, "text color" %>
<%= f.text_field :text_color_hex, placeholder: "#ffffff", class: "color-picker" %>
<div class="color-palette"></div>
<div class="settings-color-select-container">
<div class="color-select-fields">
<div class="field">
<% @user.bg_color_hex = user_colors(@user)[:bg] if @user.bg_color_hex.blank? %>
<%= f.label :bg_color_hex, "background color" %><br>
<div class="select-field-wrapper">
<%= f.text_field :bg_color_hex, placeholder: "#000000", class: "color-select-textbox", id: "bg-color-textfield" %>
<input id="bg-color-colorfield" type="color">
</div>
</div>
<div class="field">
<% @user.bg_color_hex = user_colors(@user)[:text] if @user.text_color_hex.blank? %>
<%= f.label :text_color_hex, "text color" %><br>
<div class="select-field-wrapper">
<%= f.text_field :text_color_hex, placeholder: "#ffffff", class: "color-select-textbox", id: "text-color-colorfield" %>
<input id="text-color-colorfield" type="color">
</div>
</div>
</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>
</div>
</div>
<div class="field">
<%= f.label :location %>
Expand Down