Skip to content

Commit f0cdf11

Browse files
committed
qml: Add OutlineButton interaction color animation states
1 parent 5ee9c25 commit f0cdf11

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/qml/controls/OutlineButton.qml

+38-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import QtQuick 2.15
66
import QtQuick.Controls 2.15
77

88
Button {
9+
id: root
910
font.family: "Inter"
1011
font.styleName: "Semi Bold"
1112
font.pixelSize: 18
@@ -17,13 +18,49 @@ Button {
1718
verticalAlignment: Text.AlignVCenter
1819
}
1920
background: Rectangle {
21+
id: bg
2022
implicitHeight: 46
2123
implicitWidth: 340
2224
color: Theme.color.background
2325
radius: 5
26+
state:"DEFAULT"
2427
border {
2528
width: 1
26-
color: Theme.color.neutral4
29+
Behavior on color {
30+
ColorAnimation { duration: 150 }
31+
}
32+
}
33+
34+
states: [
35+
State {
36+
name: "DEFAULT"
37+
PropertyChanges { target: bg; border.color: Theme.color.neutral6}
38+
},
39+
State {
40+
name: "HOVER"
41+
PropertyChanges { target: bg; border.color: Theme.color.neutral9 }
42+
},
43+
State {
44+
name: "PRESSED"
45+
PropertyChanges { target: bg; border.color: Theme.color.orangeLight2 }
46+
}
47+
]
48+
}
49+
MouseArea {
50+
anchors.fill: parent
51+
hoverEnabled: true
52+
onEntered: {
53+
root.background.state = "HOVER"
54+
}
55+
onExited: {
56+
root.background.state = "DEFAULT"
57+
}
58+
onPressed: {
59+
root.background.state = "PRESSED"
60+
}
61+
onReleased: {
62+
root.background.state = "DEFAULT"
63+
root.clicked()
2764
}
2865
}
2966
}

0 commit comments

Comments
 (0)