Skip to content

Add Header Control#100

Merged
hebasto merged 2 commits into
bitcoin-core:mainfrom
jarolrod:headertext-control
Jan 5, 2022
Merged

Add Header Control#100
hebasto merged 2 commits into
bitcoin-core:mainfrom
jarolrod:headertext-control

Conversation

@jarolrod
Copy link
Copy Markdown
Contributor

@jarolrod jarolrod commented Jan 3, 2022

This introduces and demos the Header control. This component is to be used as the main text component for wizard pages; it implements the style for wizard text set in the main design file. It's properties allows for a good level of customization, so this can be extended to any page (wizard or not) that needs a header.

The header control consists of a required header text, and optional description and subtext strings. This allows the control to be reused for all currently designed wizard pages. The description label will only be shown if the description property is given a value. Similarly, the subtext label will only be shown if the subtext property is given a value.

The bold, headerSize, descriptionSize, descriptionMargin and subtextSize properties have been given default values that represent the most common sizes in our wizard pages. Looking at the designed wizard pages; All headers have a size of 28 except the first one. Also, only one header is bold. Therefore, the bold property has been given a default value of false and headerSize a default value of 28. Similarly, all descriptions have a size of 18 and a margin of 10 except the first one; set 18 as default value for descriptionSize and 10 as default value for descriptionMargin. There is only one page with subtext, and it sets the size for the subtext to 15; set the default value for subtextSize to 15.

This means that the code to represent header text can be condensed. For example, the following code represents the header text for the onboarding connections page:

Header {
    header: "Connections"
    description: "Communicating with the Bitcoin network can use a lot of data."
}

The diagram below shows a breakdown of the control and how it works/example usage:

header-diagram-png

Windows
macOS
Android

@jarolrod jarolrod force-pushed the headertext-control branch from 2fb2611 to 827abff Compare January 3, 2022 16:51
@jarolrod
Copy link
Copy Markdown
Contributor Author

jarolrod commented Jan 3, 2022

updates from 2fb2611 -> 827abff (pr100.01 -> pr100.02, diff)

changes:

  • enable word wrapping
  • allow for choosing between text that is aligned to the left or centered through the addition of a center property. This property defaults to true. This will allow this control to be used as the main text for the connections detailed settings page.

Copy link
Copy Markdown
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK, but should address the following comments.

Comment thread src/qml/controls/Header.qml Outdated
Comment thread src/qml/controls/Header.qml Outdated
Comment thread src/qml/controls/Header.qml Outdated
Comment thread src/qml/controls/Header.qml Outdated
height: sourceComponent.height
Layout.fillWidth: true
Layout.preferredWidth: 0
active: root.description.length > 0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should handle description === undefined?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined wouldn't have a length greater than zero, so isn't this fine as is?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accessing length of undefined is an error?

Comment thread src/qml/controls/Header.qml
Comment thread src/qml/controls/Header.qml Outdated
Comment thread src/qml/controls/Header.qml Outdated
font.family: "Inter"
font.styleName: root.bold ? "Semi Bold" : "Regular"
font.pointSize: root.headerSize
color: "#FFFFFF"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://bitcoindesign.slack.com/archives/C026F9QF79B/p1641383578276800?thread_ts=1641381552.272700&cid=C026F9QF79B:

Yes please, names are better. I'd recommend using two types. First, descriptive ones like red, blue, green. Then, functional ones like primary, accent, error, success, neutral, etc to which the descriptive ones are assigned. Then you’d only reference the functional ones in the code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll keep this in mind, but for now leave as is?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, not the place to address this.

@jarolrod jarolrod force-pushed the headertext-control branch from 06bc708 to 6aee4e3 Compare January 5, 2022 17:51
@jarolrod
Copy link
Copy Markdown
Contributor Author

jarolrod commented Jan 5, 2022

updated from 827abff -> 6aee4e3

rebased and addressed review comments. Here is a diff of the changes on Header.qml:

-import QtQuick 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Layouts 1.11
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Layouts 1.15
 
-Item {
+Control {
     id: root
     property bool bold: false
     property bool center: true
@@ -19,10 +19,8 @@ Item {
     property string subtext
     property int subtextMargin
     property int subtextSize: 15
-    implicitHeight: childrenRect.height
-    ColumnLayout {
+    contentItem: ColumnLayout {
         spacing: 0
-        width: parent.width
         Label {
             Layout.fillWidth: true
             Layout.preferredWidth: 0
@@ -36,10 +34,10 @@ Item {
             wrapMode: Text.WordWrap
         }
         Loader {
-            height: sourceComponent.height
             Layout.fillWidth: true
             Layout.preferredWidth: 0
             active: root.description.length > 0
+            visible: active
             sourceComponent: Label {
                 topPadding: root.descriptionMargin
                 font.family: "Inter"
@@ -47,15 +45,15 @@ Item {
                 font.pointSize: root.descriptionSize
                 color: "#DEDEDE"
                 text: root.description
-                horizontalAlignment: center ? Text.AlignHCenter : Text.AlignLeft
+                horizontalAlignment: root.center ? Text.AlignHCenter : Text.AlignLeft
                 wrapMode: Text.WordWrap
             }
         }
         Loader {
-            height: sourceComponent.height
             Layout.fillWidth: true
             Layout.preferredWidth: 0
             active: root.subtext.length > 0
+            visible: active
             sourceComponent: Label {
                 topPadding: root.subtextMargin
                 font.family: "Inter"
@@ -63,7 +61,7 @@ Item {
                 font.pixelSize: root.subtextSize
                 color: "#FFFFFF"
                 text: root.subtext
-                horizontalAlignment: center ? Text.AlignHCenter : Text.AlignLeft
+                horizontalAlignment: root.center ? Text.AlignHCenter : Text.AlignLeft
                 wrapMode: Text.WordWrap
             }
         }

Copy link
Copy Markdown
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK 6aee4e3.

@hebasto hebasto merged commit 89808d7 into bitcoin-core:main Jan 5, 2022
id: root
property bool bold: false
property bool center: true
property string header
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be required property string header.

hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Jun 6, 2025
hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Jun 6, 2025
hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Jun 7, 2025
hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Jun 7, 2025
hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Jun 7, 2025
hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Jun 7, 2025
hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Jun 8, 2025
hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Jun 8, 2025
hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Jun 8, 2025
hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Jun 8, 2025
hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Jun 9, 2025
hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Jun 9, 2025
hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Jun 9, 2025
hebasto pushed a commit to hebasto/gui-qml that referenced this pull request Jun 9, 2025
johnny9 pushed a commit to johnny9/bitcoin-core-app that referenced this pull request Jul 4, 2025
11755e8 qml: demo Header control (jarolrod)
c3b55c1 qml: introduce Header qml control (jarolrod)

Pull request description:

  This introduces and demos the `Header` control. This component is to be used as the main text component for wizard pages; it implements the style for [wizard text](https://www.figma.com/file/GaCoOSNHB2yMB9ThiDtred/Bitcoin-Core-App-Main?node-id=2777%3A66555) set in the [main design file](https://www.figma.com/file/GaCoOSNHB2yMB9ThiDtred/Bitcoin-Core-App-Main?node-id=1035%3A1883). It's properties allows for a good level of customization, so this can be extended to any page (wizard or not) that needs a header.

  The `header` control consists of a required **header** text, and optional **description** and **subtext** strings. This allows the control to be reused for all currently designed wizard pages. The **description** label will only be shown if the `description` property is given a value. Similarly, the **subtext** label will only be shown if the `subtext` property is given a value.

  The `bold`, `headerSize`, `descriptionSize`, `descriptionMargin` and `subtextSize` properties have been given default values that represent the most common sizes in our wizard pages. Looking at the designed wizard pages; All headers have a size of 28 except the first one. Also, only one header is bold. Therefore, the `bold` property has been given a default value of false and `headerSize` a default value of 28. Similarly, all descriptions have a size of 18 and a margin of 10 except the first one; set 18 as default value for `descriptionSize` and 10 as default value for `descriptionMargin`. There is only one page with subtext, and it sets the size for the subtext to 15; set the default value for `subtextSize` to 15.

  This means that the code to represent header text can be condensed. For example, the following code represents the header text for the [onboarding connections page](https://www.figma.com/file/GaCoOSNHB2yMB9ThiDtred/Bitcoin-Core-App-Main?node-id=2777%3A66830):

  ```qml

  Header {
      header: "Connections"
      description: "Communicating with the Bitcoin network can use a lot of data."
  }
  ```

  The diagram below shows a breakdown of the control and how it works/example usage:

  ![header-diagram-png](https://user-images.githubusercontent.com/23396902/147905255-e3cd145e-6e09-41ff-8a2f-f287bfd8c478.png)

  [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/100)
  [![macOS](https://img.shields.io/badge/OS-macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/100)
  [![Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/100)

ACKs for top commit:
  promag:
    Code review ACK 11755e8.

Tree-SHA512: c24246bb24cb557d9189f1292839c59c7bc28220fedda2f084e6d65329390c8796be14c3df7964c09e71afa8098795112518153c8c882888d4a328f3216abd04
tx-signer450 added a commit to tx-signer450/gui-qml that referenced this pull request Oct 20, 2025
11755e87b8f5359b45987e515ce20a318ac5d1de qml: demo Header control (jarolrod)
c3b55c122f0f8fd270128bae32884d11eb24875c qml: introduce Header qml control (jarolrod)

Pull request description:

  This introduces and demos the `Header` control. This component is to be used as the main text component for wizard pages; it implements the style for [wizard text](https://www.figma.com/file/GaCoOSNHB2yMB9ThiDtred/Bitcoin-Core-App-Main?node-id=2777%3A66555) set in the [main design file](https://www.figma.com/file/GaCoOSNHB2yMB9ThiDtred/Bitcoin-Core-App-Main?node-id=1035%3A1883). It's properties allows for a good level of customization, so this can be extended to any page (wizard or not) that needs a header.

  The `header` control consists of a required **header** text, and optional **description** and **subtext** strings. This allows the control to be reused for all currently designed wizard pages. The **description** label will only be shown if the `description` property is given a value. Similarly, the **subtext** label will only be shown if the `subtext` property is given a value.

  The `bold`, `headerSize`, `descriptionSize`, `descriptionMargin` and `subtextSize` properties have been given default values that represent the most common sizes in our wizard pages. Looking at the designed wizard pages; All headers have a size of 28 except the first one. Also, only one header is bold. Therefore, the `bold` property has been given a default value of false and `headerSize` a default value of 28. Similarly, all descriptions have a size of 18 and a margin of 10 except the first one; set 18 as default value for `descriptionSize` and 10 as default value for `descriptionMargin`. There is only one page with subtext, and it sets the size for the subtext to 15; set the default value for `subtextSize` to 15.

  This means that the code to represent header text can be condensed. For example, the following code represents the header text for the [onboarding connections page](https://www.figma.com/file/GaCoOSNHB2yMB9ThiDtred/Bitcoin-Core-App-Main?node-id=2777%3A66830):

  ```qml

  Header {
      header: "Connections"
      description: "Communicating with the Bitcoin network can use a lot of data."
  }
  ```

  The diagram below shows a breakdown of the control and how it works/example usage:

  ![header-diagram-png](https://user-images.githubusercontent.com/23396902/147905255-e3cd145e-6e09-41ff-8a2f-f287bfd8c478.png)

  [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/100)
  [![macOS](https://img.shields.io/badge/OS-macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/100)
  [![Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/100)

ACKs for top commit:
  promag:
    Code review ACK 11755e87b8f5359b45987e515ce20a318ac5d1de.

Tree-SHA512: c24246bb24cb557d9189f1292839c59c7bc28220fedda2f084e6d65329390c8796be14c3df7964c09e71afa8098795112518153c8c882888d4a328f3216abd04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants