feat(StatusBanner): introduce type variants for different banner styles
* feat(sandbox/controls): Added StatusBanner component in controls view In order to test StatusBanner.qml ui component it has been added into the Sandbox app as another Control. * chore(sandbox/controls): Refactor `StatusBanner' component Create enum to allow selecting StatusBanner type (`Info`, `Danger`, `Success`, `Warning`). Add new success color with some opacity in ThemePalette. * chore(Controls/StatusBanner): Use states instead of function To have a cleaner code, it has been added states to manage type property changes. * chore(Controls/StatusBanner): Remove unnecessary stuff Remove unnecessary name property. Remove successColor3 property.
This commit is contained in:
parent
14ab4ce52d
commit
35d12f444d
|
@ -188,4 +188,12 @@ GridLayout {
|
||||||
to: 100
|
to: 100
|
||||||
value: 40
|
value: 40
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatusBanner {
|
||||||
|
id: banner
|
||||||
|
width: 360
|
||||||
|
topPadding: 20
|
||||||
|
type: StatusBanner.Type.Danger
|
||||||
|
statusText: "Banner"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,45 @@
|
||||||
import QtQuick 2.14
|
import QtQuick 2.14
|
||||||
|
|
||||||
import StatusQ.Core 0.1
|
import StatusQ.Core 0.1
|
||||||
|
import StatusQ.Core.Theme 0.1
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: statusBanner
|
id: statusBanner
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
property color backgroundColor
|
|
||||||
property color bordersColor
|
|
||||||
property color fontColor
|
|
||||||
property string statusText
|
property string statusText
|
||||||
|
property int type: StatusBanner.Type.Info
|
||||||
property int textPixels: 15
|
property int textPixels: 15
|
||||||
property int statusBannerHeight: 38
|
property int statusBannerHeight: 38
|
||||||
|
|
||||||
|
// "private" properties
|
||||||
|
QtObject {
|
||||||
|
id: d
|
||||||
|
property color backgroundColor
|
||||||
|
property color bordersColor
|
||||||
|
property color fontColor
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Type {
|
||||||
|
Info, // 0
|
||||||
|
Danger, // 1
|
||||||
|
Success, // 2
|
||||||
|
Warning // 3
|
||||||
|
}
|
||||||
|
|
||||||
|
// Component definition
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: topDiv
|
id: topDiv
|
||||||
color: statusBanner.bordersColor
|
color: d.bordersColor
|
||||||
height: 1
|
height: 1
|
||||||
width: parent.width
|
width: parent.width
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status banner content:
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: statusBox
|
id: box
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: statusBanner.statusBannerHeight
|
height: statusBanner.statusBannerHeight
|
||||||
color: statusBanner.backgroundColor
|
color: d.backgroundColor
|
||||||
|
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
id: statusTxt
|
id: statusTxt
|
||||||
|
@ -34,14 +48,42 @@ Column {
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
font.pixelSize: statusBanner.textPixels
|
font.pixelSize: statusBanner.textPixels
|
||||||
text: statusBanner.statusText
|
text: statusBanner.statusText
|
||||||
color: statusBanner.fontColor
|
color: d.fontColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: bottomDiv
|
id: bottomDiv
|
||||||
color: statusBanner.bordersColor
|
color: d.bordersColor
|
||||||
height: 1
|
height: 1
|
||||||
width: parent.width
|
width: parent.width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Behavior
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
when: statusBanner.type === StatusBanner.Type.Info
|
||||||
|
PropertyChanges { target: d; backgroundColor: Theme.palette.primaryColor3}
|
||||||
|
PropertyChanges { target: d; bordersColor: Theme.palette.primaryColor2}
|
||||||
|
PropertyChanges { target: d; fontColor: Theme.palette.primaryColor1}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
when: statusBanner.type === StatusBanner.Type.Danger
|
||||||
|
PropertyChanges { target: d; backgroundColor: Theme.palette.dangerColor3}
|
||||||
|
PropertyChanges { target: d; bordersColor: Theme.palette.dangerColor2}
|
||||||
|
PropertyChanges { target: d; fontColor: Theme.palette.dangerColor1}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
when: statusBanner.type === StatusBanner.Type.Success
|
||||||
|
PropertyChanges { target: d; backgroundColor: Theme.palette.successColor2}
|
||||||
|
PropertyChanges { target: d; bordersColor: Theme.palette.successColor2}
|
||||||
|
PropertyChanges { target: d; fontColor: Theme.palette.successColor1}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
when: statusBanner.type === StatusBanner.Type.Warning
|
||||||
|
PropertyChanges { target: d; backgroundColor: Theme.palette.pinColor3}
|
||||||
|
PropertyChanges { target: d; bordersColor: Theme.palette.pinColor2}
|
||||||
|
PropertyChanges { target: d; fontColor: Theme.palette.pinColor1}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue