Add Header Control #100

Manually merged
jarolrod merged 2 commits from headertext-control into main 2022-01-05 19:08:16 +00:00 AGit
jarolrod commented 2022-01-03 06:49:05 +00:00 (Migrated from github.com)

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

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)
jarolrod commented 2022-01-03 16:55:56 +00:00 (Migrated from github.com)

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.
updates from 2fb2611 -> 827abff ([pr100.01](https://github.com/jarolrod/gui-qml/tree/pr100.01) -> [pr100.02](https://github.com/jarolrod/gui-qml/tree/pr100.02), [diff](https://github.com/jarolrod/gui-qml/compare/pr100.01..pr100.02)) 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.
promag (Migrated from github.com) reviewed 2022-01-04 20:34:09 +00:00
promag (Migrated from github.com) left a comment

Tested ACK, but should address the following comments.

Tested ACK, but should address the following comments.
promag (Migrated from github.com) commented 2022-01-04 19:55:59 +00:00

This should be Control and below set contentItem: ColumnLayout {.

This should be `Control` and below set `contentItem: ColumnLayout {`.
promag (Migrated from github.com) commented 2022-01-04 19:56:21 +00:00

Can be removed after previous comment.

Can be removed after previous comment.
promag (Migrated from github.com) commented 2022-01-04 19:56:40 +00:00

Same as above.

Same as above.
promag (Migrated from github.com) commented 2022-01-04 19:57:41 +00:00

This doesn't make sense, sourceComponent.height is not the actual label height. I think you can just drop this line.

This doesn't make sense, `sourceComponent.height` is not the actual label height. I think you can just drop this line.
promag (Migrated from github.com) commented 2022-01-04 19:58:18 +00:00

Should handle description === undefined?

Should handle `description === undefined`?
promag (Migrated from github.com) commented 2022-01-04 20:05:35 +00:00

Should bind visible: active otherwise ColumnLayout will add the spacing (currently it is 0, maybe because of this?)

Should bind `visible: active` otherwise `ColumnLayout` will add the spacing (currently it is 0, maybe because of this?)
promag (Migrated from github.com) commented 2022-01-04 20:08:12 +00:00

Same below.

Same below.
promag (Migrated from github.com) commented 2022-01-04 20:07:52 +00:00

Use root.center.

Use `root.center`.
hebasto (Migrated from github.com) reviewed 2022-01-05 11:20:59 +00:00
hebasto (Migrated from github.com) commented 2022-01-05 11:17:20 +00:00

It needs to be rebased. And then module versions should be x.15.

It needs to be rebased. And then module versions should be `x.15`.
hebasto (Migrated from github.com) reviewed 2022-01-05 13:49:51 +00:00
hebasto (Migrated from github.com) commented 2022-01-05 13:49:50 +00:00

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.

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.
jarolrod commented 2022-01-05 17:58:10 +00:00 (Migrated from github.com)

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
             }
         }
updated from 827abff -> 6aee4e3 rebased and addressed review comments. Here is a diff of the changes on Header.qml: ```diff -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 } } ```
jarolrod (Migrated from github.com) reviewed 2022-01-05 17:58:36 +00:00
jarolrod (Migrated from github.com) commented 2022-01-05 17:58:36 +00:00

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

we'll keep this in mind, but for now leave as is?
jarolrod (Migrated from github.com) reviewed 2022-01-05 17:58:47 +00:00
jarolrod (Migrated from github.com) commented 2022-01-05 17:58:47 +00:00

done

done
jarolrod (Migrated from github.com) reviewed 2022-01-05 17:58:55 +00:00
jarolrod (Migrated from github.com) commented 2022-01-05 17:58:55 +00:00

done

done
jarolrod (Migrated from github.com) reviewed 2022-01-05 17:59:21 +00:00
jarolrod (Migrated from github.com) commented 2022-01-05 17:59:21 +00:00

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

undefined wouldn't have a length greater than zero, so isn't this fine as is?
jarolrod (Migrated from github.com) reviewed 2022-01-05 17:59:28 +00:00
jarolrod (Migrated from github.com) commented 2022-01-05 17:59:28 +00:00

done :D

done :D
promag (Migrated from github.com) reviewed 2022-01-05 18:04:31 +00:00
promag (Migrated from github.com) commented 2022-01-05 18:04:31 +00:00

Accessing length of undefined is an error?

Accessing length of undefined is an error?
promag (Migrated from github.com) reviewed 2022-01-05 18:05:07 +00:00
promag (Migrated from github.com) commented 2022-01-05 18:05:07 +00:00

Agree, not the place to address this.

Agree, not the place to address this.
promag (Migrated from github.com) reviewed 2022-01-05 18:08:10 +00:00
promag (Migrated from github.com) left a comment

Code review ACK 6aee4e3042.

Code review ACK 6aee4e3042b669c17bf03e57fad6da900e4b260c.
promag (Migrated from github.com) reviewed 2022-01-05 19:54:26 +00:00
promag (Migrated from github.com) commented 2022-01-05 19:54:26 +00:00

This could be required property string header.

This could be `required property string header`.
Sign in to join this conversation.
No description provided.