Skip to content

Commit 475c68d

Browse files
committed
- Popup editor now mostly works
- Add option to disable animations - Clean up code - Mess up code - Fix typo in package name - Upgrade vite-plugin-svelte to fix: sveltejs/vite-plugin-svelte#641 - Upgrade vite to patch CVE - Allow importing CSS into component scopes
1 parent aeb8f15 commit 475c68d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3678
-1505
lines changed

package-lock.json

Lines changed: 2462 additions & 1262 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "firefox-profile-swticher",
2+
"name": "firefox-profile-switcher",
33
"version": "2.0.0",
44
"displayName": "Profile Switcher for Firefox",
55
"author": "null-dev",
@@ -18,18 +18,21 @@
1818
"license": "MIT",
1919
"devDependencies": {
2020
"@samrum/vite-plugin-web-extension": "^2.2.0",
21-
"@sveltejs/vite-plugin-svelte": "^2.0.2",
21+
"@sveltejs/vite-plugin-svelte": "^2.4.1",
2222
"@tsconfig/svelte": "^3.0.0",
2323
"@types/marked": "^4.0.8",
2424
"@types/webextension-polyfill": "^0.9.2",
25+
"@untemps/svelte-use-tooltip": "^2.8.0",
26+
"animejs": "^3.2.1",
2527
"svelte": "^3.55.0",
2628
"svelte-check": "^3.0.1",
2729
"svelte-dnd-action": "github:null-dev/svelte-dnd-action-nd.git#diff",
2830
"svelte-highlight": "^6.2.1",
2931
"svelte-preprocess": "^5.0.0",
32+
"magic-string": "^0.30.0",
3033
"tslib": "^2.4.1",
3134
"typescript": "^4.9.4",
32-
"vite": "~4.0.3",
35+
"vite": "~4.3.9",
3336
"web-ext": "^7.4.0"
3437
},
3538
"dependencies": {

src/assets/list.svg

Lines changed: 1 addition & 0 deletions
Loading

src/entries/manager/components/bottombar/BottomBar.svelte

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,23 @@
9292
import settingsIcon from "~/assets/settings-gray.svg";
9393
import Button from "~/lib/components/button/Button.svelte";
9494
import {ButtonType} from "~/lib/components/button/button";
95-
import {resolveAsset} from "~/lib/utils";
95+
import {resolveAsset} from "~/lib/util/assets";
9696
import {CURRENT_OPERATION, EDIT_MODE_CONTEXT, OperationKind} from "../manager";
97-
import {getTypedContext} from "~/lib/typed-context";
97+
import {getTypedContext} from "~/lib/util/typed-context";
9898
import ProfileEditor from "../editor/ProfileEditor.svelte";
9999
import {defaultProfileOptions} from "~/lib/model/profiles";
100100
import {globalOptionsStore, profileListStore} from "~/lib/common";
101101
import OptionsEditor from "../options/OptionsEditor.svelte";
102+
import listIcon from "~/assets/list.svg";
103+
import {fade, slide} from 'svelte/transition';
102104
103105
const editMode = getTypedContext(EDIT_MODE_CONTEXT);
104106
const currentOperation = getTypedContext(CURRENT_OPERATION);
105107
108+
export let openPopupEditor: () => void | null = null;
109+
export let closePopupEditor: (save: boolean) => void | null = null;
110+
export let popupEditorActive: boolean = false;
111+
106112
let lastOperation;
107113
$: if($currentOperation != null) {
108114
lastOperation = $currentOperation;
@@ -148,6 +154,8 @@
148154
pokeOperationIdleTimer();
149155
$currentOperation // Trigger when $currentOperation changes
150156
}
157+
158+
const buttonTransition = {duration: 250, axis: 'x'};
151159
</script>
152160

153161
<div class="bottom-bar" class:expanded={$currentOperation != null}>
@@ -158,15 +166,36 @@
158166
<b>Profile&nbsp;Switcher</b> for&nbsp;Firefox
159167
</div>
160168
</div>
169+
<!-- TODO What to do about this transition? -->
161170
<div class="bottom-bar-controls">
162-
<Button on:click={startAddProfileOperation}>+ Add profile</Button>
163-
<Button on:click={() => $editMode = !$editMode}
164-
type={$editMode ? ButtonType.Primary : ButtonType.Normal}>
165-
{$editMode ? "Exit edit mode" : "Edit profiles"}
166-
</Button>
167-
<Button on:click={startEditOptionsOperation}>
168-
<img class="control-icon invert-when-dark" src={resolveAsset(settingsIcon)} alt="Settings icon"/>
169-
</Button>
171+
{#if popupEditorActive}
172+
<div transition:slide|local={buttonTransition}>
173+
<Button on:click={() => closePopupEditor?.(false)}>Cancel</Button>
174+
</div>
175+
<div transition:slide|local={buttonTransition}>
176+
<Button on:click={() => closePopupEditor?.(true)}
177+
type={ButtonType.Primary}>
178+
Save
179+
</Button>
180+
</div>
181+
{/if}
182+
{#if !popupEditorActive}
183+
{#if $editMode}
184+
<div>
185+
<Button on:click={openPopupEditor}>
186+
Popup editor
187+
</Button>
188+
</div>
189+
{/if}
190+
<Button on:click={startAddProfileOperation}>+ Add profile</Button>
191+
<Button on:click={() => $editMode = !$editMode}
192+
type={$editMode ? ButtonType.Primary : ButtonType.Normal}>
193+
{$editMode ? "Exit edit mode" : "Edit profiles"}
194+
</Button>
195+
<Button on:click={startEditOptionsOperation}>
196+
<img class="control-icon invert-when-dark" src={resolveAsset(settingsIcon)} alt="Settings icon"/>
197+
</Button>
198+
{/if}
170199
</div>
171200
</div>
172201
{#if lastOperation != null && ($currentOperation != null || !operationIdle)}

src/entries/manager/components/editor/AvatarPictureOption.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
import {loadAvatarIntoImageAction, profileListStore} from "~/lib/common";
5252
import {scale} from "svelte/transition";
5353
import deleteIcon from "~/assets/delete-white.svg";
54-
import {resolveAsset} from "~/lib/utils";
54+
import {resolveAsset} from "~/lib/util/assets";
5555
import Loader from "~/lib/components/loader/Loader.svelte";
5656
import {nativeDeleteAvatar} from "~/lib/native";
5757
import type {AvatarItem} from "./avatar";

src/entries/manager/components/editor/EditButton.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import {resolveAsset} from "~/lib/utils";
2+
import {resolveAsset} from "~/lib/util/assets";
33
import Loader from "~/lib/components/loader/Loader.svelte";
44
55
export let src;

src/entries/manager/components/editor/PictureList.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
<script lang="ts">
3737
import addIcon from "~/assets/add-white.svg";
38-
import {resolveAsset} from "~/lib/utils";
38+
import {resolveAsset} from "~/lib/util/assets";
3939
import resAvatarList from "~/assets/avatarlist/avatarlist.json";
4040
import {customAvatarsStore} from "~/lib/common";
4141
import AvatarPictureOption from "./AvatarPictureOption.svelte";

src/entries/manager/components/editor/ProfileEditor.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import ManagerPage from "../../main/ManagerPage.svelte";
44
import Button from "~/lib/components/button/Button.svelte";
55
import {ButtonType} from "~/lib/components/button/button";
6-
import {getTypedContext} from "~/lib/typed-context";
6+
import {getTypedContext} from "~/lib/util/typed-context";
77
import {confirmAndDeleteProfile, CURRENT_OPERATION, NEW_PROFILE_EVENT} from "../manager";
8-
import {getUniqueElementId} from "~/lib/utils";
98
import Input from "~/lib/components/input/Input.svelte";
109
import PictureList from "./PictureList.svelte";
1110
import {nativeCreateProfile, nativeDeleteProfile, nativeUpdateProfile} from "~/lib/native";
12-
import {success} from "~/lib/toast";
11+
import {success} from "~/lib/util/toast";
1312
import InputLabel from "~/lib/components/input/InputLabel.svelte";
13+
import {getUniqueElementId} from "~/lib/util/dom";
1414
1515
export let operation: EditProfileOperation;
1616

src/entries/manager/components/manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {newContextKey} from "~/lib/typed-context";
1+
import {newContextKey} from "~/lib/util/typed-context";
22
import type {Writable} from "svelte/store";
33
import type {GlobalOptions, Profile, ProfileOptions} from "~/lib/model/profiles";
44
import {nativeDeleteProfile} from "~/lib/native";

src/entries/manager/components/options/OptionsEditor.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
import Button from "~/lib/components/button/Button.svelte";
1616
import {ButtonType} from "~/lib/components/button/button";
1717
import Input from "~/lib/components/input/Input.svelte";
18-
import {getUniqueElementId} from "~/lib/utils";
1918
import {CURRENT_OPERATION} from "../manager";
2019
import type {EditOptionsOperation} from "../manager";
2120
import type {GlobalOptions, ProfileOptions} from "~/lib/model/profiles";
22-
import {getTypedContext} from "~/lib/typed-context";
21+
import {getTypedContext} from "~/lib/util/typed-context";
2322
import InputLabel from "~/lib/components/input/InputLabel.svelte";
2423
import {profileListStore} from "~/lib/common";
2524
import {nativeUpdateOptions, nativeUpdateProfile} from "~/lib/native";
25+
import {getUniqueElementId} from "~/lib/util/dom";
2626
2727
export let operation: EditOptionsOperation;
2828
@@ -40,13 +40,15 @@
4040
let darkModeAllChecked = false;
4141
let windowFocusWorkAroundChecked = false;
4242
let editModeAlwaysShowOptionsChecked = false;
43+
let popupProfileOrder = null;
4344
deserializeSettings(operation.initialProfileOptions, operation.initialGlobalOptions)
4445
4546
function deserializeSettings(profile: ProfileOptions, global: GlobalOptions) {
4647
darkModeChecked = global.darkMode ?? profile.darkMode;
4748
darkModeAllChecked = global.darkMode != null;
4849
windowFocusWorkAroundChecked = global.windowFocusWorkaround;
4950
editModeAlwaysShowOptionsChecked = global.editModeAlwaysShowOptions;
51+
popupProfileOrder = global.popupProfileOrder;
5052
}
5153
5254
let saving = false;
@@ -61,6 +63,8 @@
6163
darkMode: darkModeAllChecked ? darkModeChecked : null,
6264
windowFocusWorkaround: windowFocusWorkAroundChecked,
6365
editModeAlwaysShowOptions: editModeAlwaysShowOptionsChecked,
66+
disableAnimations: false, // TODO
67+
popupProfileOrder
6468
};
6569
6670
const profileList = $profileListStore?.profiles;

0 commit comments

Comments
 (0)