pinafore/routes/_components/IconButton.html

81 lines
1.8 KiB
HTML
Raw Normal View History

2018-02-28 08:18:07 +01:00
{{#if delegateKey}}
2018-01-28 21:51:48 +01:00
<button type="button"
aria-label="{{label}}"
2018-02-28 08:18:07 +01:00
aria-pressed="{{pressable ? !!pressed : ''}}"
2018-02-24 23:49:28 +01:00
class="{{computedClass}}"
2018-02-28 08:18:07 +01:00
:disabled
2018-03-17 03:04:48 +01:00
delegate-key="{{delegateKey}}"
focus-key="{{focusKey || ''}}" >
<svg class="icon-button-svg">
2018-01-28 21:51:48 +01:00
<use xlink:href="{{href}}" />
</svg>
</button>
{{else}}
<button type="button"
aria-label="{{label}}"
2018-02-28 08:18:07 +01:00
aria-pressed="{{pressable ? !!pressed : ''}}"
2018-02-24 23:49:28 +01:00
class="{{computedClass}}"
2018-03-17 03:04:48 +01:00
focus-key="{{focusKey || ''}}"
2018-02-28 08:18:07 +01:00
:disabled
on:click >
<svg class="icon-button-svg">
2018-01-28 21:51:48 +01:00
<use xlink:href="{{href}}" />
</svg>
</button>
{{/if}}
<style>
.icon-button {
2018-01-28 21:51:48 +01:00
padding: 6px 10px;
background: none;
border: none;
}
.icon-button-svg {
2018-01-28 21:51:48 +01:00
width: 24px;
height: 24px;
fill: var(--action-button-fill-color);
}
.icon-button.big-icon .icon-button-svg {
2018-01-28 21:51:48 +01:00
width: 32px;
height: 32px;
}
.icon-button:hover .icon-button-svg {
2018-01-28 21:51:48 +01:00
fill: var(--action-button-fill-color-hover);
}
.icon-button.not-pressable:active .icon-button-svg {
2018-01-28 21:51:48 +01:00
fill: var(--action-button-fill-color-active);
}
.icon-button.pressed .icon-button-svg {
2018-01-28 21:51:48 +01:00
fill: var(--action-button-fill-color-pressed)
}
.icon-button.pressed:hover .icon-button-svg {
2018-01-28 21:51:48 +01:00
fill: var(--action-button-fill-color-pressed-hover);
}
.icon-button.pressed:active .icon-button-svg {
2018-01-28 21:51:48 +01:00
fill: var(--action-button-fill-color-pressed-active);
}
2018-02-24 23:49:28 +01:00
</style>
<script>
2018-03-15 02:52:33 +01:00
import { classname } from '../_utils/classname'
2018-02-24 23:49:28 +01:00
export default {
computed: {
2018-03-03 06:55:04 +01:00
computedClass: (pressable, pressed, big, className) => {
2018-03-15 02:52:33 +01:00
return classname(
2018-02-24 23:49:28 +01:00
'icon-button',
!pressable && 'not-pressable',
pressed && 'pressed',
big && 'big-icon',
2018-03-03 06:55:04 +01:00
className
2018-03-15 02:52:33 +01:00
)
2018-02-24 23:49:28 +01:00
}
}
}
</script>