Files
Graphite/frontend/src/components/widgets/buttons/IconButton.vue
Keavon Chambers ef53577b20 Vue initialization and FloatingMenu codebase refactoring and cleanup (#649)
* Clean up Vue initialization-related code

* Rename folder: dispatcher -> interop

* Rename folder: state -> providers

* Comments and clarification

* Rename JS dispatcher to subscription router

* Assorted cleanup and renaming

* Rename: js-messages.ts -> messages.ts

* Comments

* Remove unused Vue component injects

* Clean up coming soon and add warning about freezing the app

* Further cleanup

* Dangerous changes

* Simplify App.vue code

* Move more disparate init code from components into managers

* Rename folder: providers -> state-providers

* Other

* Move Document panel options bar separator to backend

* Add destructors to managers to fix HMR

* Comments and code style

* Rename variable: font -> font_file_url

* Fix async font loading; refactor janky floating menu openness and min-width measurement; fix Vetur errors

* Fix misaligned canvas in viewport until panning on page (re)load

* Add Vue bidirectional props documentation

* More folder renaming for better terminology; add some documentation
2022-05-21 19:46:15 -07:00

81 lines
1.5 KiB
Vue

<template>
<button :class="['icon-button', `size-${size}`, active && 'active']" @click="(e: MouseEvent) => action(e)">
<IconLabel :icon="icon" />
</button>
</template>
<style lang="scss">
.icon-button {
display: flex;
justify-content: center;
align-items: center;
flex: 0 0 auto;
padding: 0;
outline: none;
border: none;
border-radius: 2px;
background: none;
svg {
fill: var(--color-e-nearwhite);
}
// The `where` pseudo-class does not contribtue to specificity
& + :where(.icon-button) {
margin-left: 0;
}
&.active {
background: var(--color-accent);
}
&:hover:not(.active) {
background: var(--color-6-lowergray);
color: var(--color-f-white);
svg {
fill: var(--color-f-white);
}
}
&.size-12 {
width: 12px;
height: 12px;
}
&.size-16 {
width: 16px;
height: 16px;
}
&.size-24 {
width: 24px;
height: 24px;
}
&.size-32 {
width: 32px;
height: 32px;
}
}
</style>
<script lang="ts">
import { defineComponent, PropType } from "vue";
import { IconName, IconSize } from "@/utility-functions/icons";
import IconLabel from "@/components/widgets/labels/IconLabel.vue";
export default defineComponent({
props: {
action: { type: Function as PropType<(e?: MouseEvent) => void>, required: true },
icon: { type: String as PropType<IconName>, required: true },
size: { type: Number as PropType<IconSize>, required: true },
active: { type: Boolean as PropType<boolean>, default: false },
gapAfter: { type: Boolean as PropType<boolean>, default: false },
},
components: { IconLabel },
});
</script>