Replace the Vue frontend with Svelte

This commit is contained in:
Keavon Chambers
2023-03-10 03:54:39 -08:00
parent e539e43483
commit 6e20ea538b
83 changed files with 10013 additions and 19687 deletions
@@ -1,81 +1,63 @@
<script lang="ts">
import { defineComponent, type PropType } from "vue";
import LayoutRow from "@/components/layout/LayoutRow.svelte";
import TextButton from "@/components/widgets/buttons/TextButton.svelte";
import LayoutRow from "@/components/layout/LayoutRow.vue";
import TextButton from "@/components/widgets/buttons/TextButton.vue";
export default defineComponent({
props: {
labels: { type: Array as PropType<string[]>, required: true },
disabled: { type: Boolean as PropType<boolean>, default: false },
tooltip: { type: String as PropType<string | undefined>, required: false },
// Callbacks
action: { type: Function as PropType<(index: number) => void>, required: true },
},
components: {
LayoutRow,
TextButton,
},
});
export let labels: string[];
export let disabled = false;
export let tooltip: string | undefined = undefined;
// Callbacks
export let action: (index: number) => void;
</script>
<template>
<LayoutRow class="breadcrumb-trail-buttons" :title="tooltip">
<TextButton
v-for="(label, index) in labels"
:key="index"
:label="label"
:emphasized="index === labels.length - 1"
:disabled="disabled"
:action="() => !disabled && index !== labels.length - 1 && action(index)"
/>
</LayoutRow>
</template>
<LayoutRow class="breadcrumb-trail-buttons" {tooltip}>
{#each labels as label, index (index)}
<TextButton {label} emphasized={index === labels.length - 1} {disabled} action={() => !disabled && index !== labels.length - 1 && action(index)} />
{/each}
</LayoutRow>
<style lang="scss">
.breadcrumb-trail-buttons {
.text-button {
position: relative;
<style lang="scss" global>
.breadcrumb-trail-buttons {
.text-button {
position: relative;
&:not(:first-of-type) {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
&:not(:first-of-type) {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
&::before {
content: "";
position: absolute;
top: 0;
left: -4px;
width: 0;
height: 0;
border-style: solid;
border-width: 12px 0 12px 4px;
border-color: var(--button-background-color) var(--button-background-color) var(--button-background-color) transparent;
&::before {
content: "";
position: absolute;
top: 0;
left: -4px;
width: 0;
height: 0;
border-style: solid;
border-width: 12px 0 12px 4px;
border-color: var(--button-background-color) var(--button-background-color) var(--button-background-color) transparent;
}
}
}
&:not(:last-of-type) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
&:not(:last-of-type) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
&::after {
content: "";
position: absolute;
top: 0;
right: -4px;
width: 0;
height: 0;
border-style: solid;
border-width: 12px 0 12px 4px;
border-color: transparent transparent transparent var(--button-background-color);
&::after {
content: "";
position: absolute;
top: 0;
right: -4px;
width: 0;
height: 0;
border-style: solid;
border-width: 12px 0 12px 4px;
border-color: transparent transparent transparent var(--button-background-color);
}
}
}
&:last-of-type {
// Make this non-functional button not change color on hover
pointer-events: none;
&:last-of-type {
// Make this non-functional button not change color on hover
pointer-events: none;
}
}
}
}
</style>
@@ -1,103 +1,104 @@
<script lang="ts">
import { defineComponent, type PropType } from "vue";
import { type IconName, type IconSize } from "@/utility-functions/icons";
import { type IconName, type IconSize } from "@/utility-functions/icons";
import IconLabel from "@/components/widgets/labels/IconLabel.svelte";
import IconLabel from "@/components/widgets/labels/IconLabel.vue";
export let icon: IconName;
export let size: IconSize;
export let disabled = false;
export let active = false;
export let tooltip: string | undefined = undefined;
export let sharpRightCorners = false;
// Callbacks
export let action: (e?: MouseEvent) => void;
export default defineComponent({
props: {
icon: { type: String as PropType<IconName>, required: true },
size: { type: Number as PropType<IconSize>, required: true },
disabled: { type: Boolean as PropType<boolean>, default: false },
active: { type: Boolean as PropType<boolean>, default: false },
tooltip: { type: String as PropType<string | undefined>, required: false },
sharpRightCorners: { type: Boolean as PropType<boolean>, default: false },
let className = "";
export { className as class };
export let classes: Record<string, boolean> = {};
// Callbacks
action: { type: Function as PropType<(e?: MouseEvent) => void>, required: true },
},
components: { IconLabel },
});
$: extraClasses = Object.entries(classes)
.flatMap((classAndState) => (classAndState[1] ? [classAndState[0]] : []))
.join(" ");
</script>
<template>
<button
class="icon-button"
:class="[`size-${size}`, { disabled, active, 'sharp-right-corners': sharpRightCorners }]"
@click="(e: MouseEvent) => action(e)"
:disabled="disabled"
:title="tooltip"
:tabindex="active ? -1 : 0"
>
<IconLabel :icon="icon" />
</button>
</template>
<button
class={`icon-button size-${size} ${className} ${extraClasses}`.trim()}
class:disabled
class:active
class:sharp-right-corners={sharpRightCorners}
on:click={action}
{disabled}
title={tooltip}
tabindex={active ? -1 : 0}
{...$$restProps}
>
<IconLabel {icon} />
</button>
<style lang="scss">
.icon-button {
display: flex;
justify-content: center;
align-items: center;
flex: 0 0 auto;
margin: 0;
padding: 0;
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;
}
&:hover {
background: var(--color-6-lowergray);
color: var(--color-f-white);
svg {
fill: var(--color-f-white);
}
}
&.disabled {
<style lang="scss" global>
.icon-button {
display: flex;
justify-content: center;
align-items: center;
flex: 0 0 auto;
margin: 0;
padding: 0;
border: none;
border-radius: 2px;
background: none;
svg {
fill: var(--color-8-uppergray);
fill: var(--color-e-nearwhite);
}
// The `where` pseudo-class does not contribtue to specificity
& + :where(.icon-button) {
margin-left: 0;
}
&:hover {
background: var(--color-6-lowergray);
color: var(--color-f-white);
svg {
fill: var(--color-f-white);
}
}
&.disabled {
background: none;
svg {
fill: var(--color-8-uppergray);
}
}
&.active {
background: var(--color-e-nearwhite);
svg {
fill: var(--color-2-mildblack);
}
}
&.size-12 {
width: 12px;
height: 12px;
}
&.size-16 {
width: 16px;
height: 16px;
}
&.size-24 {
width: 24px;
height: 24px;
}
&.size-32 {
width: 32px;
height: 32px;
}
}
&.active {
background: var(--color-e-nearwhite);
svg {
fill: var(--color-2-mildblack);
}
}
&.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>
@@ -1,59 +1,49 @@
<script lang="ts">
import { defineComponent, type PropType } from "vue";
import LayoutRow from "@/components/layout/LayoutRow.svelte";
import LayoutRow from "@/components/layout/LayoutRow.vue";
export default defineComponent({
props: {
exposed: { type: Boolean as PropType<boolean>, required: true },
dataType: { type: String as PropType<string>, required: true },
tooltip: { type: String as PropType<string | undefined>, required: false },
// Callbacks
action: { type: Function as PropType<(e?: MouseEvent) => void>, required: true },
},
components: { LayoutRow },
});
export let exposed: boolean;
export let dataType: string;
export let tooltip: string | undefined = undefined;
// Callbacks
export let action: (e?: MouseEvent) => void;
</script>
<template>
<LayoutRow class="parameter-expose-button">
<button :class="{ exposed }" :style="{ '--data-type-color': `var(--color-data-${dataType})` }" @click="(e: MouseEvent) => action(e)" :title="tooltip" :tabindex="0"></button>
</LayoutRow>
</template>
<LayoutRow class="parameter-expose-button">
<button class:exposed style:--data-type-color={`var(--color-data-${dataType})`} on:click={action} title={tooltip} tabindex="0" />
</LayoutRow>
<style lang="scss">
.parameter-expose-button {
display: flex;
align-items: center;
flex: 0 0 auto;
max-height: 24px;
button {
<style lang="scss" global>
.parameter-expose-button {
display: flex;
align-items: center;
flex: 0 0 auto;
width: 8px;
height: 8px;
margin: 0;
padding: 0;
border: none;
border-radius: 50%;
max-height: 24px;
&:not(.exposed) {
background: none;
border: 1px solid var(--data-type-color);
button {
flex: 0 0 auto;
width: 8px;
height: 8px;
margin: 0;
padding: 0;
border: none;
border-radius: 50%;
&:hover {
background: var(--color-6-lowergray);
&:not(.exposed) {
background: none;
border: 1px solid var(--data-type-color);
&:hover {
background: var(--color-6-lowergray);
}
}
}
&.exposed {
background: var(--data-type-color);
&.exposed {
background: var(--data-type-color);
&:hover {
border: 1px solid var(--color-f-white);
&:hover {
border: 1px solid var(--color-f-white);
}
}
}
}
}
</style>
@@ -1,90 +1,71 @@
<script lang="ts">
import { defineComponent, type PropType } from "vue";
import { type IconName } from "@/utility-functions/icons";
import { type IconName } from "@/utility-functions/icons";
import FloatingMenu from "@/components/layout/FloatingMenu.svelte";
import LayoutRow from "@/components/layout/LayoutRow.svelte";
import IconButton from "@/components/widgets/buttons/IconButton.svelte";
import FloatingMenu from "@/components/layout/FloatingMenu.vue";
import LayoutRow from "@/components/layout/LayoutRow.vue";
import IconButton from "@/components/widgets/buttons/IconButton.vue";
export let icon: IconName = "DropdownArrow";
export let tooltip: string | undefined = undefined;
export let disabled = false;
// Callbacks
export let action: (() => void) | undefined = undefined;
export default defineComponent({
props: {
icon: { type: String as PropType<IconName>, default: "DropdownArrow" },
tooltip: { type: String as PropType<string | undefined>, required: false },
disabled: { type: Boolean as PropType<boolean>, default: false },
let open = false;
// Callbacks
action: { type: Function as PropType<() => void>, required: false },
},
data() {
return {
open: false,
};
},
methods: {
onClick() {
this.open = true;
this.action?.();
},
},
components: {
FloatingMenu,
IconButton,
LayoutRow,
},
});
function onClick() {
open = true;
action?.();
}
</script>
<template>
<LayoutRow class="popover-button">
<IconButton :class="{ open }" :disabled="disabled" :action="() => onClick()" :icon="icon" :size="16" data-floating-menu-spawner :tooltip="tooltip" />
<FloatingMenu v-model:open="open" :type="'Popover'" :direction="'Bottom'">
<slot></slot>
</FloatingMenu>
</LayoutRow>
</template>
<LayoutRow class="popover-button">
<IconButton classes={{ open }} {disabled} action={() => onClick()} icon={icon || "DropdownArrow"} size={16} {tooltip} data-floating-menu-spawner />
<FloatingMenu {open} on:open={({ detail }) => (open = detail)} type="Popover" direction="Bottom">
<slot />
</FloatingMenu>
</LayoutRow>
<style lang="scss">
.popover-button {
position: relative;
width: 16px;
height: 24px;
flex: 0 0 auto;
<style lang="scss" global>
.popover-button {
position: relative;
width: 16px;
height: 24px;
flex: 0 0 auto;
.floating-menu {
left: 50%;
bottom: 0;
}
.icon-button {
width: 100%;
height: 100%;
padding: 0;
border: none;
border-radius: 2px;
background: var(--color-1-nearblack);
fill: var(--color-e-nearwhite);
&:hover,
&.open {
background: var(--color-6-lowergray);
fill: var(--color-f-white);
.floating-menu {
left: 50%;
bottom: 0;
}
&.disabled {
background: var(--color-2-mildblack);
fill: var(--color-8-uppergray);
.icon-button.icon-button {
width: 100%;
height: 100%;
padding: 0;
border: none;
border-radius: 2px;
background: var(--color-1-nearblack);
fill: var(--color-e-nearwhite);
&:hover,
&.open {
background: var(--color-6-lowergray);
fill: var(--color-f-white);
}
&.disabled {
background: var(--color-2-mildblack);
fill: var(--color-8-uppergray);
}
}
// TODO: Refactor this and other complicated cases dealing with joined widget margins and border-radius by adding a single standard set of classes: joined-first, joined-inner, and joined-last
div[class*="-input"] + & {
margin-left: 1px;
.icon-button {
border-radius: 0 2px 2px 0;
}
}
}
// TODO: Refactor this and other complicated cases dealing with joined widget margins and border-radius by adding a single standard set of classes: joined-first, joined-inner, and joined-last
div[class*="-input"] + & {
margin-left: 1px;
.icon-button {
border-radius: 0 2px 2px 0;
}
}
}
</style>
@@ -1,99 +1,92 @@
<script lang="ts">
import { defineComponent, type PropType } from "vue";
import { type IconName } from "@/utility-functions/icons";
import { type IconName } from "@/utility-functions/icons";
import IconLabel from "@/components/widgets/labels/IconLabel.svelte";
import TextLabel from "@/components/widgets/labels/TextLabel.svelte";
import IconLabel from "@/components/widgets/labels/IconLabel.vue";
import TextLabel from "@/components/widgets/labels/TextLabel.vue";
export let label: string;
export let icon: IconName | undefined = undefined;
export let emphasized: boolean = false;
export let minWidth: number = 0;
export let disabled: boolean = false;
export let tooltip: string | undefined = undefined;
export let sharpRightCorners: boolean = false;
export default defineComponent({
props: {
label: { type: String as PropType<string>, required: true },
icon: { type: String as PropType<IconName | undefined>, required: false },
emphasized: { type: Boolean as PropType<boolean>, default: false },
minWidth: { type: Number as PropType<number>, default: 0 },
disabled: { type: Boolean as PropType<boolean>, default: false },
tooltip: { type: String as PropType<string | undefined>, required: false },
sharpRightCorners: { type: Boolean as PropType<boolean>, default: false },
// Callbacks
action: { type: Function as PropType<(e: MouseEvent) => void>, required: true },
},
components: {
IconLabel,
TextLabel,
},
});
// Callbacks
// TODO: Replace this with an event binding (and on other components that do this)
export let action: (e: MouseEvent) => void;
</script>
<template>
<button
class="text-button"
:class="{ emphasized, disabled, 'sharp-right-corners': sharpRightCorners }"
:data-emphasized="emphasized || undefined"
:data-disabled="disabled || undefined"
data-text-button
:title="tooltip"
:style="{ 'min-width': minWidth > 0 ? `${minWidth}px` : undefined }"
@click="(e: MouseEvent) => action(e)"
:tabindex="disabled ? -1 : 0"
>
<IconLabel v-if="icon" :icon="icon" />
<TextLabel>{{ label }}</TextLabel>
</button>
</template>
<button
class="text-button"
class:emphasized
class:disabled
class:sharp-right-corners={sharpRightCorners}
style:min-width={minWidth > 0 ? `${minWidth}px` : undefined}
title={tooltip}
data-emphasized={emphasized || undefined}
data-disabled={disabled || undefined}
data-text-button
tabindex={disabled ? -1 : 0}
on:click={action}
>
{#if icon}
<IconLabel {icon} />
{/if}
<TextLabel>{label}</TextLabel>
</button>
<style lang="scss">
.text-button {
display: flex;
justify-content: center;
align-items: center;
flex: 0 0 auto;
height: 24px;
margin: 0;
padding: 0 8px;
box-sizing: border-box;
border: none;
border-radius: 2px;
background: var(--button-background-color);
color: var(--button-text-color);
--button-background-color: var(--color-5-dullgray);
--button-text-color: var(--color-e-nearwhite);
&:hover {
--button-background-color: var(--color-6-lowergray);
--button-text-color: var(--color-f-white);
}
&.disabled {
--button-background-color: var(--color-4-dimgray);
--button-text-color: var(--color-8-uppergray);
}
&.emphasized {
--button-background-color: var(--color-e-nearwhite);
--button-text-color: var(--color-2-mildblack);
<style lang="scss" global>
.text-button {
display: flex;
justify-content: center;
align-items: center;
flex: 0 0 auto;
height: 24px;
margin: 0;
padding: 0 8px;
box-sizing: border-box;
border: none;
border-radius: 2px;
background: var(--button-background-color);
color: var(--button-text-color);
--button-background-color: var(--color-5-dullgray);
--button-text-color: var(--color-e-nearwhite);
&:hover {
--button-background-color: var(--color-f-white);
--button-background-color: var(--color-6-lowergray);
--button-text-color: var(--color-f-white);
}
&.disabled {
--button-background-color: var(--color-8-uppergray);
--button-background-color: var(--color-4-dimgray);
--button-text-color: var(--color-8-uppergray);
}
&.emphasized {
--button-background-color: var(--color-e-nearwhite);
--button-text-color: var(--color-2-mildblack);
&:hover {
--button-background-color: var(--color-f-white);
}
&.disabled {
--button-background-color: var(--color-8-uppergray);
}
}
& + .text-button {
margin-left: 8px;
}
.icon-label {
position: relative;
left: -4px;
}
.text-label {
overflow: hidden;
}
}
& + .text-button {
margin-left: 8px;
}
.icon-label {
position: relative;
left: -4px;
}
.text-label {
overflow: hidden;
}
}
</style>