Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add solution for customization of the external links #259

Closed
wants to merge 3 commits into from
Closed
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
12 changes: 9 additions & 3 deletions packages/template/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@
<SpNavbar
:links="navbarLinks"
:active-route="router.currentRoute.value.path"
/>
>
<template #externals>
<SpAccDropdownExternalLink title='Support' link=''/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make links point to Starport properties by default, so https://discord.gg/ignt, https://twitter.com/starporthq, https://starport.com

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean like this:

<SpAccDropdownExternalLink title='Discord' link='https://discord.gg/ignt'/>
<SpAccDropdownExternalLink title='Twitter' link='https://twitter.com/starporthq'/>
<SpAccDropdownExternalLink title='Starport' link='https://starport.com/'/>

<SpAccDropdownExternalLink title='Twitter' link=''/>
<SpAccDropdownExternalLink title='Telegram' link=''/>
</template>
</SpNavbar>
<router-view />
</SpTheme>
</div>
</template>

<script lang="ts">
import { SpNavbar, SpTheme } from '@starport/vue'
import { SpAccDropdownExternalLink, SpNavbar, SpTheme } from '@starport/vue'
import { computed, onBeforeMount } from 'vue'
import { useRouter } from 'vue-router'
import { useStore } from 'vuex'

export default {
components: { SpTheme, SpNavbar },
components: { SpTheme, SpNavbar, SpAccDropdownExternalLink },

setup() {
// store
Expand Down
45 changes: 24 additions & 21 deletions packages/vue/src/components/SpAcc/SpAcc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,24 @@
<SpAccDropdown
v-if="state.accountDropdown"
:wallet="wallet"
:accName="getAccName()"
:acc-name="getAccName()"
@disconnect="disconnect"
@close="state.accountDropdown = false"
/>
>
<template #externals>
<slot name="externals"></slot>
</template>
</SpAccDropdown>
<SpModal
:visible="state.connectWalletModal"
:closeIcon="false"
:cancelButton="false"
:submitButton="false"
:close-icon="false"
:cancel-button="false"
:submit-button="false"
style="text-align: center"
@close="state.connectWalletModal = false"
@submit="state.connectWalletModal = false"
style="text-align: center"
>
<template v-slot:header>
<template #header>
<div v-if="state.modalPage === 'connect'">
<SpKeplrIcon />
<h3 v-if="isKeplrAvailable">Connect your wallet</h3>
Expand All @@ -53,7 +57,7 @@
<h3>Keplr cannot launch</h3>
</div>
</template>
<template v-slot:body>
<template #body>
<div style="max-width: 320px; text-align: center; margin: auto">
<div v-if="state.modalPage === 'connect'">
<p v-if="isKeplrAvailable">
Expand All @@ -72,8 +76,8 @@
<SpButton
aria-label="Cancel"
type="secondary"
@click="state.modalPage = 'connect'"
style="margin-top: 3rem"
@click="state.modalPage = 'connect'"
>
Cancel
</SpButton>
Expand All @@ -89,7 +93,7 @@
</div>
</div>
</template>
<template v-if="isKeplrAvailable" v-slot:footer>
<template v-if="isKeplrAvailable" #footer>
<div v-if="state.modalPage === 'connect'">
<SpButton
aria-label="Connect Keplr"
Expand Down Expand Up @@ -124,27 +128,26 @@
</template>

<script lang="ts">
import { defineComponent, reactive, computed, onMounted } from 'vue'
import { computed, defineComponent, onMounted,reactive } from 'vue'
import { useStore } from 'vuex'

import SpModal from '../SpModal'
import SpButton from '../SpButton'
import useKeplr from '../../composables/useKeplr'
import { Wallet } from '../../utils/interfaces'
import SpAccDropdown from '../SpAccDropdown'
import SpSpinner from '../SpSpinner'
import SpProfileIcon from '../SpProfileIcon'
import SpButton from '../SpButton'
import SpChevronDownIcon from '../SpChevronDown'
import SpExternalArrowIcon from '../SpExternalArrow'
import SpKeplrIcon from '../SpKeplrIcon'
import SpModal from '../SpModal'
import SpProfileIcon from '../SpProfileIcon'
import SpSpinner from '../SpSpinner'
import SpWarningIcon from '../SpWarningIcon'
import SpExternalArrowIcon from '../SpExternalArrow'
import SpChevronDownIcon from '../SpChevronDown'

import useKeplr from '../../composables/useKeplr'
import { Wallet } from '../../utils/interfaces'

export interface State {
modalPage: string
connectWalletModal: boolean
accountDropdown: boolean
keplrParams: { name: String; bech32Address: String }
keplrParams: { name: string; bech32Address: string }
}

export let initialState: State = {
Expand Down
26 changes: 14 additions & 12 deletions packages/vue/src/components/SpAccDropdown/SpAccDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,20 @@
<SpChevronRightIcon />
</div>
<hr class="divider" />
<div class="dropdown-option mb-3">
<span> Support </span>
<SpExternalArrowIcon />
</div>
<div class="dropdown-option mb-3">
<span> Twitter </span>
<SpExternalArrowIcon />
</div>
<div class="dropdown-option mb-3">
<span> Telegram </span>
<SpExternalArrowIcon />
</div>
<slot name='externals'>
<div class="dropdown-option mb-3">
<span> Support </span>
<SpExternalArrowIcon />
</div>
<div class="dropdown-option mb-3">
<span> Twitter </span>
<SpExternalArrowIcon />
</div>
<div class="dropdown-option mb-3">
<span> Telegram </span>
<SpExternalArrowIcon />
</div>
</slot>
<div style="text-align: center; margin-top: 2rem">
<span class="description-grey terms-link mr-2">Privacy</span>•
<span class="description-grey terms-link mr-2 ml-1">Terms of use</span>•
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<template>
<a class="dropdown-option mb-3" :href='link' :target='target'>
<span v-text='title'></span>
<SpExternalArrowIcon v-if='hasIcon' />
</a>
</template>

<script lang="ts">
import {
defineComponent,
} from 'vue'

import SpExternalArrowIcon from '../SpExternalArrow'

export default defineComponent({
name: 'SpAccDropdownExternalLink',

components: {
SpExternalArrowIcon,
},

props: {
title: {
type: String,
required: true
},
link: {
type: String,
required: true
},
target: {
type: String,
default: '_blank'
},
hasIcon: {
type: Boolean,
default: true
},
},
})
</script>

<style lang='scss' scoped>
.dropdown-option {
color: #111111;
text-decoration: none;
}
</style>
13 changes: 13 additions & 0 deletions packages/vue/src/components/SpAccDropdownExternalLink/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { App as Application } from 'vue'

import { registerComponent } from './../../utils/plugins/index'
// @ts-ignore
import C from './SpAccDropdownExternalLink.vue'

export const Plugin = {
install(vue: Application): void {
registerComponent(vue, C)
}
}

export default C
6 changes: 5 additions & 1 deletion packages/vue/src/components/SpNavbar/SpNavbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@
</router-link>
</div>
<div class="navbar-section">
<SpAcc />
<SpAcc>
<template #externals>
<slot name="externals"></slot>
</template>
</SpAcc>
</div>
</div>
</template>
Expand Down
2 changes: 2 additions & 0 deletions packages/vue/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as SpAcc } from './SpAcc'
export { default as SpAccDropdownExternalLink } from './SpAccDropdownExternalLink'
export { default as SpAmountSelect } from './SpAmountSelect'
export { default as SpAssets } from './SpAssets'
export { default as SpButton } from './SpButton'
Expand All @@ -10,6 +11,7 @@ export { default as SpCrudDelete } from './SpCrudDelete'
export { default as SpCrudRead } from './SpCrudRead'
export { default as SpCrudUpdate } from './SpCrudUpdate'
export { default as SpDropdown } from './SpDropdown'
export { default as SpExternalArrowIcon } from './SpExternalArrow'
export { default as SpGetTokenTransferList } from './SpGetTokenTransferList'
export { default as SpLinkIcon } from './SpLinkIcon'
export { default as SpModal } from './SpModal'
Expand Down