Skip to content

Commit

Permalink
Constants: add numeric css class (#745)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Feb 11, 2025
1 parent 8b3366d commit fff6d43
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
13 changes: 13 additions & 0 deletions data/granite.metainfo.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@
<update_contact>contact_at_elementary.io</update_contact>

<releases>
<release version="7.7.0" date="2025-02-10" urgency="medium">
<description>
<p>New Features:</p>
<ul>
<li>Granite.CssClass.NUMERIC</li>
</ul>
<p>Improvements:</p>
<ul>
<li>Updated translations</li>
</ul>
</description>
</release>

<release version="7.6.0" date="2024-11-21" urgency="medium">
<description>
<p>New Features:</p>
Expand Down
6 changes: 6 additions & 0 deletions demo/Views/CSSView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public class CSSView : Gtk.Box {
};
header4.add_css_class (Granite.STYLE_CLASS_H4_LABEL);

var numeric = new Gtk.Label ("\"numeric\" Style Class 123.4") {
margin_bottom = 12
};
numeric.add_css_class (Granite.CssClass.NUMERIC);

var card_header = new Granite.HeaderLabel ("Cards and Headers") {
secondary_text = "\"card\" with \"rounded\" and \"checkerboard\" style classes"
};
Expand All @@ -41,6 +46,7 @@ public class CSSView : Gtk.Box {
card.append (header2);
card.append (header3);
card.append (header4);
card.append (numeric);

var richlist_label = new Granite.HeaderLabel ("Lists") {
secondary_text = "\"rich-list\" and \"frame\" style classes"
Expand Down
12 changes: 12 additions & 0 deletions lib/Constants.vala
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,18 @@ namespace Granite {
*/
public const int TRANSITION_DURATION_OPEN = 250;

/**
* CSS style classes to be used with {@link Gtk.Widget.add_css_class}
*/
[Version (since = "7.7.0")]
namespace CssClass {

/**
* sets font features to use tabular numbers. Equivalent of Pango's tnum property
*/
public const string NUMERIC = "numeric";
}

/**
* Deep links to specific Settings pages.
*/
Expand Down
4 changes: 4 additions & 0 deletions lib/Styles/_label.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
opacity: 0.75;
}

.numeric {
font-feature-settings: "tnum";
}

// Intended to match the Pango size of `<small>` and `size='smaller'`
.small-label {
font-size: 0.85em;
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ project(
'granite-7',
'vala', 'c',
meson_version: '>= 0.57.0',
version: '7.6.0'
version: '7.7.0'
)

if meson.get_compiler('vala').version().version_compare('<0.48.0')
Expand Down

0 comments on commit fff6d43

Please sign in to comment.