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

feat(public account): add background image #298

Merged
merged 3 commits into from
Nov 30, 2023
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
6 changes: 6 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,9 @@ button.is-gray:hover {
padding: 5px 10px;
opacity: 0.7;
}

.account-has-bg {
border-radius: 12px;
background-size: cover;
background-position: center;
}
3 changes: 1 addition & 2 deletions app/javascript/image/loadAccountBackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ document.addEventListener('turbolinks:load', function () {
const reader = new FileReader();
reader.onload = function (e) {
accountBackground.style.backgroundImage = "url('" + e.target.result + "')";
accountBackground.style.borderRadius = "16px";
accountBackground.style.backgroundSize = "cover";
accountBackground.classList.add("account-has-bg")
};
reader.readAsDataURL(file);
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/accounts/edit.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.column.is-one-third
h2.title.is-4.has-text-centered Edit account
= form_with model: account do |f|
.columns.is-mobile.is-justify-content-space-between#account-background(style="#{"border-radius: 16px; background-size: cover; background-image: url('#{url_for(account.background)}');" if account.background.attached?}")
.columns.is-mobile.is-justify-content-space-between#account-background(style="background-image: url('#{url_for(account.background)}');" class="account-has-bg" - if account.background.attached?)
.column.is-one-third
.field
.figure.image.is-128x128(class="#{'bg-around-image' if account.background.attached?}")
Expand Down
12 changes: 6 additions & 6 deletions app/views/accounts/show.html.slim
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#topup-utc-time data-utc-time= topup_utc_time
.columns
/ desktop
.column.for-desktop.is-two-fifths.box.m-2
.p-4(style="#{"border-radius: 16px; background-size: cover; background-image: url('#{url_for(account.background)}');" if account.background.attached?}")
.column.for-desktop.is-two-fifths.box.m-2(style="#{"background-image: url('#{url_for(account.background)}');" if account.background.attached?}" class="#{'account-has-bg' if account.background.attached?}")
.p-4
- if account.parent.email != current_user.email && current_user.parent?
.columns
.column.is-flex.is-justify-content-center.is-align-items-center
.has-text-weight-bold
.has-text-weight-bold(class="#{'bg-around-text' if account.background.attached?}")
| Account owner: #{account.parent.email}
.columns.is-mobile
.column.is-4.is-flex.is-justify-content-center.is-align-items-center
Expand All @@ -15,12 +15,12 @@
.title.is-black-budgeting-kid-color(class="#{'bg-around-text' if account.background.attached?}")
= account.name
/ mobile
.column.for-mobile.is-two-fifths.box
.p-4(style="#{"border-radius: 16px; background-size: cover; background-image: url('#{url_for(account.background)}');" if account.background.attached?}")
.column.for-mobile.is-two-fifths.box(style="#{"background-image: url('#{url_for(account.background)}');" if account.background.attached?}" class="#{'account-has-bg' if account.background.attached?}")
.p-4
- if account.parent.email != current_user.email && current_user.parent?
.columns
.column.is-flex.is-justify-content-center.is-align-items-center
.has-text-weight-bold
.has-text-weight-bold(class="#{'bg-around-text' if account.background.attached?}")
| Account owner: #{account.parent.email}
.columns.is-mobile
.column.is-4.px-0.is-flex.is-justify-content-center.is-align-items-center
Expand Down
26 changes: 13 additions & 13 deletions app/views/public_account_shares/show.html.slim
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#topup-utc-time data-utc-time= topup_utc_time
.columns
/ desktop
.column.for-desktop.box.m-2
div.p-4.mb-4
.column.for-desktop.box.m-2(style="#{"background-image: url('#{url_for(public_account.background)}');" if public_account.background.attached?}" class="#{'account-has-bg' if public_account.background.attached?}")
.p-4
.columns
.column.is-flex.is-justify-content-center.is-align-items-center
.has-text-weight-bold
.has-text-weight-bold(class="#{'bg-around-text' if public_account.background.attached?}")
| Account owner: #{public_account.parent.email}
.columns.is-mobile
.column.is-4.is-flex.is-justify-content-center.is-align-items-center
img src=asset_path(avatar_for(public_account)) class="rounded-avatar" id='image-preview'
img src=asset_path(avatar_for(public_account)) class="rounded-avatar #{'bg-around-image' if public_account.background.attached?}" id='image-preview'
.column.is-flex.is-justify-content-flex-start.is-align-items-center
.title.is-black-budgeting-kid-color
.title.is-black-budgeting-kid-color(class="#{'bg-around-text' if public_account.background.attached?}")
= public_account.name
/ mobile
.column.for-mobile.box
div.p-4
.column.for-mobile.box(style="#{"background-image: url('#{url_for(public_account.background)}');" if public_account.background.attached?}" class="#{'account-has-bg' if public_account.background.attached?}")
.p-4
.columns
.column.is-flex.is-justify-content-center.is-align-items-center
.has-text-weight-bold
.has-text-weight-bold(class="#{'bg-around-text' if public_account.background.attached?}")
| Account owner: #{public_account.parent.email}
.columns.is-mobile
.column.is-4.px-0.is-flex.is-justify-content-center.is-align-items-center
img src=asset_path(avatar_for(public_account)) class="rounded-avatar" id='image-preview'
img src=asset_path(avatar_for(public_account)) class="rounded-avatar #{'bg-around-image' if public_account.background.attached?}" id='image-preview'
.column.p-0.is-flex.is-justify-content-center.is-align-items-center
.title.has-text-centered.is-black-budgeting-kid-color
.title.has-text-centered.is-black-budgeting-kid-color(class="#{'bg-around-text' if public_account.background.attached?}")
= public_account.name
/ desktop
.column.for-desktop.box.m-2.is-flex.is-justify-content-center.is-align-items-center
Expand All @@ -44,7 +44,7 @@
/ desktop
.columns.for-desktop
.column.transactions.box.m-2
div.m-5
.m-5
.title.is-black-budgeting-kid-color
| Transaction History
- transactions = public_account.transactions.first(3)
Expand All @@ -69,7 +69,7 @@
th
th
.column.goals.box.m-2
div.m-5
.m-5
.columns
.column
.title.is-black-budgeting-kid-color
Expand Down Expand Up @@ -147,7 +147,7 @@
.columns.mb-3.automatic-topup-configs
/ desktop
.column.box.m-2.for-desktop
div.m-5.pb-2 style="border-bottom: 1px solid hsl(0, 0%, 86%)"
.m-5.pb-2 style="border-bottom: 1px solid hsl(0, 0%, 86%)"
.title.is-black-budgeting-kid-color
| Recurring balance increase
.subtitle.is-6.is-vcentered.has-text-dark-gray-budgeting-kid-color
Expand Down