forked from fuse-open/fuse-samples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDropdownMenu.ux
83 lines (67 loc) · 2.93 KB
/
DropdownMenu.ux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<Panel ux:Class="DropdownMenu" ux:Name="menu" BackgroundColor="#FDFDFD" BorderColor="#BFBFBF" TextColor="#000000" FontSize="14">
<!-- PROPERTIES -->
<object ux:Property="ListItems" />
<string ux:Property="Selected" />
<float4 ux:Property="TextColor" />
<Brush ux:Property="BackgroundColor" />
<Brush ux:Property="BorderColor" />
<float ux:Property="FontSize" />
<!-- JAVASCRIPT -->
<JavaScript>
var Observable = require('FuseJS/Observable');
var selected = Observable();
function onSelected(arg) {
if(arg.data && arg.data.name) {
selected.value = arg.data.name;
}
}
module.exports = {
selected: selected,
onSelected: onSelected
}
</JavaScript>
<!-- THE LIST PANEL (when dropdown is open) -->
<Panel ux:Class="DropdownOption" ux:Name="self" Height="30" >
<string ux:Property="Text" />
<Brush ux:Property="BackgroundColor" />
<Brush ux:Property="BorderColor" />
<float ux:Property="FontSize" />
<float4 ux:Property="TextColor" />
<Rectangle Layer="Background" ux:Name="bgCol" Fill="{ReadProperty self.BackgroundColor}">
<Stroke Brush="{ReadProperty self.BorderColor}" Width="1" />
</Rectangle>
<Text Margin="10,0,0,0" Alignment="CenterLeft" Value="{ReadProperty self.Text}" FontSize="{ReadProperty self.FontSize}" Color="{ReadProperty self.TextColor}" />
</Panel>
<!-- THE FIRST PANEL (when dropdown is closed) -->
<Panel Clicked="{onSelected}" ux:Class="DropdownSelectedItem" ux:Name="self" Height="40" >
<string ux:Property="Text" />
<Brush ux:Property="BackgroundColor" />
<Brush ux:Property="BorderColor" />
<float ux:Property="FontSize" />
<float4 ux:Property="TextColor" />
<Text Margin="10,0,0,0" FontSize="{ReadProperty self.FontSize}" Color="{ReadProperty self.TextColor}" Alignment="CenterLeft" Value="{ReadProperty self.Text}" />
<Panel Layer="Background">
<Rectangle Layer="Background" Fill="{ReadProperty self.BackgroundColor}" Height="100%" Alignment="Top">
<!--Stroke Brush="{ReadProperty self.BorderColor}" Width="1" /-->
</Rectangle>
</Panel>
</Panel>
<!-- PANEL CONTAINING EVERYTHING -->
<Panel Width="200" Height="40">
<DataBinding Target="menu.Selected" Key="selected" />
<Rectangle>
<Stroke Brush="{ReadProperty menu.BorderColor}" Width="1" />
</Rectangle>
<DropdownSelectedItem TextColor="{ReadProperty menu.TextColor}" FontSize="{ReadProperty menu.FontSize}" Text="{selected}" BackgroundColor="{ReadProperty menu.BackgroundColor}" BorderColor="{ReadProperty menu.BorderColor}" />
<Clicked>
<Toggle Target="expandDropdown" />
</Clicked>
<WhileTrue ux:Name="expandDropdown">
<StackPanel Offset="0,40" >
<Each Items="{ReadProperty menu.ListItems}" >
<DropdownOption FontSize="{ReadProperty menu.FontSize}" TextColor="{ReadProperty menu.TextColor}" Text="{name}" BackgroundColor="{ReadProperty menu.BackgroundColor}" Clicked="{onSelected}" BorderColor="{ReadProperty menu.BorderColor}" />
</Each>
</StackPanel>
</WhileTrue>
</Panel>
</Panel>