John Cowen a6996b6ea5
ui: CopyButton amends (#10511)
* ui: Add with-copyable modifier

* Use with-copyable modifier for our own CopyButton

* Move copy-button styling and remove most of `copy-btn`
2021-07-06 16:56:36 +01:00

31 lines
827 B
Handlebars

<StateChart
@src={{this.chart}}
as |State Guard Action dispatch state|
>
<div
class="copy-button"
...attributes
>
{{#let (fn dispatch 'SUCCESS') (fn dispatch 'ERROR') (fn dispatch 'RESET') as |success error reset|}}
<button
{{with-copyable @value success=success error=error}}
aria-label={{t 'components.copy-button.title' name=@name}}
type="button"
class="copy-btn"
...attributes
{{tooltip
(if (state-matches state 'success') (t 'components.copy-button.success' name=@name) (t 'components.copy-button.error'))
options=(hash
trigger='manual'
showOnCreate=(not (state-matches state 'idle'))
delay=(array 0 3000)
onHidden=reset
)
}}
>
{{~yield~}}
</button>
{{/let}}
</div>
</StateChart>