Skip to content

Commit

Permalink
feat: connect modal layout update
Browse files Browse the repository at this point in the history
  • Loading branch information
peronczyk committed Nov 15, 2024
1 parent 1d5958e commit 7a02d70
Show file tree
Hide file tree
Showing 44 changed files with 657 additions and 454 deletions.
11 changes: 6 additions & 5 deletions src/background/bgPopupHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ const popups: Dictionary<IPopupConfigNoActions> = {};

const storageSession = (browser.storage as any)?.session;

export const getAeppUrl = (v: any) => new URL(v.connection.port.sender.url);

export const openPopup = async (
popupType: PopupType,
aepp: string | object,
aepp: string | Record<string, any>, // TODO establish correct type for the object
popupProps: Partial<IPopupProps> = {},
) => {
const id = uuid();
const { href, protocol, host } = (typeof aepp === 'object') ? getAeppUrl(aepp) : new URL(aepp);
const { name = host } = (typeof aepp === 'object') ? aepp : {} as any;
const url = (typeof aepp === 'object') ? aepp.connection.port.sender.url : aepp;
const { href, protocol, host } = new URL(url);

// TODO fix the name resolving issue happening in `onSubscription` of aeSdk
const name = (typeof aepp === 'object') ? aepp.name : undefined;

const tabs = await browser.tabs.query({ active: true });

Expand Down
8 changes: 6 additions & 2 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ import { updateDynamicRules } from './redirectRule';
/**
* @see https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage#sending_an_asynchronous_response_using_sendresponse
*/
function handleMessage(msg: IBackgroundMessageData, _: any, sendResponse: Function) {
const handleMessage: browser.runtime.onMessageBool = (
msg: IBackgroundMessageData,
sender: browser.runtime.MessageSender,
sendResponse: Function,
) => {
if (msg.target === 'background') {
const {
aepp,
Expand Down Expand Up @@ -73,7 +77,7 @@ function handleMessage(msg: IBackgroundMessageData, _: any, sendResponse: Functi
target: 'offscreen',
});
return true;
}
};

browser.runtime.onMessage.addListener(handleMessage);
browser.runtime.onInstalled.addListener(updateDynamicRules);
57 changes: 55 additions & 2 deletions src/constants/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,11 @@ export const POPUP_TYPES = [
POPUP_TYPE_UNSAFE_SIGN,
] as const;

export const POPUP_CONNECT_ADDRESS_PERMISSION = 'address';
export const POPUP_CONNECT_TRANSACTIONS_PERMISSION = 'transactions';
export const CONNECT_PERMISSIONS = {
address: 'address',
addressList: 'addressList',
transactions: 'transactions',
} as const;

export const POPUP_ACTIONS = {
getProps: 'getProps',
Expand Down Expand Up @@ -467,6 +470,56 @@ export const BROWSER_ACTIONS = {
favourite: 'favourite',
} as const;

/**
* List of dapps that we are sure that we support.
*/
export const TRUSTED_DAPPS: {
name: string;
url: string;
image: string;
/** Display the dapp link in the app browser featured section */
isFeatured?: boolean;
}[] = [
{
name: 'Aeternity Governance',
url: 'https://governance.aeternity.com',
image: 'Governance.webp',
isFeatured: true,
},
{
name: 'Graffiti Aepp',
url: 'https://graffiti.aeternity.com',
image: 'graffiti.svg',
isFeatured: true,
},
{
name: 'Superhero Social',
url: 'https://superhero.com',
image: 'superhero-social.svg',
},
{
name: 'Superhero DEX',
url: 'https://aepp.dex.superhero.com',
image: 'superhero-dex.svg',
isFeatured: true,
},
{
name: 'aeScan',
url: 'https://aescan.io',
image: 'aescan.svg',
},
{
name: 'Tokaen.org (DEV)',
url: 'https://dev.tokaen.org',
image: 'tokaen-org.svg',
},
{
name: 'Tokaen.org',
url: 'https://tokaen.org',
image: 'tokaen-org.svg',
},
];

export const PAGE_TRANSITION_DURATION = 150;

export const MAX_BROWSER_HISTORY_ITEMS = 10;
Expand Down
2 changes: 1 addition & 1 deletion src/icons/bell.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions src/icons/bug-report.svg

This file was deleted.

File renamed without changes
3 changes: 0 additions & 3 deletions src/icons/check-mark.svg

This file was deleted.

4 changes: 4 additions & 0 deletions src/icons/dapp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions src/icons/dapp/SuperheroDEX.svg

This file was deleted.

3 changes: 3 additions & 0 deletions src/icons/dapp/aescan.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/icons/dapp/superhero-dex.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/icons/dapp/superhero-social.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions src/icons/dapp/tokaen-org.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions src/icons/plus-circle-fill.svg

This file was deleted.

2 changes: 1 addition & 1 deletion src/icons/wallet-connect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/popup/components/AccountCardAdd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { MODAL_PROTOCOL_SELECT, MODAL_ACCOUNT_CREATE, PROTOCOLS } from '@/consta
import { useModals } from '@/composables';
import AccountCardBase, { accountCardBaseCommonProps } from '@/popup/components/AccountCardBase.vue';
import PlusCircleIcon from '../../icons/plus-circle-fill.svg?vue-component';
import PlusCircleIcon from '../../icons/plus-circle.svg?vue-component';
export default defineComponent({
components: {
Expand Down
1 change: 1 addition & 0 deletions src/popup/components/AccountImportRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<AccountSelectOptionsItem
:custom-account="account"
:outside-balance="balance"
clickable
/>
</template>

Expand Down
18 changes: 11 additions & 7 deletions src/popup/components/AccountSelectOptionsItem.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<template>
<BtnPlain
<component
:is="(clickable) ? 'BtnPlain' : 'div'"
v-if="account"
class="account-select-options-item"
:style="bgColorStyle"
@click.prevent="$emit('click')"
>
<div
class="option-wrapper"
:class="{ selected }"
:class="{ selected, clickable }"
>
<AccountInfo
:account="account"
class="account-info"
avatar-size="rg"
avatar-borderless
is-list-name
show-protocol-icon
:show-protocol-icon="!hideProtocolIcon"
/>
<TokenAmount
v-if="!hideBalance"
:amount="balance"
:symbol="tokenSymbol"
:protocol="account.protocol"
Expand All @@ -26,7 +28,7 @@
small
/>
</div>
</BtnPlain>
</component>
</template>

<script lang="ts">
Expand Down Expand Up @@ -66,6 +68,9 @@ export default defineComponent({
default: 0,
},
selected: Boolean,
hideBalance: Boolean,
hideProtocolIcon: Boolean,
clickable: Boolean,
},
setup(props) {
const { getAccountBalance } = useBalances();
Expand Down Expand Up @@ -106,7 +111,6 @@ export default defineComponent({
--border-width: 3px;
width: 100%;
padding: 2px 8px;
.option-wrapper {
position: relative;
Expand All @@ -130,10 +134,10 @@ export default defineComponent({
border: var(--border-width) solid var(--bg-color);
box-sizing: border-box;
border-radius: 10px;
transition: background-color 0.12s ease-in-out;
transition: all 0.12s ease-in-out;
}
&:hover:not(.selected) {
&.clickable:hover:not(.selected) {
&::before {
opacity: 0.8;
}
Expand Down
21 changes: 9 additions & 12 deletions src/popup/components/AppsBrowser/AppsBrowserListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
class="apps-browser-list-item"
type="button"
>
<div
class="app-image-wrapper"
>
<div class="app-image-wrapper">
<img
v-if="imageUrl"
:src="imageUrl"
class="app-image"
alt="Dapp favicon"
>
</div>
<div class="app-title">
{{ title }}
</div>
<div
class="app-name"
v-text="name"
/>
</button>
</template>

Expand All @@ -25,10 +24,8 @@ import { computed, defineComponent } from 'vue';
export default defineComponent({
name: 'AppsBrowserListItem',
props: {
title: { type: String, required: true },
/**
* App image name, should be located in src\icons\dapp
*/
name: { type: String, required: true },
/** App image name, should be located in src\icons\dapp */
image: { type: String, default: null },
},
setup(props) {
Expand Down Expand Up @@ -67,7 +64,7 @@ export default defineComponent({
background: $color-disabled;
}
.app-title,
.app-name,
.app-image {
opacity: 1;
}
Expand All @@ -89,7 +86,7 @@ export default defineComponent({
opacity: 0.85;
}
.app-title {
.app-name {
padding: 4px 8px;
font-size: 12px;
line-height: 16px;
Expand Down
2 changes: 1 addition & 1 deletion src/popup/components/BulletSwitcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import { computed, defineComponent } from 'vue';
import BtnPlain from './buttons/BtnPlain.vue';
import PlusCircleIcon from '../../icons/plus-circle-fill.svg?vue-component';
import PlusCircleIcon from '../../icons/plus-circle.svg?vue-component';
// Physical size of the bullet area in pixels
const BULLET_SIZE = 16;
Expand Down
Loading

0 comments on commit 7a02d70

Please sign in to comment.