Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions app/assets/images/workspace-refresh.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions app/components/DesktopAppUpdateButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<template>
<div v-show="updateState && visible" ref="buttonContainer" class="relative mr-1 h-8 shrink-0">
<button
type="button"
class="rounded-control flex h-8 items-center gap-1.5 bg-blue-500 px-3 text-xs font-medium whitespace-nowrap text-white transition-colors hover:bg-blue-600 focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-wait disabled:bg-blue-500"
:disabled="installing"
@click="install"
>
<RefreshCwIcon class="size-3.5" :class="{ 'animate-spin': installing }" />
Update
</button>
</div>
</template>

<script setup>
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
import { useElementSize } from '@vueuse/core';
import { RefreshCwIcon } from 'lucide-vue-next';

const props = defineProps({
viewport: { type: Object, default: null },
tabsContainer: { type: Object, default: null },
});

const $ipc = useElectronIpc();

const buttonContainer = ref(null);
const updateState = ref(null);
const installingUpdate = ref(false);
const visible = ref(true);

const installing = computed(
() => installingUpdate.value || updateState.value?.status === 'downloading'
);

const { width: viewportWidth } = useElementSize(() => props.viewport);
const { width: tabsWidth } = useElementSize(() => props.tabsContainer);
const { width: buttonWidth } = useElementSize(buttonContainer);

function updateStateChanged(event, state) {
updateState.value = state;
}

async function install() {
installingUpdate.value = true;

try {
await $ipc.invoke('install-update');
} finally {
installingUpdate.value = false;
}
}

$ipc.addListener('update-state-changed', updateStateChanged);

onMounted(async () => {
updateState.value = await $ipc.invoke('get-update-state');
});

onUnmounted(() => $ipc.removeListener('update-state-changed', updateStateChanged));

watch([viewportWidth, tabsWidth, updateState], () => {
if (!viewportWidth.value || !tabsWidth.value) return;

if (visible.value) {
if (tabsWidth.value > viewportWidth.value) visible.value = false;
} else if (tabsWidth.value + buttonWidth.value + 4 <= viewportWidth.value) {
visible.value = true;
}
});
</script>
26 changes: 20 additions & 6 deletions app/components/DesktopTitlebar.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
<template>
<div
:class="{ hidden: isFullscreen }"
style="-webkit-app-region: drag; height: 28px"
class="border-ui-line z-50 flex justify-between border-b bg-zinc-100/70 backdrop-blur-xl dark:bg-zinc-900/70"
:class="{
hidden: isFullscreen && !$slots.default,
'h-7': !$slots.default,
'h-11 gap-1': $slots.default,
'pl-[88px]': $slots.default && !isFullscreen,
}"
style="-webkit-app-region: drag"
class="border-ui-line bg-ui-chrome z-50 flex shrink-0 items-center border-b"
>
<div @dblclick="$ipc.send('double-click-title-bar')" class="size-full"></div>
<slot>
<div @dblclick="$ipc.send('double-click-title-bar')" class="size-full"></div>
</slot>

<WindowControls v-if="$config.public.platform.windows" />
<div
v-if="$slots.default"
data-titlebar-drag-region
class="h-full min-w-12 flex-1"
@dblclick="$ipc.send('double-click-title-bar')"
/>
</div>
</template>

<script setup>
import { onUnmounted, ref } from 'vue';
import { onMounted, onUnmounted, ref } from 'vue';

const { $ipc } = useNuxtApp();

Expand All @@ -25,5 +37,7 @@ function listener(event, state) {

$ipc.addListener('window-state-changed', listener);

onMounted(async () => listener(null, await $ipc.invoke('get-window-state')));

onUnmounted(() => $ipc.removeListener('window-state-changed', listener));
</script>
17 changes: 16 additions & 1 deletion app/components/FileDropdown.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<template>
<DropdownMenu>
<button
v-if="desktop"
type="button"
aria-label="File menu"
aria-haspopup="menu"
class="ui-navbar-button"
@click="desktop.invoke('show-file-menu')"
>
<Logo class="size-4" />
</button>

<DropdownMenu v-else>
<DropdownMenuTrigger as-child>
<button type="button" aria-label="Application menu" class="ui-navbar-button">
<Logo class="size-4" />
Expand Down Expand Up @@ -58,6 +69,10 @@
</template>

<script setup>
import useDesktop from '@/composables/useDesktop';

const desktop = useDesktop();

defineProps({
options: { type: Array, default: () => [] },
});
Expand Down
33 changes: 29 additions & 4 deletions app/components/ModalChangelog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,23 @@

<ScrollArea class="flex-1 overflow-auto">
<div class="space-y-4 p-5">
<div
v-for="release in standaloneReleases"
:key="release.id"
class="rounded-surface border-ui-line overflow-hidden border"
>
<div class="border-ui-line bg-ui-chrome border-b px-4 py-2.5">
<h3 class="text-sm font-semibold">{{ release.title }}</h3>
<p class="text-ui-muted mt-1 text-xs">
{{ release.date }} · Desktop {{ release.version }}
</p>
</div>
<ReleaseNotesContent class="p-4" :content="release.content" />
</div>
<div
v-for="(entry, index) in entries"
:key="index"
class="rounded-surface border-ui-line border"
class="rounded-surface border-ui-line overflow-hidden border"
>
<div
class="rounded-t-surface border-ui-line bg-ui-chrome border-b px-4 py-2.5"
Expand Down Expand Up @@ -53,12 +66,20 @@
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { computed, ref, onMounted } from 'vue';

defineProps({ modelValue: { type: [Boolean, Object], default: false } });
const props = defineProps({
modelValue: { type: [Boolean, Object], default: false },
releases: { type: Array, default: () => [] },
});
defineEmits(['update:modelValue']);

const entries = ref([]);
const standaloneReleases = computed(() =>
props.releases.filter(
(release) => !entries.value.some((entry) => entry.version === release.version)
)
);

const badgeClass = (type) => ({
'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-400':
Expand All @@ -75,7 +96,11 @@ function parseChangelog(raw) {
const dateMatch = line.match(/^## (.+)/);

if (dateMatch) {
current = { date: dateMatch[1], sections: [] };
current = {
date: dateMatch[1],
version: dateMatch[1].match(/— Version ([\d.]+)$/)?.[1],
sections: [],
};
result.push(current);
continue;
}
Expand Down
7 changes: 3 additions & 4 deletions app/components/ModalCustomBackground.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@
<script setup>
import 'vue-advanced-cropper/dist/style.css';
import collect from 'collect.js';
import { head, debounce } from 'lodash';
import { debounce } from 'lodash';
import { useElementSize } from '@vueuse/core';
import { Cropper } from 'vue-advanced-cropper';
import { fileDialog } from 'file-select-dialog';
import useFileDialogs from '@/composables/useFileDialogs';
import useBackgrounds from '@/composables/useBackgrounds';
import { computed, onMounted, ref, watch } from 'vue';
import { CodeIcon, ImageIcon, RefreshCwIcon } from 'lucide-vue-next';
Expand Down Expand Up @@ -197,8 +197,7 @@ const { width: monacoWrapperWidth } = useElementSize(monacoWrapper);

async function importBackground() {
reset();
const files = await fileDialog({ accept: ['.png', '.jpg', '.gif'] });
const file = head(files);
const file = await useFileDialogs().openFile('background');
if (!file) return;
const blob = await new Response(file).blob();
const reader = new FileReader();
Expand Down
67 changes: 67 additions & 0 deletions app/components/ModalWhatsNew.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<template>
<Dialog :open="modelValue" @update:open="(value) => !value && $emit('dismiss')">
<DialogContent class="max-w-xl gap-0 overflow-hidden p-0">
<div class="max-h-[calc(100dvh-7rem)] overflow-y-auto overscroll-contain">
<DialogHeader class="gap-2 px-6 pt-6 pb-5 text-left">
<div class="text-ui-muted flex items-center gap-2 pr-6 text-[11px]">
<span class="text-ui-text font-medium">What's new</span>
<span aria-hidden="true">·</span>
<span>Showcode {{ release.version }}</span>
<span class="ml-auto">{{ release.date }}</span>
</div>
<DialogTitle class="text-xl font-semibold tracking-tight">
{{ release.title }}
</DialogTitle>
<DialogDescription class="text-ui-muted text-[13px] leading-relaxed">
{{ release.description }}
</DialogDescription>
</DialogHeader>

<div v-if="release.image" class="px-6 pb-5">
<img
:src="release.image"
:alt="release.imageAlt"
class="border-ui-line w-full rounded-lg border"
/>
</div>

<ReleaseNotesContent class="px-6 pb-6" :content="release.content" />
</div>

<div class="bg-ui-chrome flex flex-wrap items-center gap-3 px-6 py-4">
<label class="text-ui-muted mr-auto flex items-center gap-2 text-[11px]">
<span
class="relative inline-flex size-3.5 shrink-0 items-center justify-center"
>
<input
type="checkbox"
:checked="showAfterUpdate"
class="peer border-ui-line bg-ui-field text-ui-text checked:border-ui-text checked:bg-ui-text hover:border-ui-muted focus-visible:outline-ui-focus m-0 size-3.5 appearance-none rounded-sm border shadow-none transition-colors checked:bg-none focus:ring-0 focus:ring-offset-0 focus-visible:outline-2 focus-visible:outline-offset-2"
@change="$emit('update:showAfterUpdate', $event.target.checked)"
/>
<CheckIcon
aria-hidden="true"
:stroke-width="3"
class="text-ui-canvas pointer-events-none absolute size-2.5 opacity-0 peer-checked:opacity-100"
/>
</span>
Show after updates
</label>
<Button variant="ghost" @click="$emit('changelog')">Full changelog</Button>
<Button class="rounded-full px-4" @click="$emit('dismiss')">Continue</Button>
</div>
</DialogContent>
</Dialog>
</template>

<script setup>
import { CheckIcon } from 'lucide-vue-next';

defineProps({
modelValue: { type: Boolean, default: false },
release: { type: Object, required: true },
showAfterUpdate: { type: Boolean, default: true },
});

defineEmits(['dismiss', 'changelog', 'update:showAfterUpdate']);
</script>
6 changes: 5 additions & 1 deletion app/components/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ async function captureThumbnail() {
await previewRef.value?.captureThumbnail();
}

defineExpose({ captureThumbnail });
defineExpose({
captureThumbnail,
exportImage: (method) => previewRef.value?.saveAs(method),
copyImage: () => previewRef.value?.copyToClipboard(),
});

watch(
() => editors.value.length,
Expand Down
Loading
Loading