Add TextButton widget (#321)
This commit is contained in:
parent
e1ac2a85b3
commit
1c317d0166
|
|
@ -55,6 +55,8 @@
|
||||||
--color-accent-rgb: 49, 148, 214;
|
--color-accent-rgb: 49, 148, 214;
|
||||||
--color-accent-hover: #49a5e2;
|
--color-accent-hover: #49a5e2;
|
||||||
--color-accent-hover-rgb: 73, 165, 226;
|
--color-accent-hover-rgb: 73, 165, 226;
|
||||||
|
--color-accent-disabled: #416277;
|
||||||
|
--color-accent-disabled-rgb: 65, 98, 119;
|
||||||
|
|
||||||
// TODO: Replace with CSS color() function to calculate alpha when browsers support it
|
// TODO: Replace with CSS color() function to calculate alpha when browsers support it
|
||||||
// See https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color() and https://caniuse.com/css-color-function
|
// See https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color() and https://caniuse.com/css-color-function
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
<template>
|
||||||
|
<button class="text-button" :class="{ emphasized, disabled }" :style="minWidth > 0 ? `min-width: ${minWidth}px` : ''" @click="action">
|
||||||
|
<TextLabel>{{ label }}</TextLabel>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.text-button {
|
||||||
|
display: inline-flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
height: 24px;
|
||||||
|
padding: 0 8px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
border-radius: 2px;
|
||||||
|
background: var(--color-5-dullgray);
|
||||||
|
color: var(--color-e-nearwhite);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--color-6-lowergray);
|
||||||
|
color: var(--color-f-white);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.emphasized {
|
||||||
|
background: var(--color-accent);
|
||||||
|
color: var(--color-f-white);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--color-accent-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.disabled {
|
||||||
|
background: var(--color-accent-disabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.disabled {
|
||||||
|
background: var(--color-4-dimgray);
|
||||||
|
color: var(--color-8-uppergray);
|
||||||
|
}
|
||||||
|
|
||||||
|
& + .text-button {
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { defineComponent } from "vue";
|
||||||
|
import TextLabel from "@/components/widgets/labels/TextLabel.vue";
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
props: {
|
||||||
|
action: { type: Function, required: true },
|
||||||
|
label: { type: String, required: true },
|
||||||
|
emphasized: { type: Boolean, default: false },
|
||||||
|
disabled: { type: Boolean, default: false },
|
||||||
|
minWidth: { type: Number, default: 0 },
|
||||||
|
gapAfter: { type: Boolean, default: false },
|
||||||
|
},
|
||||||
|
components: { TextLabel },
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<span class="text-label">
|
<span class="text-label" :class="{ bold, italic }">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -7,7 +7,15 @@
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.text-label {
|
.text-label {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
font-weight: bold;
|
line-height: 18px;
|
||||||
|
|
||||||
|
&.bold {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.italic {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
@ -16,6 +24,9 @@ import { defineComponent } from "vue";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {},
|
components: {},
|
||||||
props: {},
|
props: {
|
||||||
|
bold: { type: Boolean, default: false },
|
||||||
|
italic: { type: Boolean, default: false },
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,24 @@ export type Widgets = IconButtonWidget | SeparatorWidget | PopoverButtonWidget |
|
||||||
export type WidgetRow = Array<Widgets>;
|
export type WidgetRow = Array<Widgets>;
|
||||||
export type WidgetLayout = Array<WidgetRow>;
|
export type WidgetLayout = Array<WidgetRow>;
|
||||||
|
|
||||||
|
// Text Button
|
||||||
|
export interface TextButtonWidget {
|
||||||
|
kind: "TextButton";
|
||||||
|
tooltip?: string;
|
||||||
|
message?: string | object;
|
||||||
|
callback?: Function;
|
||||||
|
props: TextButtonProps;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TextButtonProps {
|
||||||
|
// `action` is used via `IconButtonWidget.callback`
|
||||||
|
label: string;
|
||||||
|
emphasized?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
|
minWidth?: number;
|
||||||
|
gapAfter?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
// Icon Button
|
// Icon Button
|
||||||
export interface IconButtonWidget {
|
export interface IconButtonWidget {
|
||||||
kind: "IconButton";
|
kind: "IconButton";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="window-buttons-web" @click="handleClick" :title="fullscreen.windowFullscreen ? 'Exit Fullscreen (F11)' : 'Enter Fullscreen (F11)'">
|
<div class="window-buttons-web" @click="handleClick" :title="fullscreen.windowFullscreen ? 'Exit Fullscreen (F11)' : 'Enter Fullscreen (F11)'">
|
||||||
<TextLabel v-if="requestFullscreenHotkeys">Click to access all hotkeys</TextLabel>
|
<TextLabel v-if="requestFullscreenHotkeys" :italic="true">Click to access all hotkeys</TextLabel>
|
||||||
<IconLabel :icon="fullscreen.windowFullscreen ? 'FullscreenExit' : 'FullscreenEnter'" />
|
<IconLabel :icon="fullscreen.windowFullscreen ? 'FullscreenExit' : 'FullscreenEnter'" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -13,8 +13,6 @@
|
||||||
fill: var(--color-e-nearwhite);
|
fill: var(--color-e-nearwhite);
|
||||||
|
|
||||||
.text-label {
|
.text-label {
|
||||||
font-weight: normal;
|
|
||||||
font-style: italic;
|
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue