mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 16:26:00 +00:00
json UI improvements
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
import JsonUiHeading from './JsonUiHeading.svelte';
|
import JsonUiHeading from './JsonUiHeading.svelte';
|
||||||
import JsonUiHighlight from './JsonUiHighlight.svelte';
|
import JsonUiHighlight from './JsonUiHighlight.svelte';
|
||||||
import JsonUiLinkButton from './JsonUiLinkButton.svelte';
|
import JsonUiLinkButton from './JsonUiLinkButton.svelte';
|
||||||
|
import JsonUiLinkButtonBlock from './JsonUiLinkButtonBlock.svelte';
|
||||||
import JsonUiMarkdown from './JsonUiMarkdown.svelte';
|
import JsonUiMarkdown from './JsonUiMarkdown.svelte';
|
||||||
import JsonUiTextBlock from './JsonUiTextBlock.svelte';
|
import JsonUiTextBlock from './JsonUiTextBlock.svelte';
|
||||||
import JsonUiTickList from './JsonUiTickList.svelte';
|
import JsonUiTickList from './JsonUiTickList.svelte';
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
markdown: JsonUiMarkdown,
|
markdown: JsonUiMarkdown,
|
||||||
highlight: JsonUiHighlight,
|
highlight: JsonUiHighlight,
|
||||||
countdown: JsonUiCountdown,
|
countdown: JsonUiCountdown,
|
||||||
|
buttonblock: JsonUiLinkButtonBlock,
|
||||||
} as const;
|
} as const;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
import { openWebLink } from '../utility/simpleTools';
|
||||||
|
|
||||||
export let colorClass: string = 'premium-gradient';
|
export let colorClass: string = 'premium-gradient';
|
||||||
export let validTo;
|
export let validTo;
|
||||||
|
export let link;
|
||||||
|
|
||||||
function formatRemaining(validTo, now) {
|
function formatRemaining(validTo, now) {
|
||||||
let diffMs = validTo.getTime() - now.getTime();
|
let diffMs = validTo.getTime() - now.getTime();
|
||||||
@@ -43,7 +45,15 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if validTo}
|
{#if validTo}
|
||||||
<div class="countdown {colorClass}">
|
<div
|
||||||
|
class="countdown {colorClass}"
|
||||||
|
class:isLink={!!link}
|
||||||
|
on:click={() => {
|
||||||
|
if (link) {
|
||||||
|
openWebLink(link);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
<span class="big">Offer ends in:</span><br />
|
<span class="big">Offer ends in:</span><br />
|
||||||
{#each parts as part}
|
{#each parts as part}
|
||||||
<span class="part">
|
<span class="part">
|
||||||
@@ -62,6 +72,10 @@
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.countdown.isLink {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.big {
|
.big {
|
||||||
font-size: large;
|
font-size: large;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|||||||
@@ -1,19 +1,28 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let text: string;
|
export let text: string;
|
||||||
export let colorClass: string = 'premium-gradient';
|
export let colorClass: string = 'premium-gradient';
|
||||||
|
export let link: string;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if link}
|
||||||
|
<a class="highlight {colorClass}" href={link}>
|
||||||
|
{text}
|
||||||
|
</a>
|
||||||
|
{:else}
|
||||||
<div class="highlight {colorClass}">
|
<div class="highlight {colorClass}">
|
||||||
{text}
|
{text}
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.highlight {
|
.highlight {
|
||||||
|
display: block;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
font-size: large;
|
font-size: large;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -5,9 +5,6 @@
|
|||||||
export let text: string;
|
export let text: string;
|
||||||
export let link: string;
|
export let link: string;
|
||||||
export let colorClass: string = '';
|
export let colorClass: string = '';
|
||||||
|
|
||||||
// very light url guard
|
|
||||||
const safe = /^(https?:)?\/\//i.test(link) || link.startsWith('/');
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="center">
|
<div class="center">
|
||||||
|
|||||||
21
packages/web/src/jsonui/JsonUiLinkButtonBlock.svelte
Normal file
21
packages/web/src/jsonui/JsonUiLinkButtonBlock.svelte
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import FormStyledButton from '../buttons/FormStyledButton.svelte';
|
||||||
|
import { openWebLink } from '../utility/simpleTools';
|
||||||
|
|
||||||
|
export let text: string;
|
||||||
|
export let link: string;
|
||||||
|
export let colorClass: string = '';
|
||||||
|
export let items: any[] = [];
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="center">
|
||||||
|
{#each items as item}
|
||||||
|
<FormStyledButton on:click={() => openWebLink(item.link)} value={item.text} skipWidth {colorClass} />
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user