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

Homepage: style banners completely in CSS #2128

Merged
merged 3 commits into from
Mar 19, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 0 additions & 20 deletions data/styles/Banner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,4 @@
color: #{'@banner_fg_color'};
text-shadow: none;
-gtk-icon-shadow: none;

&.card {
border: 1px solid #{'shade(@banner_bg_color, 0.8)'};
box-shadow:
inset 0 0 0 1px #{'alpha(shade(@banner_bg_color, 1.7), 0.05)'},
inset 0 1px 0 0 #{'alpha(shade(@banner_bg_color, 1.7), 0.45)'},
inset 0 -1px 0 0 #{'alpha(shade(@banner_bg_color, 1.7), 0.15)'},
0 3px 2px -1px #{'alpha(shade(@banner_bg_color, 0.5), 0.2)'},
0 3px 5px #{'alpha(shade(@banner_bg_color, 0.5), 0.15)'};
margin: rem(24px);

&:hover {
box-shadow:
inset 0 0 0 1px #{'alpha(shade(@banner_bg_color, 1.7), 0.05)'},
inset 0 1px 0 0 #{'alpha(shade(@banner_bg_color, 1.7), 0.45)'},
inset 0 -1px 0 0 #{'alpha(shade(@banner_bg_color, 1.7), 0.15)'},
0 10px 8px -11px #{'alpha(shade(@banner_bg_color, 0.6), 0.8)'},
0 8px 12px #{'alpha(shade(@banner_bg_color, 0.8), 0.6)'};
}
}
}
56 changes: 56 additions & 0 deletions data/styles/HomePage.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2024 elementary, Inc. (https://elementary.io)
*/

homepage {
.banner {
border: 1px solid #{'shade(@banner_bg_color, 0.8)'};
box-shadow:
inset 0 0 0 1px #{'alpha(shade(@banner_bg_color, 1.7), 0.05)'},
inset 0 1px 0 0 #{'alpha(shade(@banner_bg_color, 1.7), 0.45)'},
inset 0 -1px 0 0 #{'alpha(shade(@banner_bg_color, 1.7), 0.15)'},
0 3px 2px -1px #{'alpha(shade(@banner_bg_color, 0.5), 0.2)'},
0 3px 5px #{'alpha(shade(@banner_bg_color, 0.5), 0.15)'};
margin: rem(24px);
padding: rem(64px) rem(24px);

&:hover {
box-shadow:
inset 0 0 0 1px #{'alpha(shade(@banner_bg_color, 1.7), 0.05)'},
inset 0 1px 0 0 #{'alpha(shade(@banner_bg_color, 1.7), 0.45)'},
inset 0 -1px 0 0 #{'alpha(shade(@banner_bg_color, 1.7), 0.15)'},
0 10px 8px -11px #{'alpha(shade(@banner_bg_color, 0.6), 0.8)'},
0 8px 12px #{'alpha(shade(@banner_bg_color, 0.8), 0.6)'};
}

image {
-gtk-icon-size: rem(128px);
margin-left: -12px; /*Offset space inside icon*/;
margin-right: -12px; /*Offset space inside icon*/;
}

> box {
border-spacing: rem(24px);
}

label.name {
font-size: 3rem;
font-weight: 700;
letter-spacing: -0.04em;
margin-bottom: -0.1em;
}

label.summary {
font-size: 1.25rem;
font-weight: 400;
letter-spacing: -0.035em;
margin-bottom: 0.75em;
}

label.description {
font-size: 0.95rem;
opacity: 0.85;
}
}
}
1 change: 1 addition & 0 deletions data/styles/Index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
@import 'AppInfoView.scss';
@import 'Banner.scss';
@import 'Category.scss';
@import 'HomePage.scss';
@import 'MainWindow.scss';
@import 'ProgressButton.scss';
4 changes: 4 additions & 0 deletions src/Views/Homepage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public class AppCenter.Homepage : Adw.NavigationPage {

private uint banner_timeout_id;

class construct {
set_css_name ("homepage");
}

construct {
add_css_class (Granite.STYLE_CLASS_VIEW);
hexpand = true;
Expand Down
31 changes: 15 additions & 16 deletions src/Widgets/Banner.vala
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public class AppCenter.Widgets.Banner : Gtk.Button {
wrap = true,
xalign = 0
};
name_label.add_css_class (Granite.STYLE_CLASS_H1_LABEL);
name_label.add_css_class ("name");

var summary_label = new Gtk.Label (package.get_summary ()) {
max_width_chars = 50,
use_markup = true,
wrap = true,
xalign = 0
};
summary_label.add_css_class (Granite.STYLE_CLASS_H3_LABEL);
summary_label.add_css_class ("summary");

string description = "";
if (package.get_description () != null) {
Expand All @@ -64,32 +64,31 @@ public class AppCenter.Widgets.Banner : Gtk.Button {
wrap = true,
xalign = 0
};
description_label.add_css_class ("description");

var icon_image = new Gtk.Image.from_gicon (
package.get_icon (128, get_scale_factor ())
) {
pixel_size = 128
};
);

var package_grid = new Gtk.Grid () {
column_spacing = 24,
halign = Gtk.Align.CENTER,
margin_bottom = 64,
margin_top = 64,
valign = Gtk.Align.CENTER
var inner_box = new Gtk.Box (VERTICAL, 0) {
valign = CENTER
};
inner_box.append (name_label);
inner_box.append (summary_label);
inner_box.append (description_label);

package_grid.attach (icon_image, 0, 0, 1, 3);
package_grid.attach (name_label, 1, 0);
package_grid.attach (summary_label, 1, 1);
package_grid.attach (description_label, 1, 2);
var outer_box = new Gtk.Box (HORIZONTAL, 0) {
halign = CENTER
};
outer_box.append (icon_image);
outer_box.append (inner_box);

add_css_class ("banner");
add_css_class (Granite.STYLE_CLASS_CARD);
add_css_class (Granite.STYLE_CLASS_ROUNDED);

hexpand = true;
child = package_grid;
child = outer_box;

var provider = new Gtk.CssProvider ();
try {
Expand Down