Skip to content

Commit

Permalink
feat: filter organizations and color updates (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelkristiansson authored Oct 14, 2024
1 parent 306541e commit 5762126
Show file tree
Hide file tree
Showing 64 changed files with 2,380 additions and 1,195 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: setup node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 16
node-version: lts/*
- name: install Rust stable
uses: actions-rs/toolchain@v1
with:
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
14 changes: 14 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://shadcn-svelte.com/schema.json",
"style": "default",
"tailwind": {
"config": "tailwind.config.js",
"css": "src/app.css",
"baseColor": "gray"
},
"aliases": {
"components": "$lib/components",
"utils": "$lib/utils"
},
"typescript": true
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gitbar</title>
</head>
<body class="bg-white text-slate-500 antialiased dark:bg-stone-900 dark:text-slate-400 overflow-hidden">
<body class="antialiased overflow-hidden">
<div id="app" class="h-screen"></div>
<script type="module" src="/src/main.ts"></script>
</body>
Expand Down
25 changes: 15 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gitbar",
"private": true,
"version": "0.6.1",
"version": "0.7.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -14,20 +14,25 @@
},
"dependencies": {
"@tauri-apps/api": "^1.6.0",
"svelte": "^3.53.1"
"bits-ui": "^0.21.16",
"clsx": "2.1.1",
"svelte": "4.2.19",
"tailwind-merge": "2.5.3",
"tailwind-variants": "0.2.1"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^1.2.0",
"@sveltejs/vite-plugin-svelte": "3.1.2",
"@tauri-apps/cli": "^1.6.1",
"@tsconfig/svelte": "^3.0.0",
"@tsconfig/svelte": "5.0.4",
"autoprefixer": "^10.4.13",
"lucide-svelte": "^0.452.0",
"postcss": "^8.4.18",
"svelte-check": "^2.9.2",
"svelte-preprocess": "^4.10.7",
"tailwindcss": "^3.2.3",
"tslib": "^2.4.1",
"typescript": "^4.8.2",
"vite": "^3.0.9"
"svelte-check": "4.0.4",
"svelte-preprocess": "6.0.3",
"tailwindcss": "3.4.13",
"tslib": "2.7.0",
"typescript": "5.6.3",
"vite": "5.4.8"
},
"prettier": {
"tabWidth": 2,
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gitbar"
version = "0.6.1"
version = "0.7.0"
description = "Github review counter"
authors = ["mikael.kristiansson"]
license = "MIT"
Expand Down
87 changes: 55 additions & 32 deletions src/app.css
Original file line number Diff line number Diff line change
@@ -1,35 +1,58 @@
/* Write your global styles here, in PostCSS syntax */
@tailwind base;
[multiple],
[type='date'],
[type='datetime-local'],
[type='email'],
[type='month'],
[type='number'],
[type='password'],
[type='search'],
[type='tel'],
[type='text'],
[type='time'],
[type='url'],
[type='week'],
select,
textarea {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-color: #fff;
border-color: #6b7280;
border-width: 1px;
border-radius: 0;
padding-top: 0.5rem;
padding-right: 0.75rem;
padding-bottom: 0.5rem;
padding-left: 0.75rem;
font-size: 1rem;
line-height: 1.5rem;
--tw-shadow: 0 0 #0000;
outline: none;
}
@tailwind components;
@tailwind utilities;

@layer base {
:root {
--background: 0 0% 100%;
--foreground: 240 10% 3.9%;
--card: 0 0% 100%;
--card-foreground: 240 10% 3.9%;
--popover: 0 0% 100%;
--popover-foreground: 240 10% 3.9%;
--primary: 137.14 62.87% 32.75%;
--primary-foreground: 0 0% 98%;
--secondary: 240 4.8% 95.9%;
--secondary-foreground: 240 5.9% 10%;
--muted: 240 4.8% 95.9%;
--muted-foreground: 240 3.8% 46.1%;
--accent: 240 4.8% 95.9%;
--accent-foreground: 240 5.9% 10%;
--destructive: 0 72.22% 50.59%;
--destructive-foreground: 0 0% 98%;
--border: 240 5.9% 90%;
--input: 240 5.9% 90%;
--ring: 240 5.9% 10%;
--radius: 0.5rem;
}
.dark {
--background: 240 10% 3.9%;
--foreground: 0 0% 98%;
--card: 240 10% 3.9%;
--card-foreground: 0 0% 98%;
--popover: 240 10% 3.9%;
--popover-foreground: 0 0% 98%;
--primary: 131.52 58.58% 33.14%;
--primary-foreground: 0 0% 98%;
--secondary: 240 3.7% 15.9%;
--secondary-foreground: 0 0% 98%;
--muted: 240 3.7% 15.9%;
--muted-foreground: 240 5% 64.9%;
--accent: 240 3.7% 15.9%;
--accent-foreground: 0 0% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 0 0% 98%;
--border: 240 3.7% 15.9%;
--input: 240 3.7% 15.9%;
--ring: 240 4.9% 83.9%;
}
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
135 changes: 82 additions & 53 deletions src/components/Filters.svelte
Original file line number Diff line number Diff line change
@@ -1,79 +1,108 @@
<script lang="ts">
import Toggle from './Toggle.svelte';
import { onMount } from 'svelte';
import { auth } from '../lib/auth';
import Select from './Select.svelte';
import { getOrganizations } from '../lib/api';
import * as Select from '$lib/components/ui/select';
import { Button } from '$lib/components/ui/button';
import { Switch } from '$lib/components/ui/switch';
import { Label } from '$lib/components/ui/label';
export let modalVisible: boolean;
export let onSaved: () => void;
let showArchive = $auth.githubSettings.archive;
let state = $auth.githubSettings.state;
let type = $auth.githubSettings.type;
let selectedOrganizations = $auth.githubSettings.organizations || [];
let organizationOptions: Array<{ value: string; label: string }> = [];
const changeShowArchive = e => {
showArchive = e.target.checked;
const changeShowArchive = (checked: boolean) => {
showArchive = checked;
};
const onSave = () => {
$auth.updateGithubSettings({
archive: showArchive,
state,
type,
organizations: selectedOrganizations,
});
modalVisible = false;
onSaved();
};
const updateSelectedOrganizations = (target: any) => {
const incoming = target as { value: string; label: string }[];
selectedOrganizations = incoming.map(i => i.value);
};
const updateType = (target: any) => (type = target.value);
const updateState = (target: any) => (state = target.value);
const typeOptions = [
{ value: 'review-requested', label: 'Reviews' },
{ value: 'author', label: 'Created' },
{ value: 'mentions', label: 'Mentions' },
{ value: 'assignee', label: 'Assigned' },
];
const stateOptions = [
{ value: 'open', label: 'Open' },
{ value: 'closed', label: 'Closed' },
{ value: 'all', label: 'All' },
];
onMount(() => {
if (!$auth.account) return;
getOrganizations($auth.account).then(orgs => {
organizationOptions = orgs.map(org => ({ value: org, label: org }));
});
});
</script>

<div class="flex justify-between items-start p-4 rounded-t border-b dark:border-slate-900">
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">Filters</h3>
<button
type="button"
class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white"
on:click={() => (modalVisible = false)}
>
<svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<path
fill-rule="evenodd"
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
clip-rule="evenodd"
/>
</svg>
<span class="sr-only">Close modal</span>
</button>
</div>
<div class="p-6 space-y-6">
<div>
<Toggle name="archive" checked={showArchive} label="Show archived" on:change={changeShowArchive} />
<Select
name="type"
label="Type"
options={[
{ value: 'review-requested', label: 'Reviews' },
{ value: 'author', label: 'Created' },
{ value: 'mentions', label: 'Mentions' },
{ value: 'assignee', label: 'Assigned' },
]}
selected={type}
onChange={e => (type = e.target.value)}
/>
<Select
name="state"
label="State"
options={[
{ value: 'open', label: 'Open' },
{ value: 'closed', label: 'Closed' },
{ value: 'all', label: 'All' },
]}
selected={state}
onChange={e => (state = e.target.value)}
/>
<div class="space-y-6">
<div class="flex flex-col gap-4">
<div class="flex items-center space-x-2">
<Switch id="archive" name="archive" checked={showArchive} onCheckedChange={changeShowArchive} />
<Label for="archive">Show archived</Label>
</div>
<div class="flex items-center justify-between gap-4">
<Select.Root items={typeOptions} selected={typeOptions.find(v => type)} onSelectedChange={updateType}>
<Select.Trigger>
<Select.Value placeholder="Type" />
</Select.Trigger>
<Select.Content>
{#each typeOptions as { value, label }}
<Select.Item {value} {label}>{label}</Select.Item>
{/each}
</Select.Content>
</Select.Root>
<Select.Root items={stateOptions} selected={stateOptions.find(v => state)} onSelectedChange={updateState}>
<Select.Trigger>
<Select.Value placeholder="State" />
</Select.Trigger>
<Select.Content>
{#each stateOptions as { value, label }}
<Select.Item {value} {label}>{label}</Select.Item>
{/each}
</Select.Content>
</Select.Root>
</div>
<Select.Root
items={organizationOptions}
selected={selectedOrganizations.map(v => ({ value: v, label: v }))}
multiple
onSelectedChange={updateSelectedOrganizations}
>
<Select.Trigger class="w-full">
<Select.Value placeholder="Organizations" />
</Select.Trigger>
<Select.Content>
{#each organizationOptions as { value, label }}
<Select.Item {value} {label}>{label}</Select.Item>
{/each}
</Select.Content>
</Select.Root>
</div>
<div class="relative mt-4 flex items-end justify-end">
<button
type="button"
on:click={onSave}
class="text-white font-bold bg-blue-600 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 rounded-md text-sm px-4 py-2 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800"
>Save</button
>
<Button type="button" size="sm" on:click={onSave}>Save</Button>
</div>
</div>
Loading

0 comments on commit 5762126

Please sign in to comment.