create-basicjs 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bin/create-basicjs.js +31 -4
- package/bin/verify-package.js +1 -1
- package/package.json +2 -2
- package/payload/starter/AGENTS.md +11 -6
- package/payload/starter/README.md +1 -1
- package/payload/starter/_basic/VERSION +1 -1
- package/payload/starter/_basic/assets/cards/almond-blossom.png +0 -0
- package/payload/starter/_basic/assets/cards/blackberry.png +0 -0
- package/payload/starter/_basic/assets/cards/borage.png +0 -0
- package/payload/starter/_basic/assets/cards/chamomile.png +0 -0
- package/payload/starter/_basic/assets/cards/dill.png +0 -0
- package/payload/starter/_basic/assets/cards/eucalyptus.png +0 -0
- package/payload/starter/_basic/assets/cards/fennel.png +0 -0
- package/payload/starter/_basic/assets/cards/fig.png +0 -0
- package/payload/starter/_basic/assets/cards/juniper.png +0 -0
- package/payload/starter/_basic/assets/cards/lavender.png +0 -0
- package/payload/starter/_basic/assets/cards/lemon.png +0 -0
- package/payload/starter/_basic/assets/cards/olives.png +0 -0
- package/payload/starter/_basic/assets/cards/oregano.png +0 -0
- package/payload/starter/_basic/assets/cards/pepper.png +0 -0
- package/payload/starter/_basic/assets/cards/physalis.png +0 -0
- package/payload/starter/_basic/assets/cards/pomegranate.png +0 -0
- package/payload/starter/_basic/assets/cards/poppy.png +0 -0
- package/payload/starter/_basic/assets/cards/rosehip.png +0 -0
- package/payload/starter/_basic/assets/cards/saffron.png +0 -0
- package/payload/starter/_basic/assets/categories/cappuccino.png +0 -0
- package/payload/starter/_basic/assets/categories/chocolate-milk.png +0 -0
- package/payload/starter/_basic/assets/categories/coffee.png +0 -0
- package/payload/starter/_basic/assets/categories/frappe.png +0 -0
- package/payload/starter/_basic/assets/categories/iced-caffee.png +0 -0
- package/payload/starter/_basic/assets/categories/milkshake.png +0 -0
- package/payload/starter/_basic/assets/categories/orange-juice.png +0 -0
- package/payload/starter/_basic/assets/categories/tea.png +0 -0
- package/payload/starter/_basic/assets/fruids/brokoli.png +0 -0
- package/payload/starter/_basic/assets/fruids/cilek.png +0 -0
- package/payload/starter/_basic/assets/fruids/domates.png +0 -0
- package/payload/starter/_basic/assets/fruids/elma.png +0 -0
- package/payload/starter/_basic/assets/fruids/havuc.png +0 -0
- package/payload/starter/_basic/assets/fruids/karpuz.png +0 -0
- package/payload/starter/_basic/assets/fruids/limon.png +0 -0
- package/payload/starter/_basic/assets/fruids/muz.png +0 -0
- package/payload/starter/_basic/assets/fruids/nar.png +0 -0
- package/payload/starter/_basic/assets/fruids/patlican.png +0 -0
- package/payload/starter/_basic/assets/fruids/yabanmersini.png +0 -0
- package/payload/starter/_basic/assets/fruids/yesilbiber.png +0 -0
- package/payload/starter/_basic/basic/LICENSE +1 -1
- package/payload/starter/_basic/basic/basic.css +3 -6
- package/payload/starter/_basic/basic/basic.js +154 -60
- package/payload/starter/_basic/basic/basic.min.js +19 -6
- package/payload/starter/_basic/basic/scroll-bar.js +4 -2
- package/payload/starter/_basic/basic/scroll-bar.min.js +1 -0
- package/payload/starter/_basic/comp/accordion.js +659 -0
- package/payload/starter/_basic/comp/action-button.js +22 -23
- package/payload/starter/_basic/comp/action-tab-bar.js +8 -8
- package/payload/starter/_basic/comp/app-bar.js +12 -11
- package/payload/starter/_basic/comp/{badge-v2.js → badge.js} +51 -5
- package/payload/starter/_basic/comp/bottom-bar.js +31 -23
- package/payload/starter/_basic/comp/breadcrumbs.js +4 -2
- package/payload/starter/_basic/comp/canvas.js +652 -0
- package/payload/starter/_basic/comp/chat-view.js +827 -0
- package/payload/starter/_basic/comp/check-box.js +137 -21
- package/payload/starter/_basic/comp/code-editor.js +953 -0
- package/payload/starter/_basic/comp/{select-color.js → color-picker.js} +62 -29
- package/payload/starter/_basic/comp/context-menu.js +342 -30
- package/payload/starter/_basic/comp/{currency-input-b.js → currency-field.js} +48 -29
- package/payload/starter/_basic/comp/data-table.js +114 -42
- package/payload/starter/_basic/comp/{select-date.js → date-picker.js} +104 -52
- package/payload/starter/_basic/comp/dialog.js +214 -76
- package/payload/starter/_basic/comp/email-field.js +65 -0
- package/payload/starter/_basic/comp/{select-file.js → file-picker.js} +245 -57
- package/payload/starter/_basic/comp/filters.js +374 -60
- package/payload/starter/_basic/comp/form.js +38 -26
- package/payload/starter/_basic/comp/full-screen-select.js +36 -33
- package/payload/starter/_basic/comp/gauge.js +12 -8
- package/payload/starter/_basic/comp/graph-box.js +3911 -0
- package/payload/starter/_basic/comp/grid-group.js +185 -0
- package/payload/starter/_basic/comp/hold-to-confirm-button.js +16 -7
- package/payload/starter/_basic/comp/image-view.js +598 -0
- package/payload/starter/_basic/comp/item-list.js +507 -163
- package/payload/starter/_basic/comp/json-editor.js +3221 -0
- package/payload/starter/_basic/comp/json-view.js +597 -0
- package/payload/starter/_basic/comp/label-editor.js +22 -19
- package/payload/starter/_basic/comp/left-menu.js +97 -25
- package/payload/starter/_basic/comp/line-progress-bar.js +196 -45
- package/payload/starter/_basic/comp/loading-screen.js +49 -18
- package/payload/starter/_basic/comp/log-view.js +530 -0
- package/payload/starter/_basic/comp/{login-page-v2.js → login-page.js} +205 -106
- package/payload/starter/_basic/comp/markdown-view.js +1044 -0
- package/payload/starter/_basic/comp/menu-bar.js +624 -0
- package/payload/starter/_basic/comp/mini-graph-box.js +20 -11
- package/payload/starter/_basic/comp/minimal-accent.js +208 -0
- package/payload/starter/_basic/comp/notice.js +15 -13
- package/payload/starter/_basic/comp/{number-input-b.js → number-field.js} +26 -19
- package/payload/starter/_basic/comp/numeric-keyboard.js +15 -13
- package/payload/starter/_basic/comp/page-control.js +21 -4
- package/payload/starter/_basic/comp/page-header.js +7 -6
- package/payload/starter/_basic/comp/password-field.js +192 -0
- package/payload/starter/_basic/comp/period-bar.js +8 -7
- package/payload/starter/_basic/comp/{phone-input-b.js → phone-field.js} +80 -45
- package/payload/starter/_basic/comp/progress-bar.js +401 -85
- package/payload/starter/_basic/comp/property-panel.js +1022 -123
- package/payload/starter/_basic/comp/radio-button.js +79 -19
- package/payload/starter/_basic/comp/range-slider.js +569 -0
- package/payload/starter/_basic/comp/rich-text-editor.js +33 -30
- package/payload/starter/_basic/comp/scroll-area.js +308 -0
- package/payload/starter/_basic/comp/scrolling-text.js +10 -9
- package/payload/starter/_basic/comp/search-input.js +725 -0
- package/payload/starter/_basic/comp/search-results.js +60 -24
- package/payload/starter/_basic/comp/select-box.js +229 -107
- package/payload/starter/_basic/comp/settings-row.js +20 -19
- package/payload/starter/_basic/comp/side-panel.js +53 -10
- package/payload/starter/_basic/comp/slider-field.js +264 -88
- package/payload/starter/_basic/comp/slider.js +541 -86
- package/payload/starter/_basic/comp/smart-button.js +433 -352
- package/payload/starter/_basic/comp/smart-table.js +740 -185
- package/payload/starter/_basic/comp/sortable-list.js +47 -38
- package/payload/starter/_basic/comp/spark-line-box.js +25 -16
- package/payload/starter/_basic/comp/splitter.js +411 -0
- package/payload/starter/_basic/comp/status-bar.js +408 -0
- package/payload/starter/_basic/comp/step-bar.js +345 -0
- package/payload/starter/_basic/comp/stepper.js +77 -49
- package/payload/starter/_basic/comp/tabs.js +67 -18
- package/payload/starter/_basic/comp/tag-input.js +50 -10
- package/payload/starter/_basic/comp/tap-effect.js +6 -4
- package/payload/starter/_basic/comp/text-area-field.js +233 -0
- package/payload/starter/_basic/comp/text-field.js +1006 -0
- package/payload/starter/_basic/comp/time-line.js +102 -28
- package/payload/starter/_basic/comp/{select-time.js → time-picker.js} +104 -51
- package/payload/starter/_basic/comp/tiny-select.js +79 -39
- package/payload/starter/_basic/comp/tiny-table.js +12 -8
- package/payload/starter/_basic/comp/toast.js +87 -34
- package/payload/starter/_basic/comp/toggle.js +147 -27
- package/payload/starter/_basic/comp/tool-bar.js +760 -0
- package/payload/starter/_basic/comp/tooltip.js +80 -17
- package/payload/starter/_basic/comp/tree-view.js +124 -41
- package/payload/starter/_basic/comp/ui-effects.js +17 -11
- package/payload/starter/_basic/comp/ui-standards.js +5 -4
- package/payload/starter/_basic/comp/url-field.js +190 -0
- package/payload/starter/_basic/comp/web-view.js +70 -16
- package/payload/starter/_basic/docs/basic-js-animated-rules.md +15 -9
- package/payload/starter/_basic/docs/basic-js-code-rules.md +42 -5
- package/payload/starter/_basic/docs/basic-js-components.md +12 -17
- package/payload/starter/_basic/docs/basic-js-core.md +5 -4
- package/payload/starter/_basic/docs/component-index.md +245 -104
- package/payload/starter/_basic/docs/component-template.js +28 -24
- package/payload/starter/_basic/docs/handbook/00-introduction.md +6 -2
- package/payload/starter/_basic/docs/handbook/00-what-is-new.md +21 -0
- package/payload/starter/_basic/docs/handbook/01-label.md +4 -4
- package/payload/starter/_basic/docs/handbook/02-box.md +7 -7
- package/payload/starter/_basic/docs/handbook/03-image.md +4 -4
- package/payload/starter/_basic/docs/handbook/04-common-properties.md +6 -5
- package/payload/starter/_basic/docs/handbook/05-autolayout.md +8 -7
- package/payload/starter/_basic/docs/handbook/06-button.md +3 -3
- package/payload/starter/_basic/docs/handbook/07-input.md +3 -3
- package/payload/starter/_basic/docs/handbook/08-page.md +3 -3
- package/payload/starter/_basic/docs/handbook/09-useful-examples.md +39 -58
- package/payload/starter/_basic/docs/handbook/10-motion.md +6 -6
- package/payload/starter/_basic/docs/handbook/11-other-functions.md +1 -0
- package/payload/starter/_basic/docs/handbook/13-sound.md +3 -3
- package/payload/starter/_basic/docs/handbook/14-using-components.md +180 -0
- package/payload/starter/_basic/docs/handbook/15-making-a-component.md +338 -0
- package/payload/starter/_basic/docs/what-is-new.md +106 -0
- package/payload/starter/_basic/examples/accordion.htm +174 -0
- package/payload/starter/_basic/examples/action-button.htm +74 -32
- package/payload/starter/_basic/examples/action-tab-bar.htm +5 -6
- package/payload/starter/_basic/examples/app-bar.htm +63 -41
- package/payload/starter/_basic/examples/badge.htm +96 -0
- package/payload/starter/_basic/examples/bottom-bar-2.htm +61 -48
- package/payload/starter/_basic/examples/bottom-bar.htm +74 -16
- package/payload/starter/_basic/examples/breadcrumbs.htm +160 -150
- package/payload/starter/_basic/examples/canvas.htm +190 -0
- package/payload/starter/_basic/examples/chat-view.htm +143 -0
- package/payload/starter/_basic/examples/check-box-2.htm +71 -82
- package/payload/starter/_basic/examples/check-box-3.htm +72 -83
- package/payload/starter/_basic/examples/check-box.htm +207 -0
- package/payload/starter/_basic/examples/code-editor-2.htm +259 -0
- package/payload/starter/_basic/examples/code-editor.htm +225 -0
- package/payload/starter/_basic/examples/color-picker.htm +206 -0
- package/payload/starter/_basic/examples/context-menu.htm +180 -139
- package/payload/starter/_basic/examples/currency-field.htm +105 -0
- package/payload/starter/_basic/examples/data-table-2.htm +2 -1
- package/payload/starter/_basic/examples/data-table-3.htm +1 -1
- package/payload/starter/_basic/examples/data-table-4.htm +15 -12
- package/payload/starter/_basic/examples/data-table-5.htm +11 -3
- package/payload/starter/_basic/examples/data-table.htm +90 -40
- package/payload/starter/_basic/examples/date-picker.htm +239 -0
- package/payload/starter/_basic/examples/dialog-centered.htm +394 -40
- package/payload/starter/_basic/examples/dialog.htm +267 -46
- package/payload/starter/_basic/examples/email-field.htm +102 -0
- package/payload/starter/_basic/examples/file-picker.htm +296 -0
- package/payload/starter/_basic/examples/filters.htm +33 -22
- package/payload/starter/_basic/examples/{form-1.htm → form.htm} +18 -19
- package/payload/starter/_basic/examples/full-screen-select.htm +81 -58
- package/payload/starter/_basic/examples/gauge.htm +95 -81
- package/payload/starter/_basic/examples/graph-box.htm +365 -0
- package/payload/starter/_basic/examples/grid-group.htm +179 -0
- package/payload/starter/_basic/examples/hold-to-confirm-button.htm +102 -113
- package/payload/starter/_basic/examples/image-view.htm +195 -0
- package/payload/starter/_basic/examples/item-list-2.htm +138 -94
- package/payload/starter/_basic/examples/item-list.htm +191 -86
- package/payload/starter/_basic/examples/json-editor.htm +206 -0
- package/payload/starter/_basic/examples/json-view.htm +153 -0
- package/payload/starter/_basic/examples/label-editor.htm +85 -89
- package/payload/starter/_basic/examples/left-menu-2.htm +93 -0
- package/payload/starter/_basic/examples/left-menu.htm +42 -37
- package/payload/starter/_basic/examples/line-progress-bar.htm +155 -114
- package/payload/starter/_basic/examples/loading-screen.htm +149 -125
- package/payload/starter/_basic/examples/log-view.htm +175 -0
- package/payload/starter/_basic/examples/{login-page-dark-v2.htm → login-page-dark.htm} +265 -267
- package/payload/starter/_basic/examples/{login-page-v2.htm → login-page.htm} +266 -267
- package/payload/starter/_basic/examples/markdown-view.htm +220 -0
- package/payload/starter/_basic/examples/menu-bar-2.htm +225 -0
- package/payload/starter/_basic/examples/menu-bar.htm +145 -0
- package/payload/starter/_basic/examples/mini-graph-box.htm +98 -109
- package/payload/starter/_basic/examples/minimal-accent.htm +196 -0
- package/payload/starter/_basic/examples/minimal-theme.htm +432 -0
- package/payload/starter/_basic/examples/notice.htm +13 -4
- package/payload/starter/_basic/examples/number-field.htm +103 -0
- package/payload/starter/_basic/examples/numeric-keyboard.htm +44 -42
- package/payload/starter/_basic/examples/page-control.htm +181 -130
- package/payload/starter/_basic/examples/page-header.htm +57 -30
- package/payload/starter/_basic/examples/password-field.htm +117 -0
- package/payload/starter/_basic/examples/period-bar.htm +43 -29
- package/payload/starter/_basic/examples/phone-field-select-country.htm +292 -0
- package/payload/starter/_basic/examples/phone-field.htm +104 -0
- package/payload/starter/_basic/examples/progress-bar-ozden.htm +229 -92
- package/payload/starter/_basic/examples/progress-bar.htm +222 -174
- package/payload/starter/_basic/examples/property-panel.htm +152 -52
- package/payload/starter/_basic/examples/radio-button-2.htm +101 -109
- package/payload/starter/_basic/examples/radio-button-3.htm +81 -71
- package/payload/starter/_basic/examples/radio-button.htm +289 -0
- package/payload/starter/_basic/examples/range-slider.htm +171 -0
- package/payload/starter/_basic/examples/rich-text-editor.htm +115 -110
- package/payload/starter/_basic/examples/scroll-area.htm +293 -0
- package/payload/starter/_basic/examples/scrolling-text.htm +27 -6
- package/payload/starter/_basic/examples/search-input-2-light.htm +112 -0
- package/payload/starter/_basic/examples/search-input-3-dark.htm +105 -0
- package/payload/starter/_basic/examples/{search-input-v2-place.htm → search-input-place.htm} +25 -26
- package/payload/starter/_basic/examples/search-input.htm +159 -0
- package/payload/starter/_basic/examples/search-results.htm +85 -88
- package/payload/starter/_basic/examples/select-box-ozden-dark-text.htm +70 -0
- package/payload/starter/_basic/examples/select-box-ozden-item.htm +6 -5
- package/payload/starter/_basic/examples/select-box-ozden-text.htm +5 -3
- package/payload/starter/_basic/examples/select-box.htm +190 -159
- package/payload/starter/_basic/examples/settings-row.htm +92 -43
- package/payload/starter/_basic/examples/side-panel-2.htm +63 -25
- package/payload/starter/_basic/examples/side-panel.htm +84 -70
- package/payload/starter/_basic/examples/slider-2-classic.htm +152 -0
- package/payload/starter/_basic/examples/slider-field-ozden.htm +286 -0
- package/payload/starter/_basic/examples/slider-field.htm +174 -134
- package/payload/starter/_basic/examples/slider.htm +257 -180
- package/payload/starter/_basic/examples/smart-button-3-ozden.htm +170 -257
- package/payload/starter/_basic/examples/smart-button-4-dark.htm +86 -47
- package/payload/starter/_basic/examples/smart-button-5-features.htm +130 -125
- package/payload/starter/_basic/examples/smart-button-alternatif.htm +266 -0
- package/payload/starter/_basic/examples/smart-button.htm +207 -174
- package/payload/starter/_basic/examples/smart-table-2.htm +43 -56
- package/payload/starter/_basic/examples/smart-table-3.htm +148 -113
- package/payload/starter/_basic/examples/smart-table-4.htm +37 -50
- package/payload/starter/_basic/examples/{smart-table-1.htm → smart-table-5.htm} +37 -48
- package/payload/starter/_basic/examples/smart-table.htm +183 -0
- package/payload/starter/_basic/examples/sortable-list.htm +191 -142
- package/payload/starter/_basic/examples/spark-line-box.htm +149 -161
- package/payload/starter/_basic/examples/splitter.htm +164 -0
- package/payload/starter/_basic/examples/status-bar.htm +166 -0
- package/payload/starter/_basic/examples/step-bar.htm +129 -0
- package/payload/starter/_basic/examples/stepper-2.htm +71 -59
- package/payload/starter/_basic/examples/stepper.htm +146 -135
- package/payload/starter/_basic/examples/tabs-2.htm +58 -67
- package/payload/starter/_basic/examples/tabs.htm +197 -180
- package/payload/starter/_basic/examples/tag-input.htm +150 -153
- package/payload/starter/_basic/examples/tap-effect.htm +23 -19
- package/payload/starter/_basic/examples/text-area-field.htm +104 -0
- package/payload/starter/_basic/examples/text-field-2.htm +113 -0
- package/payload/starter/_basic/examples/text-field-3-style.htm +105 -0
- package/payload/starter/_basic/examples/text-field-4-custom-unit.htm +96 -0
- package/payload/starter/_basic/examples/{input-b-ex5-warning-icon.htm → text-field-5-warning-icon.htm} +19 -19
- package/payload/starter/_basic/examples/text-field-6-modern-dark.htm +114 -0
- package/payload/starter/_basic/examples/text-field-7-modern.htm +106 -0
- package/payload/starter/_basic/examples/text-field-8-light-dark.htm +159 -0
- package/payload/starter/_basic/examples/text-field.htm +163 -0
- package/payload/starter/_basic/examples/time-line.htm +180 -116
- package/payload/starter/_basic/examples/time-picker.htm +240 -0
- package/payload/starter/_basic/examples/tiny-select.htm +118 -86
- package/payload/starter/_basic/examples/tiny-table.htm +40 -34
- package/payload/starter/_basic/examples/toast.htm +145 -147
- package/payload/starter/_basic/examples/toggle-2.htm +99 -68
- package/payload/starter/_basic/examples/toggle-3.htm +104 -101
- package/payload/starter/_basic/examples/toggle.htm +161 -93
- package/payload/starter/_basic/examples/tool-bar.htm +172 -0
- package/payload/starter/_basic/examples/tooltip-2.htm +110 -60
- package/payload/starter/_basic/examples/tooltip-3.htm +124 -65
- package/payload/starter/_basic/examples/tooltip-4.htm +218 -0
- package/payload/starter/_basic/examples/tooltip.htm +206 -124
- package/payload/starter/_basic/examples/tree-view.htm +210 -182
- package/payload/starter/_basic/examples/ui-effects.htm +207 -185
- package/payload/starter/_basic/examples/ui-standards.htm +200 -139
- package/payload/starter/_basic/examples/url-field.htm +120 -0
- package/payload/starter/_basic/examples/web-view.htm +109 -110
- package/payload/starter/_basic/min/accordion.min.js +2 -0
- package/payload/starter/_basic/min/action-button.min.js +1 -1
- package/payload/starter/_basic/min/app-bar.min.js +1 -1
- package/payload/starter/_basic/min/badge.min.js +2 -0
- package/payload/starter/_basic/min/bottom-bar.min.js +1 -1
- package/payload/starter/_basic/min/canvas.min.js +2 -0
- package/payload/starter/_basic/min/chat-view.min.js +2 -0
- package/payload/starter/_basic/min/check-box.min.js +1 -1
- package/payload/starter/_basic/min/code-editor.min.js +2 -0
- package/payload/starter/_basic/min/color-picker.min.js +2 -0
- package/payload/starter/_basic/min/context-menu.min.js +1 -1
- package/payload/starter/_basic/min/currency-field.min.js +2 -0
- package/payload/starter/_basic/min/data-table.min.js +1 -1
- package/payload/starter/_basic/min/date-picker.min.js +2 -0
- package/payload/starter/_basic/min/dialog.min.js +1 -1
- package/payload/starter/_basic/min/email-field.min.js +2 -0
- package/payload/starter/_basic/min/file-picker.min.js +2 -0
- package/payload/starter/_basic/min/filters.min.js +1 -1
- package/payload/starter/_basic/min/form.min.js +1 -1
- package/payload/starter/_basic/min/full-screen-select.min.js +1 -1
- package/payload/starter/_basic/min/gauge.min.js +1 -1
- package/payload/starter/_basic/min/graph-box.min.js +2 -0
- package/payload/starter/_basic/min/grid-group.min.js +2 -0
- package/payload/starter/_basic/min/hold-to-confirm-button.min.js +1 -1
- package/payload/starter/_basic/min/image-view.min.js +2 -0
- package/payload/starter/_basic/min/item-list.min.js +1 -1
- package/payload/starter/_basic/min/json-editor.min.js +2 -0
- package/payload/starter/_basic/min/json-view.min.js +2 -0
- package/payload/starter/_basic/min/label-editor.min.js +1 -1
- package/payload/starter/_basic/min/left-menu.min.js +1 -1
- package/payload/starter/_basic/min/line-progress-bar.min.js +1 -1
- package/payload/starter/_basic/min/loading-screen.min.js +1 -1
- package/payload/starter/_basic/min/log-view.min.js +2 -0
- package/payload/starter/_basic/min/login-page.min.js +2 -0
- package/payload/starter/_basic/min/markdown-view.min.js +2 -0
- package/payload/starter/_basic/min/menu-bar.min.js +2 -0
- package/payload/starter/_basic/min/mini-graph-box.min.js +1 -1
- package/payload/starter/_basic/min/minimal-accent.min.js +2 -0
- package/payload/starter/_basic/min/notice.min.js +1 -1
- package/payload/starter/_basic/min/number-field.min.js +2 -0
- package/payload/starter/_basic/min/numeric-keyboard.min.js +1 -1
- package/payload/starter/_basic/min/page-control.min.js +1 -1
- package/payload/starter/_basic/min/password-field.min.js +2 -0
- package/payload/starter/_basic/min/phone-field.min.js +2 -0
- package/payload/starter/_basic/min/progress-bar.min.js +1 -1
- package/payload/starter/_basic/min/property-panel.min.js +1 -1
- package/payload/starter/_basic/min/radio-button.min.js +1 -1
- package/payload/starter/_basic/min/range-slider.min.js +2 -0
- package/payload/starter/_basic/min/rich-text-editor.min.js +1 -1
- package/payload/starter/_basic/min/scroll-area.min.js +2 -0
- package/payload/starter/_basic/min/scrolling-text.min.js +1 -1
- package/payload/starter/_basic/min/search-input.min.js +2 -0
- package/payload/starter/_basic/min/search-results.min.js +1 -1
- package/payload/starter/_basic/min/select-box.min.js +1 -1
- package/payload/starter/_basic/min/settings-row.min.js +1 -1
- package/payload/starter/_basic/min/side-panel.min.js +1 -1
- package/payload/starter/_basic/min/slider-field.min.js +1 -1
- package/payload/starter/_basic/min/slider.min.js +1 -1
- package/payload/starter/_basic/min/smart-button.min.js +1 -1
- package/payload/starter/_basic/min/smart-table.min.js +1 -1
- package/payload/starter/_basic/min/sortable-list.min.js +1 -1
- package/payload/starter/_basic/min/spark-line-box.min.js +1 -1
- package/payload/starter/_basic/min/splitter.min.js +2 -0
- package/payload/starter/_basic/min/status-bar.min.js +2 -0
- package/payload/starter/_basic/min/step-bar.min.js +2 -0
- package/payload/starter/_basic/min/stepper.min.js +1 -1
- package/payload/starter/_basic/min/tabs.min.js +1 -1
- package/payload/starter/_basic/min/tag-input.min.js +1 -1
- package/payload/starter/_basic/min/text-area-field.min.js +2 -0
- package/payload/starter/_basic/min/text-field.min.js +2 -0
- package/payload/starter/_basic/min/time-line.min.js +1 -1
- package/payload/starter/_basic/min/time-picker.min.js +2 -0
- package/payload/starter/_basic/min/tiny-select.min.js +1 -1
- package/payload/starter/_basic/min/toast.min.js +1 -1
- package/payload/starter/_basic/min/toggle.min.js +1 -1
- package/payload/starter/_basic/min/tool-bar.min.js +2 -0
- package/payload/starter/_basic/min/tooltip.min.js +1 -1
- package/payload/starter/_basic/min/tree-view.min.js +1 -1
- package/payload/starter/_basic/min/ui-effects.min.js +1 -1
- package/payload/starter/_basic/min/url-field.min.js +2 -0
- package/payload/starter/_basic/min/web-view.min.js +1 -1
- package/payload/templates/booking/app/app.js +11 -8
- package/payload/templates/booking/app/settings.js +4 -4
- package/payload/templates/booking/index.htm +3 -3
- package/payload/templates/booking/pages/account.js +6 -6
- package/payload/templates/booking/pages/book.js +1 -1
- package/payload/templates/booking/pages/services.js +5 -4
- package/payload/templates/classic/app/app.js +15 -11
- package/payload/templates/classic/app/settings.js +22 -20
- package/payload/templates/classic/assets/_attribute.txt +2 -0
- package/payload/templates/classic/assets/cards/dill.png +0 -0
- package/payload/templates/classic/assets/cards/fennel.png +0 -0
- package/payload/templates/classic/assets/cards/juniper.png +0 -0
- package/payload/templates/classic/assets/cards/olives.png +0 -0
- package/payload/templates/classic/assets/cards/oregano.png +0 -0
- package/payload/templates/classic/assets/cards/pepper.png +0 -0
- package/payload/templates/classic/assets/cards/rosehip.png +0 -0
- package/payload/templates/classic/assets/categories/cappuccino.png +0 -0
- package/payload/templates/classic/assets/categories/chocolate-milk.png +0 -0
- package/payload/templates/classic/assets/categories/coffee.png +0 -0
- package/payload/templates/classic/assets/categories/frappe.png +0 -0
- package/payload/templates/classic/assets/categories/iced-caffee.png +0 -0
- package/payload/templates/classic/assets/categories/milkshake.png +0 -0
- package/payload/templates/classic/assets/categories/orange-juice.png +0 -0
- package/payload/templates/classic/assets/categories/tea.png +0 -0
- package/payload/templates/classic/index.htm +2 -2
- package/payload/templates/classic/pages/example.js +10 -10
- package/payload/templates/classic/pages/examples.js +44 -43
- package/payload/templates/classic/pages/home.js +16 -15
- package/payload/templates/classic/pages/info-pages.js +5 -5
- package/payload/templates/classic/pages/search.js +8 -7
- package/payload/templates/classic/pages/settings.js +13 -13
- package/payload/templates/classic/pages/tasks.js +1 -0
- package/payload/templates/classic/pages/template-pages.js +12 -11
- package/payload/templates/coffee-shop/app/app.js +12 -8
- package/payload/templates/coffee-shop/app/settings.js +4 -4
- package/payload/templates/coffee-shop/index.htm +3 -3
- package/payload/templates/coffee-shop/pages/drink.js +1 -1
- package/payload/templates/coffee-shop/pages/menu.js +5 -4
- package/payload/templates/forms/TEMPLATE.md +1 -1
- package/payload/templates/forms/appointment-form.htm +55 -53
- package/payload/templates/forms/contact-form-to-mail.htm +38 -37
- package/payload/templates/forms/contact-form-to-supabase.htm +47 -46
- package/payload/templates/forms/dark-contact-form.htm +43 -40
- package/payload/templates/forms/event-registration-form.htm +80 -77
- package/payload/templates/forms/feedback-form.htm +54 -54
- package/payload/templates/forms/order-form.htm +88 -84
- package/payload/templates/forms/recruitment-form.htm +60 -60
- package/payload/templates/forms/service/readme.md +9 -8
- package/payload/templates/forms/service/send-form-mail.php +38 -21
- package/payload/templates/forms/support-ticket-form.htm +67 -65
- package/payload/templates/panel/common/module-page.js +2 -2
- package/payload/templates/panel/common/theme.js +37 -10
- package/payload/templates/panel/common/top-bar.js +45 -40
- package/payload/templates/panel/index.htm +63 -60
- package/payload/templates/panel/module10/greenhouse.htm +98 -113
- package/payload/templates/panel/module11/arduino-projects.htm +47 -58
- package/payload/templates/panel/module6/energy-hub.htm +71 -103
- package/payload/templates/panel/module7/3d-printers.htm +58 -81
- package/payload/templates/panel/module8/cold-rooms.htm +58 -79
- package/payload/templates/panel/module9/elevator-fleet.htm +72 -93
- package/payload/templates/panel/pages/activity.js +134 -152
- package/payload/templates/panel/pages/contents.js +291 -308
- package/payload/templates/panel/pages/customers.js +250 -267
- package/payload/templates/panel/pages/edit-user.js +31 -30
- package/payload/templates/panel/pages/home.js +39 -70
- package/payload/templates/panel/pages/media.js +166 -183
- package/payload/templates/panel/pages/notifications.js +7 -7
- package/payload/templates/panel/pages/orders.js +200 -217
- package/payload/templates/panel/pages/products.js +259 -278
- package/payload/templates/panel/pages/reports.js +74 -123
- package/payload/templates/panel/pages/roles.js +57 -60
- package/payload/templates/panel/pages/settings.js +127 -143
- package/payload/templates/panel/pages/user-actions.js +106 -110
- package/payload/templates/panel/pages/user-list.js +221 -238
- package/payload/templates/panel/pages/users.js +14 -29
- package/payload/templates/shop/TEMPLATE.md +1 -1
- package/payload/templates/shop/app/app.js +11 -8
- package/payload/templates/shop/app/settings.js +4 -4
- package/payload/templates/shop/index.htm +3 -3
- package/payload/templates/shop/pages/account.js +7 -7
- package/payload/templates/shop/pages/cart.js +1 -1
- package/payload/templates/shop/pages/checkout.js +2 -2
- package/payload/templates/shop/pages/product.js +2 -2
- package/payload/templates/shop/pages/shop.js +6 -5
- package/payload/templates/starter/TEMPLATE.md +1 -1
- package/payload/templates/starter/app/app.js +12 -8
- package/payload/templates/starter/app/settings.js +14 -11
- package/payload/templates/starter/index.htm +3 -3
- package/payload/templates/starter/pages/about.js +1 -1
- package/payload/templates/starter/pages/home.js +2 -2
- package/payload/templates/starter/pages/product.js +1 -1
- package/payload/templates/starter/pages/products.js +5 -5
- package/payload/templates/starter/pages/settings.js +1 -1
- package/payload/templates/starter/pages/tasks.js +8 -8
- package/payload/templates/starter/pages/website.js +1 -1
- package/payload/starter/_basic/comp/chart-box/chart-4.5.1.umd.min.js +0 -13
- package/payload/starter/_basic/comp/chart-box/chart-js-LICENSE.md +0 -9
- package/payload/starter/_basic/comp/chart-box.js +0 -868
- package/payload/starter/_basic/comp/email-input-b.js +0 -57
- package/payload/starter/_basic/comp/input-b.js +0 -759
- package/payload/starter/_basic/comp/password-input-b.js +0 -164
- package/payload/starter/_basic/comp/search-input-v2.js +0 -427
- package/payload/starter/_basic/comp/textarea-b.js +0 -184
- package/payload/starter/_basic/comp/url-input-b.js +0 -145
- package/payload/starter/_basic/examples/badgeV2.htm +0 -68
- package/payload/starter/_basic/examples/chart-box.htm +0 -287
- package/payload/starter/_basic/examples/check-box-1.htm +0 -220
- package/payload/starter/_basic/examples/currency-input-b.htm +0 -71
- package/payload/starter/_basic/examples/email-input-b.htm +0 -67
- package/payload/starter/_basic/examples/input-b-ex1.htm +0 -132
- package/payload/starter/_basic/examples/input-b-ex2.htm +0 -136
- package/payload/starter/_basic/examples/input-b-ex3-style.htm +0 -113
- package/payload/starter/_basic/examples/input-b-ex4-custom-unit.htm +0 -112
- package/payload/starter/_basic/examples/input-b-ex6-dark.htm +0 -108
- package/payload/starter/_basic/examples/input-b-ex7-ozden.htm +0 -153
- package/payload/starter/_basic/examples/number-input-b.htm +0 -68
- package/payload/starter/_basic/examples/password-input-b.htm +0 -70
- package/payload/starter/_basic/examples/phone-input-b-select-country.htm +0 -298
- package/payload/starter/_basic/examples/phone-input-b.htm +0 -72
- package/payload/starter/_basic/examples/radio-button-1.htm +0 -264
- package/payload/starter/_basic/examples/search-input-v2-ozden.htm +0 -128
- package/payload/starter/_basic/examples/search-input-v2.htm +0 -65
- package/payload/starter/_basic/examples/select-color.htm +0 -215
- package/payload/starter/_basic/examples/select-date.htm +0 -244
- package/payload/starter/_basic/examples/select-file.htm +0 -268
- package/payload/starter/_basic/examples/select-time.htm +0 -249
- package/payload/starter/_basic/examples/smart-button-2.htm +0 -220
- package/payload/starter/_basic/examples/textarea-b.htm +0 -76
- package/payload/starter/_basic/examples/unfinished-login-page-dark-supabase.htm +0 -221
- package/payload/starter/_basic/examples/unfinished-login-page-supabase.htm +0 -221
- package/payload/starter/_basic/examples/url-input-b.htm +0 -85
- package/payload/starter/_basic/min/badge-v2.min.js +0 -2
- package/payload/starter/_basic/min/chart-box.min.js +0 -2
- package/payload/starter/_basic/min/currency-input-b.min.js +0 -2
- package/payload/starter/_basic/min/email-input-b.min.js +0 -2
- package/payload/starter/_basic/min/input-b.min.js +0 -2
- package/payload/starter/_basic/min/login-page-v2.min.js +0 -2
- package/payload/starter/_basic/min/number-input-b.min.js +0 -2
- package/payload/starter/_basic/min/password-input-b.min.js +0 -2
- package/payload/starter/_basic/min/phone-input-b.min.js +0 -2
- package/payload/starter/_basic/min/search-input-v2.min.js +0 -2
- package/payload/starter/_basic/min/select-color.min.js +0 -2
- package/payload/starter/_basic/min/select-date.min.js +0 -2
- package/payload/starter/_basic/min/select-file.min.js +0 -2
- package/payload/starter/_basic/min/select-time.min.js +0 -2
- package/payload/starter/_basic/min/textarea-b.min.js +0 -2
- package/payload/starter/_basic/min/url-input-b.min.js +0 -2
- package/payload/templates/panel/common/bridge.min.js +0 -0
- package/payload/templates/panel/common/full-view.min.js +0 -1
- package/payload/templates/panel/common/main-view.min.js +0 -1
- package/payload/templates/panel/common/module-page.min.js +0 -1
- package/payload/templates/panel/common/right-view.min.js +0 -1
- package/payload/templates/panel/common/start-page.min.js +0 -1
- package/payload/templates/panel/common/top-bar-v25-07-29-1.js +0 -330
- package/payload/templates/panel/common/top-bar-v25-07-29-2.js +0 -265
- package/payload/templates/panel/common/top-bar.min.js +0 -1
- package/payload/templates/panel/common/ui-standards.min.js +0 -1
- package/payload/templates/panel/managers/database.min.js +0 -1
- package/payload/templates/panel/managers/login.min.js +0 -1
- package/payload/templates/panel/pages/_page-template.min.js +0 -1
- package/payload/templates/panel/pages/contents.min.js +0 -1
- package/payload/templates/panel/pages/edit-user.min.js +0 -1
- package/payload/templates/panel/pages/edit-users-table.min.js +0 -1
- package/payload/templates/panel/pages/home.min.js +0 -1
- package/payload/templates/panel/pages/notifications.min.js +0 -1
- package/payload/templates/panel/pages/reports.min.js +0 -1
- package/payload/templates/panel/pages/settings.min.js +0 -1
- package/payload/templates/panel/pages/user-actions.min.js +0 -2
- package/payload/templates/panel/pages/users.min.js +0 -1
- /package/payload/starter/_basic/comp/{password-input-b → password-field}/hide-btn.png +0 -0
- /package/payload/starter/_basic/comp/{password-input-b → password-field}/hide-btn2.png +0 -0
- /package/payload/starter/_basic/comp/{password-input-b → password-field}/show-btn.png +0 -0
- /package/payload/starter/_basic/comp/{password-input-b → password-field}/show-btn2.png +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/clear-round.svg +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/clear.svg +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/filter.png +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/filter.svg +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/search.svg +0 -0
|
@@ -2,65 +2,79 @@
|
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
|
|
5
|
-
Smart Button - v26.
|
|
5
|
+
Smart Button - v26.11
|
|
6
6
|
|
|
7
|
-
THE DEFAULT BUTTON of new pages and projects
|
|
8
|
-
|
|
7
|
+
THE DEFAULT BUTTON of new pages and projects.
|
|
8
|
+
|
|
9
|
+
THE MODEL PAGE: _basic/examples/smart-button.htm: new pages and projects take their buttons from it.
|
|
10
|
+
The other samples: smart-button-alternatif.htm (pill and outlined with the colors of the page), smart-button-3-ozden.htm
|
|
11
|
+
(the templates), smart-button-4-dark.htm (the dark templates and tones), smart-button-5-features.htm.
|
|
9
12
|
|
|
10
13
|
- A button with an icon and a text (or only one of them); the icon on the left or on top (iconPosition).
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
- THE LOOK IN THREE STEPS. The order: style > tone > the template.
|
|
15
|
+
1. styleName: the template (the shape), gray. "ozden" (THE DEFAULT: #E3E3E3, a thin dark edge and a darker
|
|
16
|
+
line at the bottom), "ozden2" (no bottom line), "ozden3" (a faint edge), "ozden4" (a ghost: no
|
|
17
|
+
surface, no edge, only its hover is gray), "pill" (round, no edge, a bold text), "outlined" (round, a thicker
|
|
18
|
+
edge with a line at its bottom). For a dark page (the draft _designs/smart-button-dark.htm):
|
|
19
|
+
"ozdenDark" ... "ozden4Dark" (#2E2E2C, a white text and icon, the dark waiting clock).
|
|
20
|
+
"minimal" / "minimalDark" (the minimal theme, _designs/minimal-theme.htm): 28 px high, a 13 px text, only a line
|
|
21
|
+
that gets darker under the mouse; the main action takes the tone "ink" / "inkDark"; a delete "minimalDanger" /
|
|
22
|
+
"minimalDangerDark" (the line and the text in the danger color).
|
|
23
|
+
A template is only a style (SmartButton.styles); the minimal ones also give the height.
|
|
24
|
+
2. tone: a color of the kit (SmartButton.tones), three colors: the button, the button under the mouse, its text.
|
|
25
|
+
"white", "cyan" (the main action), "orange" (a delete, a reject), "yellow" (go on, but look first), "green"
|
|
26
|
+
(after a good result), "blue" (nothing changes). For a dark page: "cyanDark", "orangeDark", "yellowDark",
|
|
27
|
+
"greenDark", "blueDark" (deeper, a light text and a white icon). "": the gray of the template. setTone().
|
|
28
|
+
"ink" / "inkDark" (the main action of the minimal templates) color the edge too (a tone with edge / hoverEdge).
|
|
29
|
+
A tone looks the same on every template: its text (and its icon) come with it.
|
|
30
|
+
3. style: your own look, only the keys you change. A color is two colors: the button and the button under the mouse.
|
|
31
|
+
style: { box: { color: "#9DC7B5" }, hover: { color: "#91BCA9" } }
|
|
32
|
+
Pressed, a button gets a little smaller and darker (animated: 1, style.press): a press has no color of its own.
|
|
33
|
+
- AN ICON BUTTON: labelText: "" -> the icon in the middle, no room at the sides; with no width it is a square
|
|
34
|
+
(44 x 44). The same template and tone as a text button. Give it an ariaLabel.
|
|
35
|
+
An "auto" height keeps the room of style.layout.padding (Ex: padding [10, 10] -> 44 x 44).
|
|
36
|
+
- HEIGHT: 44 by default (40 looked narrow); every template, pill and outlined too. An icon on
|
|
37
|
+
top of a text makes it "auto" (as high as its padding and content).
|
|
29
38
|
- KEYBOARD AND ACCESSIBILITY: role "button", Tab reaches it, Enter / Space press it (Space when it goes up), a focus
|
|
30
39
|
ring only for the keyboard; ariaLabel for a button with only an icon (else labelText is read).
|
|
31
40
|
- setEnabled(0): no click, no hover, out of the Tab order (aria-disabled): a flat light gray button, a faint edge, no
|
|
32
41
|
bottom line, the text and the icon faint gray (the same for every color; chosen on
|
|
33
42
|
experimental/smart-button-bench.htm).
|
|
34
|
-
- ASK (two clicks): ask: "Click again to delete." -> the first click turns the button
|
|
43
|
+
- ASK (two clicks): ask: "Click again to delete." -> the first click turns the button orange (style.ask.button) and
|
|
35
44
|
shows the text in a bubble over it (comp/tooltip.js, Tooltip.show(): it stays inside the screen; without
|
|
36
|
-
tooltip.js only the
|
|
45
|
+
tooltip.js only the orange button); the second click runs onClick. It forgets after style.ask.time. One button asks
|
|
37
46
|
at a time. setAsk(text), cancelAsk(), isAsking. onBeforeClick(self) returns false: no ask and no onClick (Ex: a
|
|
38
47
|
form with an error must not ask "Sure?" first). press(): a press like a click (the ask too), Ex: Enter in a field.
|
|
39
48
|
- WAITING: setWaiting(1) while a job runs (a download, a save): the text and the icon fade and a small animation is
|
|
40
49
|
in the middle; the button can not be clicked. waitingType: "clock" (the default: the clock of the waiting views
|
|
41
|
-
with moving hands;
|
|
50
|
+
with moving hands; style.waiting.clock "ozden", or "ozdenDark" in the dark templates) or "dots" (three dots one
|
|
51
|
+
after the other).
|
|
42
52
|
setWaiting(0) ends it (after delay ms, if given). Nothing turns with prefers-reduced-motion.
|
|
43
53
|
(comp/loading-screen.js draws its clock and its dots with SmartButton.createClockSvg / createDots)
|
|
44
|
-
- MOTION: animated: 1 (default): pressed 0.94 and a little darker. ripple:
|
|
45
|
-
point
|
|
54
|
+
- MOTION: animated: 1 (default): pressed 0.94 and a little darker. ripple: 0 (default; 1 gives a wave from the
|
|
55
|
+
pressed point, from the middle for the keyboard; its color fits the button). setAnimated(0/1), setRipple(0/1).
|
|
46
56
|
- setStyle(style): changes the look after create with only the keys it gets.
|
|
47
57
|
|
|
48
58
|
USAGE:
|
|
49
|
-
SmartButton({ labelText: "
|
|
59
|
+
SmartButton({ labelText: "Cancel", onClick: function (self) { } }); // the default: ozden, gray
|
|
60
|
+
SmartButton({ tone: "cyan", labelText: "Send", iconFile: "_basic/assets/icons/send.png", onClick: send });
|
|
61
|
+
SmartButton({ styleName: "pill", tone: "blue", labelText: "Follow" });
|
|
62
|
+
SmartButton({ styleName: "ozdenDark", tone: "blueDark", labelText: "Send" }); // on a dark page
|
|
63
|
+
SmartButton({ styleName: "ozden2", tone: "white", labelText: "", iconFile: "trash.svg", ariaLabel: "Delete", ask: "Click again to delete.", onClick: deleteFile });
|
|
64
|
+
SmartButton({ labelText: "Archive", style: { box: { color: "#C3DBCE" }, hover: { color: "#B5D0C1" } } }); // your own color
|
|
50
65
|
const btnDownload = SmartButton({ labelText: "Download", onClick: function (self) {
|
|
51
66
|
self.setWaiting(1);
|
|
52
67
|
download().then(function () { self.setWaiting(0); });
|
|
53
68
|
} });
|
|
54
|
-
|
|
55
|
-
SmartButton({ styleName: "pill", tone: "green", labelText: "Accepted", iconFile: "check.svg" });
|
|
56
|
-
button.setTone("blue", "pillSolid"); // another color and shape after create
|
|
57
|
-
btnSave.setStyle({ box: { color: "#9DC7B5" }, hover: { color: "#91BCA9" }, active: { color: "#91BCA9" } });
|
|
69
|
+
btnSave.setTone("green"); // another color after create ("": the gray of its template)
|
|
58
70
|
|
|
59
71
|
Started Date: January 2026
|
|
60
|
-
Developer: Bugra Ozden
|
|
61
|
-
Email: bugra.ozden@gmail.com
|
|
62
72
|
Webpage: https://bug7a.github.io/js-components/
|
|
63
73
|
|
|
74
|
+
Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
|
|
75
|
+
Licensed under the Apache License, Version 2.0
|
|
76
|
+
SPDX-License-Identifier: Apache-2.0
|
|
77
|
+
|
|
64
78
|
*/
|
|
65
79
|
|
|
66
80
|
"use strict";
|
|
@@ -68,38 +82,38 @@ Webpage: https://bug7a.github.io/js-components/
|
|
|
68
82
|
// Default values:
|
|
69
83
|
const SmartButtonDefaults = {
|
|
70
84
|
key: "0",
|
|
71
|
-
styleName: "
|
|
72
|
-
tone: "", //
|
|
73
|
-
width: "auto",
|
|
74
|
-
height: "auto"
|
|
75
|
-
labelText: "Button",
|
|
85
|
+
styleName: "ozden", // the template (SmartButton.styles): "ozden" (the default) ... "ozden4", "pill", "outlined", "ozdenDark" ... "ozden4Dark", "minimal", "minimalDark", "minimalDanger", "minimalDangerDark"
|
|
86
|
+
tone: "", // a color of the kit (SmartButton.tones): "white", "cyan", "orange", "yellow", "green", "blue", "cyanDark"..., "ink" / "inkDark" (minimal). "": the gray of the template. setTone()
|
|
87
|
+
width: "auto", // an icon button (labelText: "") is a square
|
|
88
|
+
height: 44, // "auto": as high as its padding and content (an icon on top of a text is "auto")
|
|
89
|
+
labelText: "Button", // "": an icon button
|
|
90
|
+
allowHtml: 0, // 1: labelText is HTML (only for your own texts)
|
|
76
91
|
iconFile: "", // "": no icon (Ex: "_basic/comp/smart-button/alert-black.png")
|
|
77
92
|
iconPosition: "left", // "left", "top"
|
|
78
93
|
enabled: 1, // 0: gray, can not be pressed (set later with setEnabled)
|
|
79
|
-
ariaLabel: "", // "": labelText is read.
|
|
94
|
+
ariaLabel: "", // "": labelText is read. An icon button needs it (Ex: "Delete")
|
|
80
95
|
waiting: 0, // 1: it waits (set later with setWaiting)
|
|
81
96
|
waitingType: "clock", // "clock" (the default wait) or "dots"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
ask: "", // "Click again to delete.": two clicks (the first one asks with a red button and this text in a bubble). setAsk()
|
|
97
|
+
animated: 1, // 1: pressed it gets smaller and darker (style.press). setAnimated()
|
|
98
|
+
ripple: 0, // 1: a wave from the pressed point (it works with animated: 0 too). setRipple()
|
|
99
|
+
ask: "", // "Click again to delete.": two clicks (the first one asks with an orange button and this text in a bubble). setAsk()
|
|
86
100
|
onBeforeClick: null, // function (self): false stops the press, with no ask either
|
|
87
101
|
onClick: function (self) { }, // Not called while waiting
|
|
88
102
|
onWaitingEnd: function (self) { }, // The wait ended (setWaiting(0))
|
|
89
|
-
style: { //
|
|
103
|
+
style: { // ozden (the default template)
|
|
90
104
|
layout: {
|
|
91
105
|
gap: 8,
|
|
92
106
|
padding: [16, 0],
|
|
93
107
|
align: "center center",
|
|
94
108
|
// px less space on the side of the icon (an icon left of a text): the empty edge in an icon file and its
|
|
95
|
-
// thin lines made that side look wider (measured 1 - 3 px
|
|
109
|
+
// thin lines made that side look wider (measured 1 - 3 px). 0: the same on both sides
|
|
96
110
|
iconSideTrim: 2,
|
|
97
111
|
},
|
|
98
112
|
icon: {
|
|
99
113
|
width: 24,
|
|
100
114
|
height: 24,
|
|
101
115
|
opacity: 0.8,
|
|
102
|
-
filter: "none", // a CSS filter: the dark
|
|
116
|
+
filter: "none", // a CSS filter: the dark templates turn the icon white ("brightness(0) invert(1)")
|
|
103
117
|
},
|
|
104
118
|
label: {
|
|
105
119
|
fontSize: 20,
|
|
@@ -114,22 +128,23 @@ const SmartButtonDefaults = {
|
|
|
114
128
|
boxShadow: "inset 0 -2px 0 rgba(0, 0, 0, 0.25)",
|
|
115
129
|
},
|
|
116
130
|
hover: {
|
|
117
|
-
color: "#D9D9D9",
|
|
118
|
-
|
|
119
|
-
active: {
|
|
120
|
-
color: "#D9D9D9",
|
|
131
|
+
color: "#D9D9D9", // under the mouse (pressed: this color, darker)
|
|
132
|
+
borderColor: "", // the edge under the mouse. "": the edge of box (the minimal templates darken it)
|
|
121
133
|
},
|
|
122
|
-
// ask: the
|
|
134
|
+
// ask: the look of the button while it asks, and the bubble over it (Tooltip.BUBBLE_LOOK keys).
|
|
135
|
+
// #DE815B (the orange of danger); its own value, not the orange tone,
|
|
136
|
+
// so the two can be changed apart.
|
|
123
137
|
ask: {
|
|
124
138
|
button: {
|
|
125
|
-
color: "#
|
|
126
|
-
border:
|
|
127
|
-
|
|
139
|
+
color: "#DE815B", // also under the mouse and pressed
|
|
140
|
+
// WHY no border width: the edge of the template stays, so a pill (0) or an outlined (2) button keeps
|
|
141
|
+
// its size while it asks (border: 1 made an "auto" pill 2 px wider)
|
|
142
|
+
borderColor: "#DE815B",
|
|
128
143
|
boxShadow: "none",
|
|
129
144
|
textColor: "white",
|
|
130
145
|
iconFilter: "brightness(0) invert(1)", // the icon turns white, whatever color its file has
|
|
131
146
|
},
|
|
132
|
-
bubble: { color: "#
|
|
147
|
+
bubble: { color: "#DE815B", textColor: "white", fontSize: 13, bold: 1, round: 8, padding: [12, 7], border: 0, borderColor: "", shadow: "0 6px 16px rgba(0, 0, 0, 0.18)", arrow: 12, gap: 6, edge: 8, grow: 1 },
|
|
133
148
|
time: 5000, // ms: it forgets the question
|
|
134
149
|
},
|
|
135
150
|
focus: {
|
|
@@ -141,9 +156,10 @@ const SmartButtonDefaults = {
|
|
|
141
156
|
textColor: "rgba(0, 0, 0, 0.3)",
|
|
142
157
|
iconOpacity: 0.25, // (and no color)
|
|
143
158
|
},
|
|
159
|
+
// The press (animated: 1). WHY no color for it: two colors are enough, the press
|
|
160
|
+
// only darkens the color of the moment
|
|
144
161
|
press: {
|
|
145
162
|
scale: 0.94, // while pressed
|
|
146
|
-
removeShadow: 0, // 1: while pressed the box shadow (Ex: the inset bottom line) goes away, as if pushed in
|
|
147
163
|
brightness: 0.92, // while pressed
|
|
148
164
|
time: 0.15, // s
|
|
149
165
|
},
|
|
@@ -154,6 +170,7 @@ const SmartButtonDefaults = {
|
|
|
154
170
|
time: 0.6, // s
|
|
155
171
|
},
|
|
156
172
|
waiting: {
|
|
173
|
+
clock: "ozden", // the look of the clock: "ozden" (a white face, dark lines), "ozdenDark", or the ring of "minimal" / "minimalDark" (SmartButton.clocks)
|
|
157
174
|
contentOpacity: 0.18, // the text and the icon while waiting
|
|
158
175
|
clockSize: 30, // at most; a small button gets a smaller clock
|
|
159
176
|
space: 14, // the room around the clock in a small button
|
|
@@ -164,74 +181,76 @@ const SmartButtonDefaults = {
|
|
|
164
181
|
|
|
165
182
|
const SmartButton = function (params = {}) {
|
|
166
183
|
|
|
167
|
-
// Merge params:
|
|
168
|
-
SmartButton.
|
|
169
|
-
|
|
184
|
+
// Merge params: style > tone > the template (styleName) > the defaults
|
|
185
|
+
SmartButton.applyLook(params);
|
|
186
|
+
const hasText = (params.labelText !== "");
|
|
187
|
+
// WHY: 44 is the height of a row; an icon above its text needs more (about 60)
|
|
188
|
+
if (params.iconPosition === "top" && hasText && params.height === undefined) params.height = "auto";
|
|
170
189
|
mergeIntoIfMissing(params, SmartButtonDefaults);
|
|
190
|
+
// AN ICON BUTTON (no text): a square when no width is given.
|
|
191
|
+
// WHY only with a number height: an "auto" one is as big as its padding and its icon (Ex: 10 + 24 + 10)
|
|
192
|
+
const isIconButton = !hasText && (typeof params.height === "number");
|
|
193
|
+
if (isIconButton && params.width === "auto") params.width = params.height;
|
|
171
194
|
|
|
172
195
|
// BOX: Component container
|
|
173
196
|
const box = startObject(params);
|
|
174
197
|
|
|
175
198
|
// *** PRIVATE VARIABLES:
|
|
176
199
|
const WAITING_MOTION = "opacity 0.2s"; // the content fades while waiting
|
|
177
|
-
const
|
|
200
|
+
const ASK_ANSWER_DELAY = 400; // ms: a click this soon after the question is the second click of a double click
|
|
201
|
+
const STILL_MOTION = "background-color 0.2s"; // the color under the mouse (animated: 0 too)
|
|
178
202
|
let cancelWaitingEnd = null;
|
|
179
203
|
let cancelAskTimer = null;
|
|
180
204
|
let askBubble = null;
|
|
205
|
+
let askStartTime = 0; // when the question was shown (isAnswerTooSoon)
|
|
181
206
|
let isHover = 0;
|
|
182
207
|
let isPressed = 0;
|
|
183
208
|
let isSpaceDown = 0; // Space went down on this button (it presses when it goes up, like a real button)
|
|
184
|
-
let
|
|
209
|
+
let isMotionStarted = 0; // the transitions are on after the first view (startMotion)
|
|
185
210
|
|
|
186
211
|
// *** PRIVATE FUNCTIONS:
|
|
187
212
|
|
|
213
|
+
const setText = function (label, text) {
|
|
214
|
+
const value = (text === undefined || text === null) ? "" : String(text);
|
|
215
|
+
if (box.allowHtml == 1) label.text = value;
|
|
216
|
+
else label.plainText = value;
|
|
217
|
+
};
|
|
218
|
+
|
|
188
219
|
const canPress = function () {
|
|
189
220
|
return box.enabled == 1 && box.waiting != 1;
|
|
190
221
|
};
|
|
191
222
|
|
|
192
223
|
const isReducedMotion = function () {
|
|
193
|
-
return
|
|
224
|
+
return SmartButton.isReducedMotion();
|
|
194
225
|
};
|
|
195
226
|
|
|
196
227
|
const isMotionOn = function () {
|
|
197
228
|
return box.animated == 1 && !isReducedMotion();
|
|
198
229
|
};
|
|
199
230
|
|
|
200
|
-
// THE LOOK OF THE STATE: disabled > asking >
|
|
201
|
-
|
|
231
|
+
// THE LOOK OF THE STATE: the normal look, and over it the keys of the state: disabled > asking > under the mouse.
|
|
232
|
+
// (style.disabled and style.ask.button have the key names of the look; pressed: getPressCss darkens it)
|
|
233
|
+
// WHY one order: an ask never meets a disabled or waiting button (setEnabled(0) and setWaiting(1) end it)
|
|
234
|
+
const getLook = function () {
|
|
202
235
|
const _s = box.style;
|
|
203
|
-
|
|
204
|
-
|
|
236
|
+
const look = {
|
|
237
|
+
color: _s.box.color,
|
|
238
|
+
border: _s.box.border,
|
|
239
|
+
borderColor: _s.box.borderColor,
|
|
240
|
+
boxShadow: _s.box.boxShadow,
|
|
241
|
+
textColor: _s.label.textColor,
|
|
242
|
+
iconOpacity: _s.icon.opacity,
|
|
243
|
+
iconFilter: _s.icon.filter,
|
|
244
|
+
};
|
|
245
|
+
// WHY no shadow when disabled: a flat button is not one that can be pressed in
|
|
246
|
+
if (box.enabled != 1) return Object.assign(look, _s.disabled, { boxShadow: "none" });
|
|
247
|
+
if (box.isAsking == 1) return Object.assign(look, _s.ask.button);
|
|
205
248
|
// WHY not while waiting: the button stays in its own color under the animation
|
|
206
|
-
if (box.waiting
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const getBorderColor = function () {
|
|
213
|
-
if (box.enabled != 1) return box.style.disabled.borderColor;
|
|
214
|
-
if (box.isAsking == 1) return box.style.ask.button.borderColor;
|
|
215
|
-
return box.style.box.borderColor;
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
// WHY none when disabled: a flat button is not one that can be pressed in
|
|
219
|
-
const getBoxShadow = function () {
|
|
220
|
-
if (box.enabled != 1) return "none";
|
|
221
|
-
if (box.isAsking == 1) return box.style.ask.button.boxShadow;
|
|
222
|
-
if (isPressed && canPress() && box.style.press.removeShadow == 1) return "none";
|
|
223
|
-
return box.style.box.boxShadow || "";
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
const getTextColor = function () {
|
|
227
|
-
if (box.enabled != 1) return box.style.disabled.textColor;
|
|
228
|
-
if (box.isAsking == 1) return box.style.ask.button.textColor;
|
|
229
|
-
return box.style.label.textColor;
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
const getIconOpacity = function () {
|
|
233
|
-
if (box.enabled != 1) return box.style.disabled.iconOpacity;
|
|
234
|
-
return (box.style.icon.opacity === undefined) ? 1 : box.style.icon.opacity;
|
|
249
|
+
if (isHover && box.waiting != 1) {
|
|
250
|
+
look.color = _s.hover.color;
|
|
251
|
+
if (_s.hover.borderColor) look.borderColor = _s.hover.borderColor;
|
|
252
|
+
}
|
|
253
|
+
return look;
|
|
235
254
|
};
|
|
236
255
|
|
|
237
256
|
// The press: smaller and darker while pressed (only with animated: 1)
|
|
@@ -243,22 +262,19 @@ const SmartButton = function (params = {}) {
|
|
|
243
262
|
};
|
|
244
263
|
};
|
|
245
264
|
|
|
246
|
-
const getIconFilter = function () {
|
|
247
|
-
if (box.isAsking == 1 && box.enabled == 1) return box.style.ask.button.iconFilter;
|
|
248
|
-
return box.style.icon.filter || "none";
|
|
249
|
-
};
|
|
250
|
-
|
|
251
265
|
// Everything that changes with the state: the box, the content, the press, the keyboard and the screen reader
|
|
252
266
|
const render = function () {
|
|
253
267
|
const isEnabled = (box.enabled == 1);
|
|
254
|
-
|
|
255
|
-
box.
|
|
256
|
-
box.
|
|
257
|
-
box.
|
|
258
|
-
|
|
268
|
+
const look = getLook();
|
|
269
|
+
box.color = look.color;
|
|
270
|
+
box.border = look.border;
|
|
271
|
+
box.borderColor = look.borderColor;
|
|
272
|
+
box.boxShadow = look.boxShadow;
|
|
273
|
+
box.css = getPressCss();
|
|
274
|
+
if (box.label) box.label.textColor = look.textColor;
|
|
259
275
|
if (box.icon) {
|
|
260
|
-
box.icon.opacity =
|
|
261
|
-
box.icon.css = { filter:
|
|
276
|
+
box.icon.opacity = look.iconOpacity;
|
|
277
|
+
box.icon.css = { filter: look.iconFilter };
|
|
262
278
|
}
|
|
263
279
|
box.layout.css = { filter: isEnabled ? "none" : "grayscale(1)" };
|
|
264
280
|
box.layout.opacity = (box.waiting == 1) ? box.style.waiting.contentOpacity : 1;
|
|
@@ -267,8 +283,42 @@ const SmartButton = function (params = {}) {
|
|
|
267
283
|
box.aria = { disabled: !isEnabled, label: box.ariaLabel || box.labelText || "" };
|
|
268
284
|
};
|
|
269
285
|
|
|
286
|
+
// The room inside: an icon button has none (its icon in the middle); an icon left of a text has a little less
|
|
287
|
+
// on its side (style.layout.iconSideTrim)
|
|
288
|
+
const paintPadding = function () {
|
|
289
|
+
if (isIconButton) {
|
|
290
|
+
box.layout.padding = 0;
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
const _l = box.style.layout;
|
|
294
|
+
const isIconLeft = box.icon && box.label && box.iconPosition !== "top";
|
|
295
|
+
const padding = Array.isArray(_l.padding) ? _l.padding[0] : _l.padding;
|
|
296
|
+
const trim = isIconLeft ? _l.iconSideTrim : 0;
|
|
297
|
+
box.layout.css = { paddingLeft: Math.max(0, padding - trim) + "px" };
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// The style on the objects (box, layout, icon, label, focus ring); render() gives the colors of the state.
|
|
301
|
+
const applyStyle = function () {
|
|
302
|
+
const _s = box.style;
|
|
303
|
+
box.props(_s.box);
|
|
304
|
+
box.layout.props(_s.layout);
|
|
305
|
+
paintPadding();
|
|
306
|
+
if (box.icon) box.icon.props(_s.icon);
|
|
307
|
+
if (box.label) box.label.props(_s.label);
|
|
308
|
+
box.setFocusRing(_s.focus.ringColor);
|
|
309
|
+
render();
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
// WHY: the second click of a double click answered the ask before it was read (SmartButton({ ask }) and a
|
|
313
|
+
// Dialog.confirm with danger and ask ran at once)
|
|
314
|
+
const isAnswerTooSoon = function (event) {
|
|
315
|
+
if (event && event.detail > 1) return true;
|
|
316
|
+
return (Date.now() - askStartTime < ASK_ANSWER_DELAY);
|
|
317
|
+
};
|
|
318
|
+
|
|
270
319
|
const press = function (event) {
|
|
271
320
|
if (!canPress()) return;
|
|
321
|
+
if (box.isAsking == 1 && isAnswerTooSoon(event)) return;
|
|
272
322
|
if (typeof box.onBeforeClick === "function" && box.onBeforeClick(box) === false) return;
|
|
273
323
|
if (box.ask && box.isAsking != 1) {
|
|
274
324
|
startAsk();
|
|
@@ -278,14 +328,14 @@ const SmartButton = function (params = {}) {
|
|
|
278
328
|
if (box.onClick) box.onClick(box, event);
|
|
279
329
|
};
|
|
280
330
|
|
|
281
|
-
// *** ASK (two clicks): the
|
|
331
|
+
// *** ASK (two clicks): the orange look (render) and the bubble (Tooltip.show)
|
|
282
332
|
|
|
283
333
|
const startAsk = function () {
|
|
284
334
|
// WHY one at a time: the bubble of another button would stay over this one
|
|
285
|
-
|
|
286
|
-
if (other && other !== box) other.cancelAsk();
|
|
335
|
+
if (SmartButton.askingButton) SmartButton.askingButton.cancelAsk();
|
|
287
336
|
SmartButton.askingButton = box;
|
|
288
337
|
box.isAsking = 1;
|
|
338
|
+
askStartTime = Date.now();
|
|
289
339
|
render();
|
|
290
340
|
if (typeof Tooltip !== "undefined") askBubble = Tooltip.show(box, box.ask, box.style.ask.bubble);
|
|
291
341
|
cancelAskTimer = box.after(box.style.ask.time, box.cancelAsk);
|
|
@@ -322,7 +372,8 @@ const SmartButton = function (params = {}) {
|
|
|
322
372
|
dot.style.cssText = "position: absolute; border-radius: 50%; pointer-events: none; background: " + getRippleColor() + ";" +
|
|
323
373
|
" left: " + (point.x - radius) + "px; top: " + (point.y - radius) + "px; width: " + (radius * 2) + "px; height: " + (radius * 2) + "px;";
|
|
324
374
|
layer.appendChild(dot);
|
|
325
|
-
|
|
375
|
+
// WHY under the waiting cover: onClick often starts it (no cover yet: the layer goes last, the cover comes over it)
|
|
376
|
+
elem.insertBefore(layer, box.waitingCover ? box.waitingCover.elem : null);
|
|
326
377
|
const wave = dot.animate([
|
|
327
378
|
{ transform: "scale(0)", opacity: 1 },
|
|
328
379
|
{ transform: "scale(1)", opacity: 0.7, offset: 0.6 },
|
|
@@ -331,53 +382,98 @@ const SmartButton = function (params = {}) {
|
|
|
331
382
|
wave.onfinish = function () { layer.remove(); };
|
|
332
383
|
};
|
|
333
384
|
|
|
334
|
-
// ***
|
|
385
|
+
// *** THE MOTION
|
|
335
386
|
|
|
336
|
-
// The press
|
|
387
|
+
// The transitions: the press (animated: 1, not with reduced motion) and the color under the mouse (always)
|
|
388
|
+
// WHY not setMotion(): it starts after a timer, and the press must answer the first click
|
|
337
389
|
const applyAnimated = function () {
|
|
338
|
-
if (!
|
|
339
|
-
if (!wasAnimated) return;
|
|
340
|
-
wasAnimated = 0;
|
|
341
|
-
render();
|
|
342
|
-
box.setMotionNow(STILL_MOTION);
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
wasAnimated = 1;
|
|
390
|
+
if (!isMotionStarted) return; // (startMotion turns them on)
|
|
346
391
|
const time = box.style.press.time + "s";
|
|
347
|
-
|
|
348
|
-
box.setMotionNow(
|
|
349
|
-
|
|
392
|
+
const pressMotion = isMotionOn() ? "transform " + time + ", filter " + time + ", box-shadow " + time + ", " : "";
|
|
393
|
+
box.setMotionNow(pressMotion + STILL_MOTION);
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
// The transitions start after the first view: a state set while the button is made (Ex: setEnabled(0) right
|
|
397
|
+
// after a Dialog is made) is drawn at once, not as a move from its first look (the Save
|
|
398
|
+
// button of a dialog turned from blue to gray when the dialog opened)
|
|
399
|
+
// WHY the frame and the read: the look of now must be the start of a transition, not the look before it
|
|
400
|
+
const startMotion = function () {
|
|
401
|
+
requestAnimationFrame(function () {
|
|
402
|
+
if (box._isRemoved) return;
|
|
403
|
+
void box.elem.offsetWidth; // (the browser takes the look of now)
|
|
404
|
+
isMotionStarted = 1;
|
|
405
|
+
box.layout.setMotionNow(WAITING_MOTION);
|
|
406
|
+
applyAnimated();
|
|
407
|
+
});
|
|
350
408
|
};
|
|
351
409
|
|
|
410
|
+
// *** WAITING
|
|
411
|
+
|
|
352
412
|
// The clock fits the button: at most its size, smaller in a small button (the dots keep their size)
|
|
353
413
|
const fitWaitingIcon = function () {
|
|
354
414
|
const icon = box.waitingCover.icon;
|
|
355
415
|
if (box.waitingType == "clock") {
|
|
356
416
|
const _w = box.style.waiting;
|
|
357
|
-
const
|
|
417
|
+
const room = Math.min(box.width, box.height) - _w.space;
|
|
418
|
+
const size = basic.clamp(room, 0, _w.clockSize);
|
|
358
419
|
icon.setSize(size, size);
|
|
359
420
|
}
|
|
360
421
|
icon.center();
|
|
361
422
|
};
|
|
362
423
|
|
|
424
|
+
// BOX: Waiting cover, made at the first wait: most buttons never wait (it is 2/3 of the objects of a button).
|
|
425
|
+
// Clear: the content fades under it; it holds the animation and takes the mouse.
|
|
426
|
+
const createWaitingCover = function () {
|
|
427
|
+
saveCurrentThat(); // WHY: a wait must not change `that` (Ex: that.setWaiting(1) right after create)
|
|
428
|
+
box.waitingCover = createIn(box, function () {
|
|
429
|
+
const cover = startBox(0, 0, "100%", "100%", {
|
|
430
|
+
color: "transparent",
|
|
431
|
+
clickable: 1, // WHY: it takes the mouse, so its "progress" cursor shows (the hover color: render())
|
|
432
|
+
cursor: "progress",
|
|
433
|
+
});
|
|
434
|
+
if (box.waitingType == "dots") {
|
|
435
|
+
cover.icon = SmartButton.createDots(box.style.waiting.dots);
|
|
436
|
+
} else {
|
|
437
|
+
const clockStyle = SmartButton.clocks[box.style.waiting.clock] || SmartButton.clocks.ozden;
|
|
438
|
+
cover.icon = Box(0, 0, 0, 0, { color: "transparent", html: SmartButton.createClockSvg(clockStyle) });
|
|
439
|
+
}
|
|
440
|
+
endBox();
|
|
441
|
+
return cover;
|
|
442
|
+
});
|
|
443
|
+
restoreThatFromSaved();
|
|
444
|
+
box.onResize(function () {
|
|
445
|
+
if (box.waiting == 1) fitWaitingIcon();
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
const startWaiting = function () {
|
|
450
|
+
box.cancelAsk();
|
|
451
|
+
box.waiting = 1;
|
|
452
|
+
box.aria = { busy: true };
|
|
453
|
+
if (!box.waitingCover) createWaitingCover();
|
|
454
|
+
box.waitingCover.visible = 1;
|
|
455
|
+
fitWaitingIcon();
|
|
456
|
+
render();
|
|
457
|
+
};
|
|
458
|
+
|
|
363
459
|
const endWaiting = function () {
|
|
364
460
|
box.waiting = 0;
|
|
365
461
|
box.aria = { busy: false };
|
|
366
462
|
box.waitingCover.visible = 0;
|
|
367
463
|
render();
|
|
368
|
-
box.onWaitingEnd(box);
|
|
464
|
+
if (typeof box.onWaitingEnd === "function") box.onWaitingEnd(box);
|
|
369
465
|
};
|
|
370
466
|
|
|
371
467
|
// *** PUBLIC FUNCTIONS:
|
|
372
468
|
|
|
373
469
|
box.isAsking = 0; // 1: the first click of ask was made, the button is red
|
|
374
470
|
|
|
375
|
-
box.
|
|
471
|
+
box.setLabelText = function (text) {
|
|
376
472
|
box.labelText = text;
|
|
377
|
-
if (box.label) box.label
|
|
473
|
+
if (box.label) setText(box.label, text);
|
|
378
474
|
render(); // (the label read by a screen reader)
|
|
379
475
|
};
|
|
380
|
-
|
|
476
|
+
// USAGE: button.setLabelText("Save")
|
|
381
477
|
|
|
382
478
|
box.setIcon = function (file) {
|
|
383
479
|
box.iconFile = file;
|
|
@@ -388,6 +484,7 @@ const SmartButton = function (params = {}) {
|
|
|
388
484
|
box.setAnimated = function (value) {
|
|
389
485
|
box.animated = basic.isOn(value) ? 1 : 0;
|
|
390
486
|
applyAnimated();
|
|
487
|
+
render(); // WHY: a button pressed now loses its press look with animated: 0
|
|
391
488
|
};
|
|
392
489
|
// USAGE: get: button.animated, set: button.setAnimated(0)
|
|
393
490
|
|
|
@@ -400,11 +497,8 @@ const SmartButton = function (params = {}) {
|
|
|
400
497
|
box.enabled = basic.isOn(value) ? 1 : 0;
|
|
401
498
|
if (box.enabled != 1) {
|
|
402
499
|
box.cancelAsk();
|
|
403
|
-
isHover = 0;
|
|
404
500
|
isPressed = 0;
|
|
405
501
|
isSpaceDown = 0;
|
|
406
|
-
} else {
|
|
407
|
-
isHover = box.elem.matches(":hover") ? 1 : 0; // WHY: the mouse may have stayed on it while it was off
|
|
408
502
|
}
|
|
409
503
|
render();
|
|
410
504
|
};
|
|
@@ -439,61 +533,40 @@ const SmartButton = function (params = {}) {
|
|
|
439
533
|
const superRemove = box.remove;
|
|
440
534
|
box.superRemove = superRemove;
|
|
441
535
|
box.remove = function () {
|
|
536
|
+
if (box.isRemoved) return;
|
|
442
537
|
box.cancelAsk();
|
|
443
538
|
superRemove.call(box);
|
|
444
539
|
};
|
|
445
540
|
|
|
446
|
-
// Only the given keys change; the other keys of the style stay.
|
|
541
|
+
// Only the given keys change; the other keys of the style stay, inside a part too (ask.button, waiting.dots).
|
|
447
542
|
// WHY a new object for each part: the old one can be shared with other buttons (the same style object of a page)
|
|
543
|
+
// WHY not Object.assign: it replaces ask.button whole, so { ask: { button: { color } } } would lose
|
|
544
|
+
// the white text and the white icon of the ask
|
|
448
545
|
box.setStyle = function (style) {
|
|
449
546
|
Object.keys(style || {}).forEach(function (part) {
|
|
450
|
-
|
|
547
|
+
const merged = {};
|
|
548
|
+
mergeIntoIfMissing(merged, style[part]); // the new keys first
|
|
549
|
+
mergeIntoIfMissing(merged, box.style[part]); // then the old ones under them
|
|
550
|
+
box.style[part] = merged;
|
|
451
551
|
});
|
|
452
552
|
applyStyle();
|
|
553
|
+
applyAnimated(); // WHY: style.press.time is in the transitions
|
|
453
554
|
};
|
|
454
555
|
// USAGE: button.setStyle({ box: { color: "tomato", borderColor: "red" }, hover: { color: "tomato" } })
|
|
455
556
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
box.
|
|
459
|
-
box.tone
|
|
460
|
-
if (toneName) box.setStyle(SmartButton.getToneStyle(toneName, box.styleName));
|
|
461
|
-
};
|
|
462
|
-
// USAGE: button.setTone("blue"), button.setTone("blue", "pillSolid"), button.setTone("", "pill") (only the package)
|
|
463
|
-
|
|
464
|
-
// The style on the objects (box, layout, icon, label, focus ring); render() gives the colors of the state.
|
|
465
|
-
// The side of the icon a little narrower (style.layout.iconSideTrim), only for an icon left of a text
|
|
466
|
-
const paintIconSide = function () {
|
|
467
|
-
const _l = box.style.layout;
|
|
468
|
-
const isIconLeft = box.icon && box.label && box.iconPosition !== "top";
|
|
469
|
-
const padding = Array.isArray(_l.padding) ? _l.padding[0] : _l.padding;
|
|
470
|
-
const trim = isIconLeft ? (Number(_l.iconSideTrim) || 0) : 0;
|
|
471
|
-
box.layout.css = { paddingLeft: Math.max(0, padding - trim) + "px" };
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
const applyStyle = function () {
|
|
475
|
-
const _s = box.style;
|
|
476
|
-
box.props(_s.box);
|
|
477
|
-
box.layout.props(_s.layout);
|
|
478
|
-
paintIconSide();
|
|
479
|
-
if (box.icon) box.icon.props(_s.icon);
|
|
480
|
-
if (box.label) box.label.props(_s.label);
|
|
481
|
-
box.setFocusRing(_s.focus.ringColor);
|
|
482
|
-
render();
|
|
557
|
+
// The two colors of a tone (a color of the page given with style goes)
|
|
558
|
+
box.setTone = function (toneName) {
|
|
559
|
+
box.tone = toneName || "";
|
|
560
|
+
box.setStyle(SmartButton.getToneStyle(box.tone, box.styleName));
|
|
483
561
|
};
|
|
562
|
+
// USAGE: button.setTone("green"), button.setTone("") (the gray of its template)
|
|
484
563
|
|
|
485
564
|
// delay: ms before the wait ends (only for 0)
|
|
486
565
|
box.setWaiting = function (value, delay = 0) {
|
|
487
|
-
const isWaiting = basic.isOn(value) ? 1 : 0;
|
|
488
566
|
if (cancelWaitingEnd) cancelWaitingEnd();
|
|
489
567
|
cancelWaitingEnd = null;
|
|
490
|
-
if (
|
|
491
|
-
|
|
492
|
-
box.waiting = 1;
|
|
493
|
-
box.aria = { busy: true };
|
|
494
|
-
box.waitingCover.visible = 1;
|
|
495
|
-
fitWaitingIcon();
|
|
496
|
-
render();
|
|
568
|
+
if (basic.isOn(value)) {
|
|
569
|
+
startWaiting();
|
|
497
570
|
return;
|
|
498
571
|
}
|
|
499
572
|
if (box.waiting != 1) return;
|
|
@@ -501,22 +574,15 @@ const SmartButton = function (params = {}) {
|
|
|
501
574
|
endWaiting();
|
|
502
575
|
return;
|
|
503
576
|
}
|
|
504
|
-
cancelWaitingEnd = box.after(delay,
|
|
505
|
-
cancelWaitingEnd = null;
|
|
506
|
-
endWaiting();
|
|
507
|
-
});
|
|
577
|
+
cancelWaitingEnd = box.after(delay, endWaiting);
|
|
508
578
|
};
|
|
509
579
|
// USAGE: get: button.waiting, set: button.setWaiting(1) / button.setWaiting(0, 1000)
|
|
510
580
|
|
|
511
581
|
// *** OBJECT VIEW:
|
|
512
582
|
|
|
513
|
-
// BOX: Container look
|
|
514
|
-
box.props(box.style.box);
|
|
583
|
+
// BOX: Container (its look: applyStyle(), when its objects are made)
|
|
515
584
|
box.clickable = 1;
|
|
516
585
|
box.role = "button";
|
|
517
|
-
box.setFocusRing(box.style.focus.ringColor);
|
|
518
|
-
// (the transitions: applyAnimated(); WHY not setMotion() here: its timer came after them and wrote over them)
|
|
519
|
-
box.setMotionNow(STILL_MOTION);
|
|
520
586
|
|
|
521
587
|
// GROUP: Layout (icon, label). iconPosition "top" puts the icon above the label.
|
|
522
588
|
// WHY "100%" for a fixed size: the group fills the inside of the border; with the size of the box itself it was
|
|
@@ -538,32 +604,19 @@ const SmartButton = function (params = {}) {
|
|
|
538
604
|
// LABEL: only when there is a text
|
|
539
605
|
if (box.labelText) {
|
|
540
606
|
box.label = Label(0, 0, box.style.label);
|
|
541
|
-
box.label
|
|
607
|
+
setText(box.label, box.labelText);
|
|
542
608
|
box.label.css.whiteSpace = "nowrap";
|
|
543
609
|
}
|
|
544
610
|
|
|
545
611
|
endAutoLayout();
|
|
546
|
-
|
|
547
|
-
paintIconSide();
|
|
548
|
-
|
|
549
|
-
// BOX: Waiting cover (clear: the content fades under it; it holds the animation and takes the mouse)
|
|
550
|
-
box.waitingCover = startBox(0, 0, "100%", "100%", {
|
|
551
|
-
color: "transparent",
|
|
552
|
-
clickable: 1, // WHY: the button under it gets no hover look while waiting
|
|
553
|
-
cursor: "progress",
|
|
554
|
-
});
|
|
555
|
-
if (box.waitingType == "dots") {
|
|
556
|
-
box.waitingCover.icon = SmartButton.createDots(box.style.waiting.dots);
|
|
557
|
-
} else {
|
|
558
|
-
const clock = Box(0, 0, 0, 0, { color: "transparent" });
|
|
559
|
-
clock.elem.innerHTML = SmartButton.createClockSvg(SmartButton.clocks[box.waitingClock] || SmartButton.clocks.ozden);
|
|
560
|
-
box.waitingCover.icon = clock;
|
|
561
|
-
}
|
|
562
|
-
endBox();
|
|
563
|
-
box.waitingCover.visible = 0;
|
|
612
|
+
// (the waiting cover: createWaitingCover(), at the first wait)
|
|
564
613
|
|
|
565
614
|
// *** OBJECT INIT CODE:
|
|
566
615
|
|
|
616
|
+
// WHY the look before the transitions: nothing fades in at the first view
|
|
617
|
+
applyStyle();
|
|
618
|
+
startMotion();
|
|
619
|
+
|
|
567
620
|
box.on("click", function (self, event) {
|
|
568
621
|
press(event);
|
|
569
622
|
});
|
|
@@ -591,10 +644,6 @@ const SmartButton = function (params = {}) {
|
|
|
591
644
|
isSpaceDown = 0;
|
|
592
645
|
});
|
|
593
646
|
|
|
594
|
-
box.onResize(function () {
|
|
595
|
-
if (box.waiting == 1) fitWaitingIcon();
|
|
596
|
-
});
|
|
597
|
-
|
|
598
647
|
// THE MOUSE: hover, pressed, back to normal (render)
|
|
599
648
|
box.onHoverChange(function (self, isOver) {
|
|
600
649
|
isHover = isOver;
|
|
@@ -612,13 +661,7 @@ const SmartButton = function (params = {}) {
|
|
|
612
661
|
render();
|
|
613
662
|
});
|
|
614
663
|
|
|
615
|
-
|
|
616
|
-
render();
|
|
617
|
-
|
|
618
|
-
if (box.waiting == 1) {
|
|
619
|
-
box.waiting = 0;
|
|
620
|
-
box.setWaiting(1);
|
|
621
|
-
}
|
|
664
|
+
if (box.waiting == 1) box.setWaiting(1);
|
|
622
665
|
|
|
623
666
|
return endObject(box);
|
|
624
667
|
|
|
@@ -628,6 +671,13 @@ const SmartButton = function (params = {}) {
|
|
|
628
671
|
|
|
629
672
|
SmartButton.askingButton = null; // the button that asks now (ask: one at a time)
|
|
630
673
|
|
|
674
|
+
// WHY one query for the page: render() asks it at every hover and press
|
|
675
|
+
SmartButton.isReducedMotion = function () {
|
|
676
|
+
if (!window.matchMedia) return false;
|
|
677
|
+
if (!SmartButton.reducedMotionQuery) SmartButton.reducedMotionQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
678
|
+
return SmartButton.reducedMotionQuery.matches;
|
|
679
|
+
};
|
|
680
|
+
|
|
631
681
|
// 1: a dark color (the ripple is light on it). A color of the browser: "rgb(r, g, b)" or "rgba(r, g, b, a)".
|
|
632
682
|
// A transparent color is not dark (the page under it shows).
|
|
633
683
|
SmartButton.DARK_LIMIT = 0.45; // the brightness (0 - 1) under it a color is dark
|
|
@@ -658,181 +708,188 @@ SmartButton.injectCss = function () {
|
|
|
658
708
|
"@media (prefers-reduced-motion: reduce) { .smart-button-hand, .smart-button-dot { animation: none !important; } }");
|
|
659
709
|
};
|
|
660
710
|
|
|
661
|
-
// *** THE
|
|
662
|
-
//
|
|
711
|
+
// *** THE TEMPLATES (the shapes), all gray. A template is a style with only the keys that differ from the default
|
|
712
|
+
// (ozden); its color comes from a tone or from style. Every template has the default height (44).
|
|
713
|
+
SmartButton.WHITE_ICON = "brightness(0) invert(1)"; // a CSS filter: any icon file turns white
|
|
714
|
+
SmartButton.ROUND = 100; // pill, outlined: always round, at any height
|
|
715
|
+
SmartButton.EDGE_WIDTH = 2; // outlined: the edge and the line at its bottom
|
|
716
|
+
|
|
663
717
|
SmartButton.styles = {
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
718
|
+
// (the buttons of _basic/examples/smart-button-3-ozden.htm)
|
|
719
|
+
ozden: SmartButtonDefaults.style, // an edge and a bottom line
|
|
720
|
+
ozden2: { box: { boxShadow: "none" } }, // only the edge
|
|
721
|
+
ozden3: { box: { borderColor: Black(0.1), boxShadow: "none" } }, // a faint edge
|
|
722
|
+
ozden4: { box: { color: White(0), border: 0, borderColor: "transparent", boxShadow: "none" } }, // a ghost
|
|
723
|
+
// ROUND (the buttons of _basic/examples/smart-button-alternatif.htm). WHY a smaller text
|
|
724
|
+
// and icon: they were 52 px high with a 30 px icon; now as high as the other buttons
|
|
725
|
+
pill: { // no edge, a bold text
|
|
726
|
+
layout: { gap: 10, padding: [18, 0] },
|
|
727
|
+
icon: { width: 26, height: 26, opacity: 1 },
|
|
728
|
+
label: { fontSize: 18, fontFamily: "opensans-bold" },
|
|
729
|
+
box: { border: 0, borderColor: "transparent", round: SmartButton.ROUND, boxShadow: "none" },
|
|
730
|
+
},
|
|
731
|
+
outlined: { // a thicker edge with a line at its bottom
|
|
732
|
+
layout: { gap: 8, padding: [14, 0] },
|
|
733
|
+
icon: { width: 26, height: 26, opacity: 1 },
|
|
734
|
+
label: { fontSize: 18 },
|
|
735
|
+
box: { border: SmartButton.EDGE_WIDTH, round: SmartButton.ROUND, boxShadow: "inset 0 -" + SmartButton.EDGE_WIDTH + "px 0 " + Black(0.35) },
|
|
675
736
|
},
|
|
676
737
|
};
|
|
677
738
|
|
|
678
|
-
// THE DARK
|
|
739
|
+
// THE DARK TEMPLATES (the draft _designs/smart-button-dark.htm): the shapes of ozden ... ozden4 with the
|
|
679
740
|
// colors of a dark page (the cards of Ozden Panel / Ozden Manager, #1A1A19). The icon turns white, the waiting clock
|
|
680
|
-
// is the dark one, the dots yellow; the ask stays
|
|
681
|
-
|
|
741
|
+
// is the dark one, the dots yellow; the ask stays orange.
|
|
742
|
+
// THE EDGE AND THE BOTTOM LINE: the edge of ozden in white and its 2 px line in white, a
|
|
743
|
+
// little fainter. A light tone on a dark template keeps them too.
|
|
744
|
+
// WHY 0.2 / 0.12 (0.35 / 0.2 were too bright on a dark page; a white edge on a dark page is
|
|
745
|
+
// much stronger than the same black on a light one): still twice the faint edge of ozden3Dark (0.1).
|
|
746
|
+
SmartButton.DARK_EDGE = White(0.2);
|
|
747
|
+
SmartButton.DARK_BOTTOM_LINE = "inset 0 -2px 0 " + White(0.12);
|
|
748
|
+
// boxKeys: only the keys of the box that differ from ozdenDark (as the light templates from ozden)
|
|
749
|
+
SmartButton.createDarkTemplate = function (boxKeys, hoverColor = "#383835") {
|
|
682
750
|
return {
|
|
751
|
+
box: Object.assign({ color: "#2E2E2C", borderColor: SmartButton.DARK_EDGE, boxShadow: SmartButton.DARK_BOTTOM_LINE }, boxKeys),
|
|
752
|
+
hover: { color: hoverColor },
|
|
753
|
+
label: { textColor: White(0.85) },
|
|
754
|
+
icon: { opacity: 0.85, filter: SmartButton.WHITE_ICON },
|
|
755
|
+
focus: { ringColor: "rgba(101, 162, 147, 0.75)" },
|
|
756
|
+
disabled: { color: "#232322", borderColor: White(0.06), textColor: White(0.28), iconOpacity: 0.25 },
|
|
757
|
+
press: { brightness: 0.88 },
|
|
758
|
+
waiting: { clock: "ozdenDark", dots: { color: "#F1C74A" } },
|
|
759
|
+
};
|
|
760
|
+
};
|
|
761
|
+
SmartButton.styles.ozdenDark = SmartButton.createDarkTemplate({}); // an edge and a bottom line
|
|
762
|
+
SmartButton.styles.ozden2Dark = SmartButton.createDarkTemplate({ boxShadow: "none" }); // only the edge
|
|
763
|
+
SmartButton.styles.ozden3Dark = SmartButton.createDarkTemplate({ borderColor: White(0.1), boxShadow: "none" }); // a faint edge: the 0.1 of ozden3 in white
|
|
764
|
+
SmartButton.styles.ozden4Dark = SmartButton.createDarkTemplate({ color: White(0), border: 0, borderColor: "transparent", boxShadow: "none" }, White(0.08)); // a ghost
|
|
765
|
+
|
|
766
|
+
// THE MINIMAL TEMPLATES (the draft _designs/minimal-theme.htm): small (28 px, a 13 px text, a 14 px icon) and made of
|
|
767
|
+
// lines: no fill, the edge gets darker under the mouse, a blue focus ring, a ring that waits. The main action takes the
|
|
768
|
+
// tone "ink" (inkDark on a dark page): the only filled button of the theme.
|
|
769
|
+
SmartButton.MINIMAL_DANGER = "#C24A36"; // the ask of the minimal templates (on light and dark windows: a white text)
|
|
770
|
+
SmartButton.createMinimalTemplate = function (colors) {
|
|
771
|
+
const danger = SmartButton.MINIMAL_DANGER;
|
|
772
|
+
return {
|
|
773
|
+
height: 28,
|
|
683
774
|
style: {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
focus: { ringColor:
|
|
690
|
-
disabled: { color: "
|
|
691
|
-
press: {
|
|
692
|
-
waiting: {
|
|
775
|
+
layout: { gap: 6, padding: [10, 0], iconSideTrim: 0 },
|
|
776
|
+
icon: { width: 14, height: 14, opacity: 1, filter: colors.iconFilter },
|
|
777
|
+
label: { fontSize: 13, textColor: colors.text },
|
|
778
|
+
box: { color: "transparent", border: 1, borderColor: colors.line, round: 4, boxShadow: "none" },
|
|
779
|
+
hover: { color: "transparent", borderColor: colors.lineHover },
|
|
780
|
+
focus: { ringColor: colors.focus },
|
|
781
|
+
disabled: { color: "transparent", borderColor: colors.disabledLine, textColor: colors.disabledText, iconOpacity: 0.4 },
|
|
782
|
+
press: { scale: 0.97, brightness: 1 },
|
|
783
|
+
waiting: { clock: colors.clock, contentOpacity: 0.12, clockSize: 16, space: 6 },
|
|
784
|
+
ask: {
|
|
785
|
+
button: { color: danger, borderColor: danger, boxShadow: "none", textColor: "white", iconFilter: SmartButton.WHITE_ICON },
|
|
786
|
+
bubble: { color: danger, textColor: "white", fontSize: 12, bold: 0, round: 4, padding: [8, 4], border: 0, borderColor: "", shadow: "none", arrow: 8, gap: 4, edge: 6 },
|
|
787
|
+
},
|
|
693
788
|
},
|
|
694
|
-
waitingClock: "ozdenDark",
|
|
695
789
|
};
|
|
696
790
|
};
|
|
697
|
-
SmartButton.styles.
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
//
|
|
706
|
-
|
|
707
|
-
SmartButton.
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
791
|
+
SmartButton.styles.minimal = SmartButton.createMinimalTemplate({
|
|
792
|
+
text: Black(0.85), line: Black(0.2), lineHover: Black(0.45), focus: "#3D8BD9",
|
|
793
|
+
disabledLine: Black(0.08), disabledText: Black(0.34), iconFilter: "none", clock: "minimal",
|
|
794
|
+
});
|
|
795
|
+
SmartButton.styles.minimalDark = SmartButton.createMinimalTemplate({
|
|
796
|
+
text: White(0.88), line: White(0.18), lineHover: White(0.42), focus: "#7FB6DE",
|
|
797
|
+
disabledLine: White(0.07), disabledText: White(0.35), iconFilter: SmartButton.WHITE_ICON, clock: "minimalDark",
|
|
798
|
+
});
|
|
799
|
+
// A delete in the minimal theme: the line and the text in the danger color (the line half of it, all of it under the
|
|
800
|
+
// mouse). The icon keeps the color of its file: give it an icon drawn in the danger color.
|
|
801
|
+
SmartButton.styles.minimalDanger = SmartButton.createMinimalTemplate({
|
|
802
|
+
text: "#C24A36", line: "rgba(194, 74, 54, 0.5)", lineHover: "#C24A36", focus: "#3D8BD9",
|
|
803
|
+
disabledLine: Black(0.08), disabledText: Black(0.34), iconFilter: "none", clock: "minimal",
|
|
804
|
+
});
|
|
805
|
+
SmartButton.styles.minimalDangerDark = SmartButton.createMinimalTemplate({
|
|
806
|
+
text: "#FF9F93", line: "rgba(255, 159, 147, 0.5)", lineHover: "#FF9F93", focus: "#7FB6DE",
|
|
807
|
+
disabledLine: White(0.07), disabledText: White(0.35), iconFilter: "none", clock: "minimalDark",
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
// *** THE TONES: the colors of the kit, with simple color names; a tone for a dark page ends
|
|
811
|
+
// with "Dark". A tone is three colors: the button, the button under the mouse and its text (DARK_TEXT, or LIGHT_TEXT:
|
|
812
|
+
// it turns the icon white too). The light ones are white and the colors of the situations (chosen on the draft
|
|
813
|
+
// _designs/smart-button-colors.htm). Any other color: style (Ex: _basic/examples/smart-button-alternatif.htm).
|
|
814
|
+
SmartButton.DARK_TEXT = Black(0.75);
|
|
815
|
+
SmartButton.LIGHT_TEXT = White(0.9);
|
|
816
|
+
SmartButton.tones = {
|
|
817
|
+
white: { color: "white", hover: "whitesmoke", text: SmartButton.DARK_TEXT },
|
|
818
|
+
cyan: { color: "#5BBAC1", hover: "#50AEB5", text: SmartButton.DARK_TEXT }, // the main action: Save, Send
|
|
819
|
+
orange: { color: "#DE815B", hover: "#D4724B", text: SmartButton.DARK_TEXT }, // a delete, a reject
|
|
820
|
+
yellow: { color: "#F1C74A", hover: "#E6BB3C", text: SmartButton.DARK_TEXT }, // go on, but look first
|
|
821
|
+
green: { color: "#7BC362", hover: "#70B756", text: SmartButton.DARK_TEXT }, // after a good result: Done
|
|
822
|
+
blue: { color: "#52A8D0", hover: "#479CC4", text: SmartButton.DARK_TEXT }, // nothing changes: Details, Help
|
|
823
|
+
// For a dark page: the same colors, 45 % over the dark card #1A1A19 (53 % under the mouse); chosen by the user on
|
|
824
|
+
// the draft _designs/smart-button2-dark-tones.htm.
|
|
825
|
+
// WHY 45 %: the light text reads on every one of them (contrast 4.8 - 6.7; 4.5 is enough)
|
|
826
|
+
cyanDark: { color: "#376265", hover: "#3C6F72", text: SmartButton.LIGHT_TEXT },
|
|
827
|
+
orangeDark: { color: "#724837", hover: "#82513C", text: SmartButton.LIGHT_TEXT },
|
|
828
|
+
yellowDark: { color: "#7B682F", hover: "#8C7633", text: SmartButton.LIGHT_TEXT },
|
|
829
|
+
greenDark: { color: "#46663A", hover: "#4D7440", text: SmartButton.LIGHT_TEXT },
|
|
830
|
+
blueDark: { color: "#335A6B", hover: "#38657A", text: SmartButton.LIGHT_TEXT },
|
|
831
|
+
// The main action of the minimal templates (the ink of the theme). edge / hoverEdge: the edge in the color of the
|
|
832
|
+
// button (a line of the template around a filled button looked like a frame)
|
|
833
|
+
ink: { color: "#1F1F1F", hover: "#3A3A3A", text: SmartButton.LIGHT_TEXT, edge: "#1F1F1F", hoverEdge: "#3A3A3A" },
|
|
834
|
+
inkDark: { color: "#EDEDEB", hover: "#FFFFFF", text: "#1A1A19", edge: "#EDEDEB", hoverEdge: "#FFFFFF" },
|
|
725
835
|
};
|
|
726
836
|
|
|
727
|
-
//
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
hover: { color: tone.solidHover },
|
|
735
|
-
active: { color: tone.solidHover },
|
|
736
|
-
label: { textColor: textColor },
|
|
737
|
-
icon: { opacity: isWhiteText ? 1 : 0.8, filter: isWhiteText ? "brightness(0) invert(1)" : "none" },
|
|
738
|
-
};
|
|
739
|
-
},
|
|
740
|
-
ozdenType4: function (tone) {
|
|
741
|
-
return {
|
|
742
|
-
hover: { color: tone.tint },
|
|
743
|
-
active: { color: tone.tint },
|
|
744
|
-
label: { textColor: tone.deep },
|
|
745
|
-
};
|
|
746
|
-
},
|
|
747
|
-
pill: function (tone) {
|
|
748
|
-
return {
|
|
749
|
-
box: { color: tone.tint },
|
|
750
|
-
hover: { color: tone.hover },
|
|
751
|
-
active: { color: tone.hover },
|
|
752
|
-
label: { textColor: tone.pillText || tone.color },
|
|
753
|
-
};
|
|
754
|
-
},
|
|
755
|
-
pillSolid: function (tone) {
|
|
756
|
-
return {
|
|
757
|
-
box: { color: tone.color },
|
|
758
|
-
hover: { color: tone.solidHover },
|
|
759
|
-
active: { color: tone.solidHover },
|
|
760
|
-
label: { textColor: tone.onColor || "white" },
|
|
761
|
-
};
|
|
762
|
-
},
|
|
763
|
-
outlined: function (tone) {
|
|
764
|
-
return {
|
|
765
|
-
box: { color: tone.tint, borderColor: tone.color, boxShadow: "inset 0 -" + SmartButton.EDGE_WIDTH + "px 0 " + tone.color },
|
|
766
|
-
hover: { color: tone.hover },
|
|
767
|
-
active: { color: tone.hover },
|
|
768
|
-
label: { textColor: tone.deep },
|
|
769
|
-
};
|
|
770
|
-
},
|
|
837
|
+
// THE LOOK, the one place of its order: style > tone > the template (styleName) > the defaults. It fills params.style
|
|
838
|
+
// and returns params (getTemplateColors reads a template with it too).
|
|
839
|
+
SmartButton.applyLook = function (params) {
|
|
840
|
+
SmartButton.applyTone(params);
|
|
841
|
+
basic.applyStylePackage(params, SmartButton.styles, SmartButtonDefaults);
|
|
842
|
+
mergeIntoIfMissing(params.style, SmartButtonDefaults.style);
|
|
843
|
+
return params;
|
|
771
844
|
};
|
|
772
845
|
|
|
846
|
+
// A tone as a style. No tone: the colors of the template (setTone("") makes a button gray again).
|
|
773
847
|
SmartButton.getToneStyle = function (toneName, styleName) {
|
|
774
|
-
|
|
848
|
+
if (!toneName) return SmartButton.getTemplateColors(styleName);
|
|
849
|
+
const tone = SmartButton.tones[toneName];
|
|
775
850
|
if (!tone) {
|
|
776
851
|
console.warn("SmartButton: tone not found: " + toneName);
|
|
777
852
|
return {};
|
|
778
853
|
}
|
|
779
|
-
|
|
780
|
-
|
|
854
|
+
// WHY the icon: an icon file is drawn dark; with a light text it turns white
|
|
855
|
+
const isLightText = (tone.text === SmartButton.LIGHT_TEXT);
|
|
856
|
+
const toneStyle = {
|
|
857
|
+
box: { color: tone.color },
|
|
858
|
+
hover: { color: tone.hover },
|
|
859
|
+
label: { textColor: tone.text },
|
|
860
|
+
icon: { filter: isLightText ? SmartButton.WHITE_ICON : "none" },
|
|
861
|
+
};
|
|
862
|
+
if (tone.edge) {
|
|
863
|
+
toneStyle.box.borderColor = tone.edge;
|
|
864
|
+
toneStyle.hover.borderColor = tone.hoverEdge || tone.edge;
|
|
865
|
+
}
|
|
866
|
+
return toneStyle;
|
|
781
867
|
};
|
|
782
868
|
|
|
783
|
-
// The
|
|
784
|
-
SmartButton.
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
869
|
+
// The colors of a template: the button, the button under the mouse, its text and its icon
|
|
870
|
+
SmartButton.getTemplateColors = function (styleName) {
|
|
871
|
+
const template = SmartButton.applyLook({ styleName: styleName }).style;
|
|
872
|
+
return {
|
|
873
|
+
box: { color: template.box.color },
|
|
874
|
+
hover: { color: template.hover.color },
|
|
875
|
+
label: { textColor: template.label.textColor },
|
|
876
|
+
icon: { filter: template.icon.filter },
|
|
877
|
+
};
|
|
790
878
|
};
|
|
791
879
|
|
|
792
|
-
// The tone goes under
|
|
880
|
+
// The tone goes under the style of the page, so a color the page gives still wins.
|
|
881
|
+
// WHY a new object: params.style can be a template given as it is (style: SmartButton.styles.ozden2)
|
|
793
882
|
SmartButton.applyTone = function (params) {
|
|
794
883
|
if (!params.tone) return;
|
|
795
|
-
const styleName = params.styleName || SmartButtonDefaults.styleName;
|
|
796
884
|
const ownStyle = {};
|
|
797
885
|
mergeIntoIfMissing(ownStyle, params.style || {});
|
|
798
|
-
mergeIntoIfMissing(ownStyle, SmartButton.getToneStyle(params.tone
|
|
886
|
+
mergeIntoIfMissing(ownStyle, SmartButton.getToneStyle(params.tone));
|
|
799
887
|
params.style = ownStyle;
|
|
800
888
|
};
|
|
801
889
|
|
|
802
|
-
// THE SITUATION PACKAGES: ozdenType1 (an edge and a bottom line) in the color of a situation.
|
|
803
|
-
["primary", "danger", "warning", "success", "info"].forEach(function (toneName) {
|
|
804
|
-
SmartButton.styles[toneName] = SmartButton.toneLooks.filled(SmartButton.TONES[toneName]);
|
|
805
|
-
});
|
|
806
|
-
|
|
807
|
-
// THE PILL AND OUTLINED SHAPES (the user: the buttons of _basic/examples/smart-button.htm): gray without a tone.
|
|
808
|
-
SmartButton.PILL_ROUND = 100; // always round, at any height
|
|
809
|
-
SmartButton.EDGE_WIDTH = 2; // outlined: the edge and the bottom line on it
|
|
810
|
-
|
|
811
|
-
SmartButton.PILL_SHAPE = {
|
|
812
|
-
layout: { gap: 12, padding: [22, 11] },
|
|
813
|
-
icon: { width: 30, height: 30, opacity: 1 },
|
|
814
|
-
label: { fontFamily: "opensans-bold" },
|
|
815
|
-
box: { border: 0, borderColor: "transparent", round: SmartButton.PILL_ROUND, boxShadow: "none" },
|
|
816
|
-
};
|
|
817
|
-
SmartButton.OUTLINED_SHAPE = {
|
|
818
|
-
layout: { gap: 8, padding: [16, 9] },
|
|
819
|
-
icon: { width: 30, height: 30, opacity: 1 },
|
|
820
|
-
label: { fontFamily: "opensans" },
|
|
821
|
-
box: { border: SmartButton.EDGE_WIDTH, round: SmartButton.PILL_ROUND },
|
|
822
|
-
};
|
|
823
|
-
SmartButton.createShapePackage = function (shape, look) {
|
|
824
|
-
const shapePackage = {};
|
|
825
|
-
mergeIntoIfMissing(shapePackage, look);
|
|
826
|
-
mergeIntoIfMissing(shapePackage, shape);
|
|
827
|
-
return shapePackage;
|
|
828
|
-
};
|
|
829
|
-
SmartButton.styles.pill = SmartButton.createShapePackage(SmartButton.PILL_SHAPE, SmartButton.toneLooks.pill(SmartButton.TONES.gray));
|
|
830
|
-
SmartButton.styles.pillSolid = SmartButton.createShapePackage(SmartButton.PILL_SHAPE, SmartButton.toneLooks.pillSolid(SmartButton.TONES.gray));
|
|
831
|
-
SmartButton.styles.outlined = SmartButton.createShapePackage(SmartButton.OUTLINED_SHAPE, SmartButton.toneLooks.outlined(SmartButton.TONES.gray));
|
|
832
|
-
|
|
833
890
|
// *** THE WAITING DRAWINGS: the clock and the dots (comp/loading-screen.js uses them too)
|
|
834
891
|
|
|
835
|
-
// The clocks of the waiting views with moving hands
|
|
892
|
+
// The clocks of the waiting views with moving hands. The sizes are px on a 30 px clock.
|
|
836
893
|
SmartButton.clocks = {
|
|
837
894
|
ozden: { // a white face, dark lines
|
|
838
895
|
faceColor: "#FFFFFF",
|
|
@@ -849,7 +906,7 @@ SmartButton.clocks = {
|
|
|
849
906
|
hourTurn: 19.2, // seconds for one turn of the hour hand (12 x minuteTurn: a real clock)
|
|
850
907
|
},
|
|
851
908
|
};
|
|
852
|
-
// a dark face, light lines; WHY yellow
|
|
909
|
+
// a dark face, light lines; WHY yellow: indianred was weak on the dark face (contrast 3.6,
|
|
853
910
|
// #F1C74A 8.9); the hour hand is dimmer, so the yellow minute hand leads (as the red one on the light clock)
|
|
854
911
|
SmartButton.clocks.ozdenDark = Object.assign({}, SmartButton.clocks.ozden, {
|
|
855
912
|
faceColor: "#2A2A2A",
|
|
@@ -859,10 +916,22 @@ SmartButton.clocks.ozdenDark = Object.assign({}, SmartButton.clocks.ozden, {
|
|
|
859
916
|
centerColor: "#F1C74A",
|
|
860
917
|
});
|
|
861
918
|
|
|
919
|
+
// The waiting ring of the minimal templates: a faint circle and a quarter arc turning on it, in the color of the text
|
|
920
|
+
// (isRing: SmartButton.createRingSvg draws it in place of a clock).
|
|
921
|
+
SmartButton.clocks.minimal = {
|
|
922
|
+
isRing: 1,
|
|
923
|
+
lineColor: Black(0.85),
|
|
924
|
+
edgeWidth: 3, // on the 30 px drawing (1.6 px at 16 px)
|
|
925
|
+
trackOpacity: 0.2, // the circle under the arc
|
|
926
|
+
turnTime: 0.8, // seconds for one turn of the arc
|
|
927
|
+
};
|
|
928
|
+
SmartButton.clocks.minimalDark = Object.assign({}, SmartButton.clocks.minimal, { lineColor: White(0.88) });
|
|
929
|
+
|
|
862
930
|
// The clock as an SVG text (as wide as its box): a face with an edge, the minute hand up, the hour hand to the right.
|
|
863
931
|
SmartButton.CLOCK_SIZE = 30; // the px of the drawing
|
|
864
932
|
SmartButton.createClockSvg = function (clockStyle) {
|
|
865
933
|
SmartButton.injectCss();
|
|
934
|
+
if (clockStyle.isRing) return SmartButton.createRingSvg(clockStyle);
|
|
866
935
|
const c = clockStyle;
|
|
867
936
|
const size = SmartButton.CLOCK_SIZE;
|
|
868
937
|
const middle = size / 2;
|
|
@@ -879,6 +948,18 @@ SmartButton.createClockSvg = function (clockStyle) {
|
|
|
879
948
|
"</svg>";
|
|
880
949
|
};
|
|
881
950
|
|
|
951
|
+
// A ring that waits: a faint circle and a quarter arc turning on it (the turn of the hands of the clock)
|
|
952
|
+
SmartButton.createRingSvg = function (ring) {
|
|
953
|
+
const size = SmartButton.CLOCK_SIZE;
|
|
954
|
+
const middle = size / 2;
|
|
955
|
+
const radius = middle - ring.edgeWidth / 2;
|
|
956
|
+
const arc = "M" + middle + " " + (middle - radius) + " A" + radius + " " + radius + " 0 0 1 " + (middle + radius) + " " + middle;
|
|
957
|
+
return '<svg viewBox="0 0 ' + size + ' ' + size + '" width="100%" height="100%" aria-hidden="true" style="display: block">' +
|
|
958
|
+
'<circle cx="' + middle + '" cy="' + middle + '" r="' + radius + '" fill="none" stroke="' + ring.lineColor + '" stroke-opacity="' + ring.trackOpacity + '" stroke-width="' + ring.edgeWidth + '"/>' +
|
|
959
|
+
'<path class="smart-button-hand" d="' + arc + '" fill="none" stroke="' + ring.lineColor + '" stroke-width="' + ring.edgeWidth + '" stroke-linecap="round" style="animation-duration: ' + ring.turnTime + 's"/>' +
|
|
960
|
+
"</svg>";
|
|
961
|
+
};
|
|
962
|
+
|
|
882
963
|
// GROUP: Three dots that grow one after the other. dots: { size, gap, color }
|
|
883
964
|
SmartButton.DOT_COUNT = 3;
|
|
884
965
|
SmartButton.DOT_TIME = 1.2; // seconds for one bounce of a dot
|