promo widget colors

This commit is contained in:
SPRINX0\prochazka
2025-10-22 10:47:59 +02:00
parent 82092fab76
commit 3a5f36155f
5 changed files with 36 additions and 8 deletions

View File

@@ -286,7 +286,7 @@ module.exports = {
premiumPromoWidget_meta: true, premiumPromoWidget_meta: true,
async premiumPromoWidget() { async premiumPromoWidget() {
const data = getPromoWidgetData(); const data = await getPromoWidgetData();
if (data?.state != 'data') { if (data?.state != 'data') {
return null; return null;
} }

View File

@@ -18,6 +18,7 @@ const logger = getLogger('cloudIntf');
let cloudFiles = null; let cloudFiles = null;
let promoWidgetData = null; let promoWidgetData = null;
let promoWidgetDataLoaded = false;
const DBGATE_IDENTITY_URL = process.env.LOCAL_DBGATE_IDENTITY const DBGATE_IDENTITY_URL = process.env.LOCAL_DBGATE_IDENTITY
? 'http://localhost:3103' ? 'http://localhost:3103'
@@ -260,13 +261,21 @@ async function getPublicFileData(path) {
return resp.data; return resp.data;
} }
async function updatePremiumPromoWidget() { async function ensurePromoWidgetDataLoaded() {
if (promoWidgetDataLoaded) {
return;
}
try { try {
const fileContent = await fs.readFile(path.join(datadir(), 'promo-widget.json'), 'utf-8'); const fileContent = await fs.readFile(path.join(datadir(), 'promo-widget.json'), 'utf-8');
promoWidgetData = JSON.parse(fileContent); promoWidgetData = JSON.parse(fileContent);
} catch (err) { } catch (err) {
promoWidgetData = null; promoWidgetData = null;
} }
promoWidgetDataLoaded = true;
}
async function updatePremiumPromoWidget() {
await ensurePromoWidgetDataLoaded();
const tags = (await collectCloudFilesSearchTags()).join(','); const tags = (await collectCloudFilesSearchTags()).join(',');
@@ -466,7 +475,8 @@ async function getPublicIpInfo() {
} }
} }
function getPromoWidgetData() { async function getPromoWidgetData() {
await ensurePromoWidgetDataLoaded();
return promoWidgetData; return promoWidgetData;
} }

View File

@@ -34,3 +34,11 @@
.color-icon-premium { .color-icon-premium {
background: linear-gradient(135deg, #1686c8, #8a25b1); background: linear-gradient(135deg, #1686c8, #8a25b1);
} }
.web-color-primary {
background: #1686c8;
}
.web-color-secondary {
background: #8a25b1;
}

View File

@@ -9,6 +9,7 @@
export let title = null; export let title = null;
export let skipWidth = false; export let skipWidth = false;
export let outline = false; export let outline = false;
export let colorClass = '';
function handleClick() { function handleClick() {
if (!disabled) dispatch('click'); if (!disabled) dispatch('click');
@@ -31,6 +32,8 @@
bind:this={domButton} bind:this={domButton}
class:skipWidth class:skipWidth
class:outline class:outline
class={colorClass}
class:setBackgroundColor={!colorClass}
/> />
<style> <style>
@@ -38,19 +41,26 @@
border: 1px solid var(--theme-bg-button-inv-2); border: 1px solid var(--theme-bg-button-inv-2);
padding: 5px; padding: 5px;
margin: 2px; margin: 2px;
background-color: var(--theme-bg-button-inv);
color: var(--theme-font-inv-1); color: var(--theme-font-inv-1);
border-radius: 2px; border-radius: 2px;
} }
.setBackgroundColor {
background-color: var(--theme-bg-button-inv);
}
input:not(.skipWidth) { input:not(.skipWidth) {
width: 100px; width: 100px;
} }
input:hover:not(.disabled):not(.outline) { input:not(.setBackgroundColor) {
cursor: pointer;
}
input.setBackgroundColor:hover:not(.disabled):not(.outline) {
background-color: var(--theme-bg-button-inv-2); background-color: var(--theme-bg-button-inv-2);
} }
input:active:not(.disabled):not(.outline) { input.setBackgroundColor:active:not(.disabled):not(.outline) {
background-color: var(--theme-bg-button-inv-3); background-color: var(--theme-bg-button-inv-3);
} }
input.disabled { input.disabled {

View File

@@ -4,14 +4,14 @@
export let text: string; export let text: string;
export let link: string; export let link: string;
export let newTab: boolean = true; export let colorClass: string = '';
// very light url guard // very light url guard
const safe = /^(https?:)?\/\//i.test(link) || link.startsWith('/'); const safe = /^(https?:)?\/\//i.test(link) || link.startsWith('/');
</script> </script>
<div class="center"> <div class="center">
<FormStyledButton on:click={() => openWebLink(link)} value={text} skipWidth /> <FormStyledButton on:click={() => openWebLink(link)} value={text} skipWidth {colorClass} />
</div> </div>
<style> <style>