-
Notifications
You must be signed in to change notification settings - Fork 46
/
button.html
247 lines (232 loc) · 8.82 KB
/
button.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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<!DOCTYPE html>
<html>
<head>
<title>Button</title>
<link rel="stylesheet" href="./button.css">
<link rel="stylesheet" href="./button-group.css">
<link rel="stylesheet" href="./progress.css">
<style>
/* these styles are purely demonstration related styles only */
body {
width: 450px;
margin: 40px auto;
}
h3 {
font-weight: 300;
}
div {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-bottom: 40px;
}
.progressBar {
margin-bottom: 24px;
}
/**
* Button Icons -- We've elected to consider button icons as dependency injected children,
* so, in React that means they're just an arbitrary part of `{ children }`, in Svelte and
* Vue they're just a part of the `<slot />`. Therefore, styling of these are left to the
* consumer of AgnosticUI.
*/
.btn-icon-left {
margin-right: 6px;
}
.btn-icon-right {
margin-left: 6px;
}
</style>
<!-- Breaking these up to make it easier to index the sheet from the dynamic JavaScript below ;) -->
<style>
/* These are some agnostic button defs with --agnosticui-default- replaced with --agnosticui-.
* That's the naming convention for any available css property overrides. The goal is to
* use JavaScript to update them dynamically to, essentially, do real-time theming :)
*/
:root {
--agnosticui-btn-bgcolor: #e9e9e9;
--agnosticui-btn-raised-from: #f8f8f8;
--agnosticui-btn-raised-to: #d8d8d8;
--agnosticui-btn-primary-raised-from: #34a5f8;
--agnosticui-btn-primary-raised-to: #088ef0;
--agnosticui-btn-primary-raised-hover-from: #42abf8;
--agnosticui-btn-secondary-raised-from: #ff5d69;
--agnosticui-btn-secondary-raised-to: #ff2a39;
--agnosticui-btn-secondary-raised-hover-from: #ff6c77;
--agnosticui-btn-disabled-bg: #cccccc;
--agnosticui-btn-disabled-border: #bbbbbb;
--agnosticui-btn-disabled-color: #aaaaaa;
--agnosticui-btn-font-color: #333333;
--agnosticui-btn-font-weight: 300;
--agnosticui-btn-font-size: 16px;
--agnosticui-btn-side-padding: calc(1.5 * var(--agnosticui-btn-font-size));
--agnosticui-btn-line-height: 2.5;
--agnosticui-btn-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Ubuntu", "Fira Sans", Helvetica, "Droid Sans", "Helvetica Neue", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
--agnosticui-btn-primary: #1087db;
--agnosticui-btn-primary-color: #ffffff;
--agnosticui-btn-secondary: #ff4351;
--agnosticui-btn-secondary-color: #ffffff;
--agnosticui-btn-radius: 4px;
--agnosticui-progress-fill-color: #1087db;
--agnosticui-progress-background: #ededed
}
</style>
</head>
<body>
<div>
<h1>Buttons</h1>
</div>
<div>
<h3>Toggle Theme</h3>
<p>If you click the fancy button below, JavaScript behind the scenes will dynamically update the
<i>--agnosticui-*</i> custom CSS properties (which you can see if you open devtools and simply look at the
<i>html</i> element!). You can do the same to theme your components!</p>
<div class="btn-group" role="group" aria-label="Button group example">
<button class="btn btn-primary btn-bordered" onclick="switchToFancy()">Fancy</button>
<button class="btn btn-primary btn-bordered" onclick="switchBackToOriginal()">Original</button>
</div>
</div>
<div>
<h3>Natural</h3>
<button class="btn">Go</button>
</div>
<div>
<h3>Natural Rounded</h3>
<button class="btn btn-rounded">Go</button>
</div>
<div>
<h3>Natural Raised</h3>
<button class="btn btn-raised btn-rounded">Go</button>
</div>
<div>
<h3>Primary</h3>
<button class="btn btn-primary">Go</button>
</div>
<div>
<h3>Primary Rounded</h3>
<button class="btn btn-primary btn-rounded">Go</button>
</div>
<div>
<h3>Primary Raised</h3>
<button class="btn btn-raised btn-primary btn-rounded">Go</button>
</div>
<div>
<h3>Primary Bordered</h3>
<button class="btn btn-primary btn-rounded btn-bordered">Go</button>
</div>
<div>
<h3>Secondary</h3>
<button class="btn btn-secondary btn-rounded">Go</button>
</div>
<div>
<h3>Secondary Raised</h3>
<button class="btn btn-raised btn-secondary btn-rounded">Go</button>
</div>
<div>
<h3>Secondary Bordered</h3>
<button class="btn btn-secondary btn-rounded btn-bordered">Go</button>
</div>
<div>
<h3>Circle</h3>
<button class="btn btn-primary btn-circle btn-circle-small">Go</button>
<button class="btn btn-secondary btn-circle">Go</button>
<button class="btn btn-primary btn-circle btn-circle-large">Go</button>
</div>
<div>
<h3>Block (Stacked)</h3>
<button class="btn btn-block btn-bordered">Go</button>
<button class="btn btn-block btn-secondary">Go</button>
<button class="btn btn-block btn-primary">Go</button>
</div>
<div>
<h3>Button Icon Left</h3>
<button class="btn btn-primary btn-rounded">
<svg class="btn-icon-left" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true">
<path fill="currentColor" fill-rule="evenodd"
d="M9 12h2l-3 3-3-3h2V7h2v5zm3-8c0-.44-.91-3-4.5-3C5.08 1 3 2.92 3 5 1.02 5 0 6.52 0 8c0 1.53 1 3 3 3h3V9.7H3C1.38 9.7 1.3 8.28 1.3 8c0-.17.05-1.7 1.7-1.7h1.3V5c0-1.39 1.56-2.7 3.2-2.7 2.55 0 3.13 1.55 3.2 1.8v1.2H12c.81 0 2.7.22 2.7 2.2 0 2.09-2.25 2.2-2.7 2.2h-2V11h2c2.08 0 4-1.16 4-3.5C16 5.06 14.08 4 12 4z">
</path>
</svg> Download</button>
</div>
<div>
<h3>Button Icon Right</h3>
<button class="btn btn-primary btn-rounded">
Call
<svg class="btn-icon-right" stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24"
data-custom-icon="true" focusable="false" aria-hidden="true" class="css-1fz80kc" height="1em" width="1em"
xmlns="http://www.w3.org/2000/svg">
<path
d="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z">
</path>
</svg>
</button>
</div>
<script>
// Here are the rest of the buttton properties (at time of writing):
// btn_disabled_bg: '#cccccc',
// btn_disabled_border: '#bbbbbb',
// btn_disabled_color: '#aaaaaa',
// btn_primary_color: '#ffffff',
// btn_secondary_color: '#ffffff',
// btn_radius: '4px'
const originalAgnosticProps = {
btn_font_color: '#333333',
btn_font_family: '-apple-system, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Ubuntu", "Fira Sans", Helvetica, "Droid Sans", "Helvetica Neue", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
btn_font_weight: '300',
btn_line_height: '2.5',
btn_bgcolor: '#e9e9e9',
btn_radius: '4px',
btn_raised_from: '#f8f8f8',
btn_raised_to: '#d8d8d8',
btn_primary_raised_from: '#34a5f8',
btn_primary_raised_to: '#088ef0',
btn_primary_raised_hover_from: '#42abf8',
btn_secondary_raised_from: '#ff5d69',
btn_secondary_raised_to: '#ff2a39',
btn_secondary_raised_hover_from: '#ff6c77',
btn_font_size: '16px',
btn_side_padding: 'calc(1.5 * var(--agnosticui-btn-font-size))',
btn_primary: '#1087db',
btn_secondary: '#ff4351',
progress_fill_color: '#1087db',
progress_height: '10px',
}
const fancyAgnosticProps = {
btn_font_family: 'Calibri, Candara, Optima, "Trebuchet MS", "Lucida Grande", sans-serif',
btn_font_color: '#152c36',
btn_font_weight: '100',
btn_line_height: '3',
btn_bgcolor: '#dddddd',
btn_radius: '3px',
btn_raised_from: '#eeeeee',
btn_raised_to: '#cccccc',
btn_primary_raised_from: '#fada6f',
btn_primary_raised_to: '#c59908',
btn_primary_raised_hover_from: '#fce189',
btn_secondary_raised_from: '#a273f8',
btn_secondary_raised_to: '#703ad4',
btn_secondary_raised_hover_from: '#ceb6fc',
btn_font_size: '18px',
btn_side_padding: 'calc(2 * var(--agnosticui-btn-font-size))',
btn_primary: '#dbac10',
btn_secondary: '#8d52fa',
progress_fill_color: '#8d52fa',
progress_height: '14px',
}
const enableTheme = (theme) => {
const prefix = '--agnosticui-'
const docElement = document.documentElement;
Object.keys(theme).forEach(key => {
const hyphenated = key.replace(/_/g, '-');
const v = `${theme[key]}`;
document.documentElement.style.setProperty(`${prefix}${hyphenated}`, v);
});
}
const switchToFancy = ev => {
enableTheme(fancyAgnosticProps)
}
const switchBackToOriginal = ev => {
enableTheme(originalAgnosticProps)
}
</script>
</body>
</html>