ember-safe-button 2.1.1 → 3.0.0

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.
Files changed (77) hide show
  1. package/README.md +9 -3
  2. package/addon-main.cjs +6 -0
  3. package/dist/_app_/components/safe-button/animations/flip.js +1 -0
  4. package/dist/_app_/components/safe-button/animations/index.js +1 -0
  5. package/dist/_app_/components/safe-button/animations/lift-bars.js +1 -0
  6. package/dist/_app_/components/safe-button/animations/poing.js +1 -0
  7. package/dist/_app_/components/safe-button/animations/roll.js +1 -0
  8. package/dist/_app_/components/safe-button/animations/slide.js +1 -0
  9. package/dist/_app_/components/safe-button/animations/zoom.js +1 -0
  10. package/dist/_app_/components/safe-button/index.js +1 -0
  11. package/dist/_app_/components/safety/index.js +1 -0
  12. package/dist/_app_/components/trigger/index.js +1 -0
  13. package/dist/_app_/modifiers/animate-me.js +1 -0
  14. package/dist/components/safe-button/animations/flip.js +103 -0
  15. package/dist/components/safe-button/animations/flip.js.map +1 -0
  16. package/dist/components/safe-button/animations/index.js +18 -0
  17. package/dist/components/safe-button/animations/index.js.map +1 -0
  18. package/dist/components/safe-button/animations/lift-bars.js +53 -0
  19. package/dist/components/safe-button/animations/lift-bars.js.map +1 -0
  20. package/dist/components/safe-button/animations/poing.js +93 -0
  21. package/dist/components/safe-button/animations/poing.js.map +1 -0
  22. package/dist/components/safe-button/animations/roll.js +57 -0
  23. package/dist/components/safe-button/animations/roll.js.map +1 -0
  24. package/dist/components/safe-button/animations/slide.js +57 -0
  25. package/dist/components/safe-button/animations/slide.js.map +1 -0
  26. package/dist/components/safe-button/animations/zoom.js +73 -0
  27. package/dist/components/safe-button/animations/zoom.js.map +1 -0
  28. package/dist/components/safe-button/index.js +9 -0
  29. package/dist/components/safe-button/index.js.map +1 -0
  30. package/dist/components/safety/index.js +54 -0
  31. package/dist/components/safety/index.js.map +1 -0
  32. package/dist/components/trigger/index.js +44 -0
  33. package/dist/components/trigger/index.js.map +1 -0
  34. package/dist/index-65a73164.js +249 -0
  35. package/dist/index-65a73164.js.map +1 -0
  36. package/dist/index.js +2 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/modifiers/animate-me.js +23 -0
  39. package/dist/modifiers/animate-me.js.map +1 -0
  40. package/package.json +70 -69
  41. package/.gitlab-ci.yml +0 -27
  42. package/.prettierignore +0 -21
  43. package/.prettierrc.js +0 -5
  44. package/.vscode/settings.json +0 -19
  45. package/CHANGELOG.md +0 -126
  46. package/LICENSE.md +0 -9
  47. package/addon/components/safe-button/animations/flip.js +0 -114
  48. package/addon/components/safe-button/animations/index.js +0 -15
  49. package/addon/components/safe-button/animations/lift-bars.js +0 -50
  50. package/addon/components/safe-button/animations/poing.js +0 -99
  51. package/addon/components/safe-button/animations/roll.js +0 -50
  52. package/addon/components/safe-button/animations/slide.js +0 -50
  53. package/addon/components/safe-button/animations/zoom.js +0 -52
  54. package/addon/components/safe-button/index.hbs +0 -35
  55. package/addon/components/safe-button/index.js +0 -184
  56. package/addon/components/safety/index.hbs +0 -20
  57. package/addon/components/safety/index.js +0 -41
  58. package/addon/components/trigger/index.hbs +0 -20
  59. package/addon/components/trigger/index.js +0 -31
  60. package/addon/modifiers/animate-me.js +0 -20
  61. package/app/components/safe-button.js +0 -1
  62. package/app/components/safety.js +0 -1
  63. package/app/components/trigger.js +0 -2
  64. package/app/modifiers/animate-me.js +0 -1
  65. package/app/templates/components/safe-button.js +0 -1
  66. package/app/templates/components/safety.js +0 -1
  67. package/app/templates/components/trigger.js +0 -1
  68. package/config/addon-docs.js +0 -13
  69. package/config/deploy.js +0 -29
  70. package/config/environment.js +0 -5
  71. package/config/tailwindcss-config.js +0 -924
  72. package/doc/demo.gif +0 -0
  73. package/doc/logo.png +0 -0
  74. package/index.js +0 -5
  75. package/netlify.toml +0 -3
  76. package/renovate.json +0 -75
  77. package/yarn-error.log +0 -13431
@@ -1,184 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { timeout } from 'ember-concurrency';
3
- import { tracked } from '@glimmer/tracking';
4
- import { task } from 'ember-concurrency';
5
- import { action } from '@ember/object';
6
- import embeddedAnimations from './animations';
7
- import { assert } from '@ember/debug';
8
-
9
- const DEFAULT_TIMEOUT = 3000;
10
- const DEFAULT_ANIMATION = 'slide';
11
-
12
- export const SAFETY_STATUS = {
13
- LOCKED: 1,
14
- UNLOCKING: 2,
15
- UNLOCKED: 3,
16
- LOCKING: 4,
17
- };
18
-
19
- /**
20
- Main component.
21
-
22
- ```hbs
23
- <SafeButton
24
- class="border-black"
25
- @animation={{this.animation}}
26
- @message="Delete me"
27
- @timeout={{2000}}
28
- @onConfirm={{action safeButtonClicked}} />
29
- ```
30
-
31
- ```
32
- @class SafeButtonComponent
33
- @param {string} [class="ember-safe-button"] CSS class to be applied on the wrapping element.
34
- @param {object} [animation="slid"] Definition of animation; It can either be string and point to one of the pre-defined animations; Or it can be an object describing Web Animation API
35
- @param {number} [timeout=3000] Number of millisenconds after which the safety rolls back over the trigger.
36
- @param {string} [message="delete"] Text to be printed on the buttons in case block is not provided.
37
- @param {function} onConfirm - Action to trigger whenever user clicks the trigger.
38
- ```
39
-
40
- When trying to construct your own `@animation` object you can take inspiration from the simple `slide` animation. The thing to keep in mind is that these go directly as parameters to [element.animate()](https://developer.mozilla.org/en-US/docs/Web/API/Element/animate) and that there are in fact four animations of which always two fire at the same time:
41
-
42
- - `safety.unlocking` and `trigger.unlocking`
43
- - `safety.locking` and `trigger.locking`
44
-
45
- ```js
46
- {
47
- safety: {
48
- unlocking: {
49
- keyframes: [
50
- { transform: 'translateX(0)' },
51
- { transform: 'translateX(-100%)' },
52
- ],
53
- options: {
54
- duration: 1000,
55
- fill: 'both',
56
- easing: 'ease',
57
- },
58
- },
59
- locking: {
60
- keyframes: [
61
- { transform: 'translateX(-100%)' },
62
- { transform: 'translateX(0)' },
63
- ],
64
- options: {
65
- duration: 1000,
66
- fill: 'both',
67
- easing: 'ease',
68
- },
69
- },
70
- },
71
- trigger: {
72
- unlocking: {
73
- keyframes: [
74
- { transform: 'translateX(100%)' },
75
- { transform: 'translateX(0)' },
76
- ],
77
- options: {
78
- duration: 1000,
79
- fill: 'both',
80
- easing: 'ease',
81
- },
82
- },
83
- locking: {
84
- keyframes: [
85
- { transform: 'translateX(0)' },
86
- { transform: 'translateX(100%)' },
87
- ],
88
- options: {
89
- duration: 1000,
90
- fill: 'both',
91
- easing: 'ease',
92
- },
93
- },
94
- },
95
- }
96
- ```
97
- */
98
- export default class SafeButtonComponent extends Component {
99
- constructor() {
100
- super(...arguments);
101
-
102
- assert(
103
- '@onConfirm attribute must be set',
104
- typeof this.args.onConfirm === 'function'
105
- );
106
- }
107
-
108
- @tracked safetyStatus = SAFETY_STATUS.LOCKED;
109
-
110
- get activeAnimation() {
111
- const animation = this.args.animation || DEFAULT_ANIMATION;
112
-
113
- return typeof animation === 'string'
114
- ? embeddedAnimations[animation]
115
- : animation;
116
- }
117
-
118
- get webAnimations() {
119
- const { activeAnimation, onUnlocked, onLocked } = this;
120
-
121
- return {
122
- safety: {
123
- unlocking: ({ element }) => {
124
- let animation = element.animate(
125
- activeAnimation.safety.unlocking.keyframes,
126
- activeAnimation.safety.unlocking.options
127
- );
128
- animation.onfinish = onUnlocked;
129
- },
130
- locking: ({ element }) => {
131
- let animation = element.animate(
132
- activeAnimation.safety.locking.keyframes,
133
- activeAnimation.safety.locking.options
134
- );
135
- animation.onfinish = onLocked;
136
- },
137
- },
138
- trigger: {
139
- unlocking({ element }) {
140
- element.animate(
141
- activeAnimation.trigger.unlocking.keyframes,
142
- activeAnimation.trigger.unlocking.options
143
- );
144
- },
145
- locking({ element }) {
146
- element.animate(
147
- activeAnimation.trigger.locking.keyframes,
148
- activeAnimation.trigger.locking.options
149
- );
150
- },
151
- },
152
- };
153
- }
154
-
155
- get timeout() {
156
- return this.args.timeout || DEFAULT_TIMEOUT;
157
- }
158
-
159
- get displayedMessage() {
160
- return this.args.message || 'delete';
161
- }
162
-
163
- @action
164
- onUnlocking() {
165
- this.safetyStatus = SAFETY_STATUS.UNLOCKING;
166
- }
167
-
168
- @action
169
- onUnlocked() {
170
- this.safetyStatus = SAFETY_STATUS.UNLOCKED;
171
- this.triggerSafety.perform();
172
- }
173
-
174
- @action
175
- onLocked() {
176
- this.safetyStatus = SAFETY_STATUS.LOCKED;
177
- }
178
-
179
- @task(function* () {
180
- yield timeout(this.timeout);
181
- this.safetyStatus = SAFETY_STATUS.LOCKING;
182
- })
183
- triggerSafety;
184
- }
@@ -1,20 +0,0 @@
1
- <button
2
- class={{this.BASIC_CLASS}}
3
- disabled={{this.isDisabled}}
4
- aria-label={{this.ariaLabel}}
5
- type='button'
6
- tabindex={{if this.isDisabled '-1' '0'}}
7
- ...attributes
8
- {{on 'click' @onClick}}
9
- {{animate-me
10
- safetyStatus=@safetyStatus
11
- webAnimations=@webAnimations
12
- focusMe=this.focusMe
13
- }}
14
- >
15
- {{#if (has-block)}}
16
- {{yield}}
17
- {{else}}
18
- {{@displayedMessage}}
19
- {{/if}}
20
- </button>
@@ -1,41 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { SAFETY_STATUS } from '../safe-button';
3
-
4
- export const BASIC_CLASS = 'ember-safe-button-safety';
5
- export const ARIA_LABELS = {
6
- [SAFETY_STATUS.LOCKED]: 'Deactivate safety',
7
- [SAFETY_STATUS.UNLOCKING]: 'Deactivating safety',
8
- [SAFETY_STATUS.UNLOCKED]: 'Safety not active',
9
- [SAFETY_STATUS.LOCKING]: 'Activating safety',
10
- };
11
-
12
- /**
13
- Safety is a component that covers the trigger.
14
-
15
- ```hbs
16
- <SafeButton
17
- @onConfirm={{action safeButtonClicked}} as |button|
18
- >
19
- <button.safety class="bg-grey-light">
20
- This is safety
21
- </button.safety>
22
- </SafeButton>
23
- ```
24
-
25
- @class SafetyComponent
26
- */
27
- export default class SafetyComponent extends Component {
28
- BASIC_CLASS = BASIC_CLASS;
29
-
30
- get isDisabled() {
31
- return this.args.safetyStatus === SAFETY_STATUS.UNLOCKED;
32
- }
33
-
34
- get focusMe() {
35
- return !this.isDisabled;
36
- }
37
-
38
- get ariaLabel() {
39
- return ARIA_LABELS[this.args.safetyStatus];
40
- }
41
- }
@@ -1,20 +0,0 @@
1
- <button
2
- class={{this.BASIC_CLASS}}
3
- disabled={{this.isDisabled}}
4
- aria-label='Confirm action'
5
- type='button'
6
- tabindex={{if this.isDisabled '-1' '0'}}
7
- ...attributes
8
- {{on 'click' @onClick}}
9
- {{animate-me
10
- safetyStatus=@safetyStatus
11
- webAnimations=@webAnimations
12
- focusMe=this.focusMe
13
- }}
14
- >
15
- {{#if (has-block)}}
16
- {{yield}}
17
- {{else}}
18
- {{@displayedMessage}}
19
- {{/if}}
20
- </button>
@@ -1,31 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { SAFETY_STATUS } from '../safe-button';
3
-
4
- export const BASIC_CLASS = 'ember-safe-button-trigger';
5
-
6
- /**
7
- Trigger is a component that is by default covered by safety and triggers the action passed to <SafeButton> when clicked.
8
-
9
- ```hbs
10
- <SafeButton
11
- @onConfirm={{action safeButtonClicked}} as |button|
12
- >
13
- <button.trigger class="bg-red-dark">
14
- Trigger
15
- </button.trigger>
16
- </SafeButton>
17
- ```
18
-
19
- @class SafetyComponent
20
- */
21
- export default class TriggerComponent extends Component {
22
- BASIC_CLASS = BASIC_CLASS;
23
-
24
- get isDisabled() {
25
- return this.args.safetyStatus !== SAFETY_STATUS.UNLOCKED;
26
- }
27
-
28
- get focusMe() {
29
- return !this.isDisabled;
30
- }
31
- }
@@ -1,20 +0,0 @@
1
- import Modifier from 'ember-modifier';
2
- import { SAFETY_STATUS } from '../components/safe-button';
3
-
4
- export default class AnimateMeModifier extends Modifier {
5
- didReceiveArguments() {
6
- if (this.args.named.focusMe) {
7
- this.element.focus();
8
- }
9
-
10
- if (this.args.named.safetyStatus === SAFETY_STATUS.UNLOCKING) {
11
- this.args.named.webAnimations.unlocking({
12
- element: this.element,
13
- });
14
- } else if (this.args.named.safetyStatus === SAFETY_STATUS.LOCKING) {
15
- this.args.named.webAnimations.locking({
16
- element: this.element,
17
- });
18
- }
19
- }
20
- }
@@ -1 +0,0 @@
1
- export { default } from 'ember-safe-button/components/safe-button';
@@ -1 +0,0 @@
1
- export { default } from 'ember-safe-button/components/safety';
@@ -1,2 +0,0 @@
1
- export * from 'ember-safe-button/components/trigger';
2
- export { default } from 'ember-safe-button/components/trigger';
@@ -1 +0,0 @@
1
- export { default } from 'ember-safe-button/modifiers/animate-me';
@@ -1 +0,0 @@
1
- export { default } from 'ember-safe-button/templates/components/safe-button';
@@ -1 +0,0 @@
1
- export { default } from 'ember-safe-button/templates/components/safety';
@@ -1 +0,0 @@
1
- export { default } from 'ember-safe-button/templates/components/trigger';
@@ -1,13 +0,0 @@
1
- /* eslint-disable node/no-unpublished-require */
2
- /* eslint-disable unicorn/prevent-abbreviations */
3
- /* eslint-env node */
4
- 'use strict';
5
-
6
- // eslint-disable-next-line node/no-unpublished-require
7
- // eslint-disable-next-line node/no-missing-require
8
- const AddonDocsConfig = require('ember-cli-addon-docs/lib/config');
9
-
10
- module.exports = class extends AddonDocsConfig {
11
- // See https://ember-learn.github.io/ember-cli-addon-docs/docs/deploying
12
- // for details on configuration you can override here.
13
- };
package/config/deploy.js DELETED
@@ -1,29 +0,0 @@
1
- /* eslint-env node */
2
- 'use strict';
3
-
4
- module.exports = function (deployTarget) {
5
- let ENV = {
6
- build: {},
7
- // include other plugin configuration that applies to all deploy targets here
8
- };
9
-
10
- if (deployTarget === 'development') {
11
- ENV.build.environment = 'development';
12
- // configure other plugins for development deploy target here
13
- }
14
-
15
- if (deployTarget === 'staging') {
16
- ENV.build.environment = 'production';
17
- // configure other plugins for staging deploy target here
18
- }
19
-
20
- if (deployTarget === 'production') {
21
- ENV.build.environment = 'production';
22
- // configure other plugins for production deploy target here
23
- }
24
-
25
- // Note: if you need to build some configuration asynchronously, you can return
26
- // a promise that resolves with the ENV object instead of returning the
27
- // ENV object synchronously.
28
- return ENV;
29
- };
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = function (/* environment, appConfig */) {
4
- return {};
5
- };