Skip to content

Commit

Permalink
Release v0.0.3 (onlook-dev#79)
Browse files Browse the repository at this point in the history
* Incremented version v0.0.3

* Add onboard flow
  • Loading branch information
Kitenite authored Jul 23, 2024
1 parent ca25e81 commit 3c741e3
Show file tree
Hide file tree
Showing 18 changed files with 204 additions and 31 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build

on:
push:
branches: [main, release/*]
branches: [main, releases/*]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
paths-ignore:
Expand All @@ -19,7 +19,7 @@ on:
jobs:
build:
runs-on: ${{ matrix.os }}

permissions:
contents: write

Expand All @@ -45,6 +45,13 @@ jobs:
- name: Install dependencies
run: cd app && npm install

- name: Set environment variables
run: |
echo "VITE_SUPABASE_API_URL=${{ secrets.SUPABASE_API_URL }}" >> app/.env
echo "VITE_SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}" >> app/.env
echo "VITE_MIXPANEL_TOKEN=${{ secrets.MIXPANEL_TOKEN }}" >> app/.env
cat app/.env
- name: Build/release Electron app
uses: samuelmeuli/action-electron-builder@v1
with:
Expand All @@ -57,4 +64,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APPLE_API_KEY: ~/private_keys/AuthKey_${{ secrets.APPLE_API_KEY_ID }}.p8
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
5 changes: 3 additions & 2 deletions app/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SUPABASE_API_URL=http://127.0.0.1:54321
SUPABASE_ANON_KEY=
VITE_SUPABASE_API_URL=
VITE_SUPABASE_ANON_KEY=
VITE_MIXPANEL_TOKEN=
2 changes: 2 additions & 0 deletions app/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export enum MainChannels {
GET_STYLE_CODE = 'get-style-code',
OPEN_TUNNEL = 'open-tunnel',
CLOSE_TUNNEL = 'close-tunnel',
ANLYTICS_PREF_SET = 'analytics-pref-set',
SEND_ANALYTICS = 'send-analytics',
}

export enum Links {
Expand Down
4 changes: 1 addition & 3 deletions app/electron/main/analytics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ class Analytics {
mixpanel: ReturnType<typeof Mixpanel.init> | undefined;

constructor() {
return; // Disabled until opt-in flow is created

try {
this.mixpanel = Mixpanel.init(process.env.MIXPANEL_TOKEN || '');
this.mixpanel = Mixpanel.init(import.meta.env.VITE_MIXPANEL_TOKEN || '');
} catch (error) {
console.error('Error initializing Mixpanel:', error);
console.log('No Mixpanel client, analytics will not be collected');
Expand Down
3 changes: 1 addition & 2 deletions app/electron/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dotenv/config';
import { BrowserWindow, app, shell } from 'electron';
import { createRequire } from 'node:module';
import os from 'node:os';
Expand All @@ -13,11 +12,11 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));

process.env.APP_ROOT = path.join(__dirname, '../..');
process.env.WEBVIEW_PRELOAD_PATH = path.join(__dirname, '../preload/webview.js');
process.env.APP_VERSION = app.getVersion();

export const MAIN_DIST = path.join(process.env.APP_ROOT, 'dist-electron');
export const RENDERER_DIST = path.join(process.env.APP_ROOT, 'dist');
export const VITE_DEV_SERVER_URL = process.env.VITE_DEV_SERVER_URL;

process.env.VITE_PUBLIC = VITE_DEV_SERVER_URL
? path.join(process.env.APP_ROOT, 'public')
: RENDERER_DIST;
Expand Down
17 changes: 17 additions & 0 deletions app/electron/main/ipcEvents.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { ipcMain } from 'electron';
import Analytics from './analytics';
import { writeStyle } from './code';
import { openInVsCode, writeCodeResults } from './code/files';
import { TunnelService } from './tunnel';
import { MainChannels } from '/common/constants';
import { CodeResult, TemplateNode, WriteStyleParams } from '/common/models';

export function listenForIpcMessages() {
let analytics: Analytics | null = null;
const tunnelService = new TunnelService();

ipcMain.handle(MainChannels.OPEN_CODE_BLOCK, (e: Electron.IpcMainInvokeEvent, args) => {
Expand All @@ -31,4 +33,19 @@ export function listenForIpcMessages() {
ipcMain.handle(MainChannels.CLOSE_TUNNEL, (e: Electron.IpcMainInvokeEvent) => {
return tunnelService.close();
});

ipcMain.on(MainChannels.ANLYTICS_PREF_SET, (e: Electron.IpcMainInvokeEvent, args) => {
const analyticsPref = args as boolean;
if (analyticsPref) {
analytics = new Analytics();
analytics.track('analytics-allowed');
}
});

ipcMain.on(MainChannels.SEND_ANALYTICS, (e: Electron.IpcMainInvokeEvent, args) => {
if (analytics) {
const { event, data } = args as { event: string; data: object };
analytics.track(event, data);
}
});
}
7 changes: 3 additions & 4 deletions app/electron/preload/browserview/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ declare global {

const env = {
WEBVIEW_PRELOAD_PATH: process.env.WEBVIEW_PRELOAD_PATH,
SUPABASE_API_URL: process.env.SUPABASE_API_URL,
SUPABASE_ANON_KEY: process.env.SUPABASE_ANON_KEY,
APP_VERSION: process.env.APP_VERSION,
};

const store = {
Expand All @@ -28,8 +27,8 @@ const store = {
};

const api = {
sendMessage<T>(channel: MainChannels, args: T[]) {
ipcRenderer.send(channel, args);
send<T>(channel: MainChannels, args: T[]) {
ipcRenderer.send(channel, ...args);
},

on<T>(channel: MainChannels, func: (...args: T[]) => void) {
Expand Down
3 changes: 1 addition & 2 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"productName": "Onlook",
"name": "@onlook/browser",
"version": "0.0.2",
"version": "0.0.3",
"homepage": "https://onlook.dev",
"main": "dist-electron/main/index.js",
"description": "The first-ever devtool for designers",
Expand Down Expand Up @@ -54,7 +54,6 @@
"clsx": "^2.1.1",
"css-to-tailwind-translator": "^1.2.8",
"culori": "^4.0.1",
"dotenv": "^16.4.5",
"electron-updater": "^6.2.1",
"fflate": "^0.8.2",
"framer-motion": "^11.2.12",
Expand Down
4 changes: 4 additions & 0 deletions app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import Announcement from './components/Announcement';
import AppBar from './components/AppBar';
import { ThemeProvider } from './components/theme-provider';
import { Toaster } from './components/ui/toaster';
import ProjectEditor from './routes/project';

function App() {
return (
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
<AppBar />
<ProjectEditor />
<Announcement />
<Toaster />
</ThemeProvider>
);
}
Expand Down
Binary file added app/src/assets/mountains.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions app/src/assets/word-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
133 changes: 133 additions & 0 deletions app/src/components/Announcement/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import mountains from '@/assets/mountains.png';
import wordLogo from '@/assets/word-logo.svg';
import supabase from '@/lib/backend';
import {
BoxIcon,
CheckboxIcon,
DiscordLogoIcon,
GitHubLogoIcon,
LayersIcon,
} from '@radix-ui/react-icons';
import { useState } from 'react';
import { Button } from '../ui/button';
import { Dialog, DialogContent } from '../ui/dialog';
import { Input } from '../ui/input';
import { Toggle } from '../ui/toggle';
import { toast } from '../ui/use-toast';
import { MainChannels } from '/common/constants';

function Announcement() {
const [checked, setChecked] = useState(true);
const [open, setOpen] = useState(true);
const [email, setEmail] = useState('');
const [error, setError] = useState('');

async function handleSubscribe() {
try {
if (!email || !email.match(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)) {
throw new Error('Email is invalid');
}

if (!supabase) {
throw new Error('No backend connected');
}
const { data, error } = await supabase.from('subscription').insert([
{
email,
},
]);
if (error) {
throw error;
}
setError('');
setEmail('');
toast({
title: 'Email Subscribed 🎉',
description: 'Thank you for following the progress!',
});
} catch (error: any) {
console.error('Error subscribing:', error);
setError('Error: ' + error.message || error);
}
}

function handleOpenChange(value: boolean) {
setOpen(false);
if (!value) {
window.api.send(MainChannels.ANLYTICS_PREF_SET, [checked]);
}
}

return (
<Dialog open={open} onOpenChange={handleOpenChange}>
<DialogContent className="text-white/60 space-x-2 text-sm space-y-2">
<div className="flex relative items-start w-[calc(100%+3rem)] h-72 -m-6 mb-0 border-b rounded-t-lg overflow-hidden">
<img
className="absolute w-[calc(100%+3rem)]"
src={mountains}
alt="Onlook logo"
/>
<div className="absolute top-10 w-full items-center flex flex-col space-y-2">
<img className="w-1/4" src={wordLogo} alt="Onlook logo" />
<p className="text-xs">Version {window.env.APP_VERSION}</p>
</div>
</div>
<div className="space-y-6">
<div className="space-y-2">
<p>Stay up to date with Onlook</p>
<div className="flex flex-row space-x-2">
<Input
className="bg-bg outline-none"
placeholder="contact@onlook.dev"
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
<Button variant={'outline'} onClick={handleSubscribe}>
Email me updates
</Button>
</div>
<p className="text-red-500">{error}</p>
</div>
<div className="grid grid-cols-2">
<div className="space-y-2">
<p>Resources</p>
<div className="flex flex-col space-y-1 ml-2">
<div className="flex flex-row items-center">
<GitHubLogoIcon className="mr-2" /> Star Github Repo
</div>
<div className="flex flex-row items-center">
<DiscordLogoIcon className="mr-2" />
Join Discord
</div>
<div className="flex flex-row items-center">
<LayersIcon className="mr-2" /> Browse Docs
</div>
</div>
</div>

<div className="space-y-2">
<p>Settings</p>
<div className="flex flex-row items-center space-x-2">
<Toggle
pressed={checked}
size="sm"
className="h-7 p-0 px-2 rounded data-[state=on]:bg-bg-positive data-[state=on]:text-teal-700"
onPressedChange={(value) => setChecked(value)}
>
{checked ? <CheckboxIcon /> : <BoxIcon />}
</Toggle>
<div className="text-xs">
<p className="text-white">Share anonymized analytics</p>
<p>This helps our small team a lot!</p>
</div>
</div>
</div>
</div>
</div>
</DialogContent>
</Dialog>
);
}

export default Announcement;
3 changes: 2 additions & 1 deletion app/src/components/AppBar/FeedbackDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function FeedbackDialog() {
},
]);
if (error) {
throw error.message;
throw error;
}
setOpen(false);
clearContent();
Expand All @@ -54,6 +54,7 @@ function FeedbackDialog() {
setError('Error submitting feedback: ' + error.message || error);
}
}

return (
<AlertDialog open={open}>
<AlertDialogTrigger asChild>
Expand Down
1 change: 0 additions & 1 deletion app/src/components/theme-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export function ThemeProvider({
return (
<ThemeProviderContext.Provider {...props} value={value}>
<div className="min-w-screen min-h-screen">{children}</div>
<Toaster />
</ThemeProviderContext.Provider>
);
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module '*.jpg';
declare module '*.svg';
declare module '*.png';
5 changes: 4 additions & 1 deletion app/src/lib/backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { createClient } from '@supabase/supabase-js';
let supabase: ReturnType<typeof createClient> | undefined;

try {
supabase = createClient(window.env.SUPABASE_API_URL || '', window.env.SUPABASE_ANON_KEY || '');
supabase = createClient(
import.meta.env.VITE_SUPABASE_API_URL || '',
import.meta.env.VITE_SUPABASE_ANON_KEY || '',
);
} catch (error) {
console.error('Error initializing Supabase:', error);
}
Expand Down
22 changes: 11 additions & 11 deletions demos/next/components/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import Link from "next/link"
import { Badge } from "@/components/ui/badge"
import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from "@/components/ui/breadcrumb"
import { Button } from "@/components/ui/button"
import { SheetTrigger, SheetContent, Sheet } from "@/components/ui/sheet"
import { BreadcrumbLink, BreadcrumbItem, BreadcrumbSeparator, BreadcrumbPage, BreadcrumbList, Breadcrumb } from "@/components/ui/breadcrumb"
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
import { Input } from "@/components/ui/input"
import { DropdownMenuTrigger, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuItem, DropdownMenuContent, DropdownMenu, DropdownMenuCheckboxItem } from "@/components/ui/dropdown-menu"
import { CardTitle, CardDescription, CardHeader, CardFooter, Card, CardContent } from "@/components/ui/card"
import { Pagination, PaginationContent, PaginationItem } from "@/components/ui/pagination"
import { Progress } from "@/components/ui/progress"
import { TabsTrigger, TabsList, TabsContent, Tabs } from "@/components/ui/tabs"
import { TableHead, TableRow, TableHeader, TableCell, TableBody, Table } from "@/components/ui/table"
import { Badge } from "@/components/ui/badge"
import { Separator } from "@/components/ui/separator"
import { PaginationItem, PaginationContent, Pagination } from "@/components/ui/pagination"
import { ChevronLeftIcon, ChevronRightIcon, CopyIcon, CreditCardIcon, FileIcon, HomeIcon, LineChartIcon, ListFilterIcon, MoveVerticalIcon, Package2Icon, PackageIcon, PanelLeftIcon, SearchIcon, SettingsIcon, ShoppingCartIcon, TruckIcon, UsersIcon } from "./shared"
import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import Link from "next/link"
import { ChevronLeftIcon, ChevronRightIcon, CopyIcon, CreditCardIcon, FileIcon, HomeIcon, LineChartIcon, ListFilterIcon, MoveVerticalIcon, Package2Icon, PackageIcon, PanelLeftIcon, SearchIcon, ShoppingCartIcon, TruckIcon, UsersIcon } from "./shared"
import { Sidebar } from "./sidebar"

export function Dashboard() {
Expand Down Expand Up @@ -473,4 +473,4 @@ export function Dashboard() {
</div>
</div >
)
}
}
Loading

0 comments on commit 3c741e3

Please sign in to comment.