-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
192 lines (179 loc) · 7.86 KB
/
index.html
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Javascript Vanilla Example V2</title>
<link rel="stylesheet" href="./index.css">
<!-- https://docs.flagsmith.com/clients/javascript#via-javascript-cdn -->
<!-- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#defer -->
<script src="https://cdn.jsdelivr.net/npm/flagsmith/index.js" defer></script>
<script src="./main.js" defer></script>
</head>
<body>
<section class="content hidden" id="content">
<div class="header">
<h1>Javascript Vanilla Example</h1>
<button id="js-logout" class="hidden">
Logout
</button>
<button id="js-login">
Login
</button>
</div>
<div class="announcement" id="announcement">
<p>
</p>
</div>
<h2>Instructions</h2>
<ol id="list">
<li>Clone this repository to play with it locally.</li>
<li>Go to <a href="http://app.flagsmith.com/" target="_blank"
rel="noopener noreferrer">app.flagsmith.com</a>, click on Sign Up, and create an account.</li>
<li>Create an Organisation.</li>
<li>Create a Project.</li>
<li>Under the Development environment, create the feature flags listed in the next section. You can continue
the steps after you are done creating all of them. See image 1.</li>
<li>Go to Settings (under your Development environment), Keys, and copy your Client-side Environment Key.
</li>
<li>In the file main.js under the javascript-vanilla-v2 folder, replace the existing environmentID (line 6)
key with yours and save.</li>
<li>Open the index.html under the javascript-vanilla-v2 folder in your browser. Now the example is already
working with your project!</li>
<li>Enable each of the feature flags in your development environment and refresh the app in your browser.
Notice what changed in your app for each feature flag you enabled.</li>
<li>We will now play with some mock identities (there is no real authentication) in our app.
<ul>
<li>Login, type [email protected], Proceed, Logout.</li>
<li>Login, type [email protected], Proceed, Logout.</li>
<li>Login, type [email protected], Proceed, Logout.</li>
</ul>
</li>
<li>Check the Identities (under your Development environment). You should see the Identities created there.
</li>
<li>Now click on the [email protected] identity. Click on the announcement feature. Make sure it is enabled
and change the value to “Welcome, John! Identity override is working!”</li>
<li>Let’s now create a Segment (right under the Project Settings).
<ul>
<li><b>ID:</b> mycompany_employees</li>
<li><b>Description:</b> This is the segment for all my company employees so we can test in
production
later.</li>
<li><b>Trait:</b> email</li>
<li><b>Criteria:</b> Matches regex</li>
<li><b>Value:</b> .*@mycompany\.com</li>
</ul>
</li>
<li>Go back to the Features (under Development environment), click on the announcement feature Segment
Overrides tab, select the mycompany_employees, enable it, and add the value: Welcome, employee! Segment
override is working! See image 2 and 3. You just created a Segment Override for your feature!</li>
<li>Login as [email protected], logout, login as [email protected], logout. Notice the difference in the
announcement banner.</li>
</ol>
<h2>
Feature Flags
</h2>
<table id="features">
<thead>
<tr>
<th>Name</th>
<th>Enabled</th>
<th>Value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>new_button</td>
<td>disabled</td>
<td>empty</td>
<td>This is the “Button 1” in my app</td>
</tr>
<tr>
<td>coloured_button</td>
<td>disabled</td>
<td>#04A596</td>
<td>This is “Button 2” in my app and it will have the background color of whatever is the value in
this feature</td>
</tr>
<tr>
<td>font_size</td>
<td>disabled</td>
<td>18</td>
<td>Font size for the Instructions section</td>
</tr>
<tr>
<td>show_footer_icons</td>
<td>disabled</td>
<td>empty</td>
<td>This flag determines if we will show the footer with the links to our website, documentation,
and GitHub</td>
</tr>
<tr>
<td>announcement</td>
<td>disabled</td>
<td>This is a general announcement for all users</td>
<td>Toggle this to show or hide the announcement on the top of the page</td>
</tr>
<tr>
<td>json_textbox</td>
<td>disabled</td>
<td>{"indent": 4}</td>
<td>Inspect all the feature flags in a textbox in JSON format. The value is itself a JSON from which
we can extract values. Changing the number in the indent will change the format of the JSON.
</td>
</tr>
<tr>
<td>images</td>
<td>enabled</td>
<td>empty</td>
<td>Show the example images</td>
</tr>
</tbody>
</table>
<div id="images">
<h2>Example Images</h2>
<div class="imagesBox">
<img src="./assets/example-1.jpg" alt="Feature Flags Dashboard Example">
<img src="./assets/example-2.jpg" alt="Segments Config Example">
<img src="./assets/example-3.jpg" alt="Identity Override Example">
<img src="./assets/example-4.jpg" alt="Identities Example">
</div>
</div>
<div class="button-box">
<button id="button">
Button 1
</button>
<button id="coloured-button">
Button 2
</button>
</div>
<p class="json" id="json-text-box">
</p>
<div class="links">
<p>
Links
</p>
<div class="icons" id="icons">
<a href="https://flagsmith.com">Flagsmith</a>
<a href="https://docs.flagsmith.com">Docs</a>
<a href="https://github.com/Flagsmith/flagsmith-js-client">Github</a>
</div>
</div>
</section>
<p id="loading">Loading...</p>
<div class="modal hidden" id="modal">
<form id="login-form" method="POST">
<label for="email"> Type Your Email</label>
<input name="email" type="text" id="email" placeholder="Email" required>
<div class="actions">
<button type="button" id="cancel-login">
Cancel
</button>
<button type="submit">
Proceed
</button>
</form>
</div>
</div>
</body>
</html>