Skip to content

Commit 5744b7b

Browse files
committed
Auto display (with suppress option) to InfoModal and localize new strings for multiple languages
1 parent bc54d65 commit 5744b7b

11 files changed

Lines changed: 74 additions & 16 deletions

File tree

pcd-website/src/components/InfoModal.vue

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ import { createFocusTrap, type FocusTrap } from 'focus-trap';
66
import { PCD_FORUM_THREAD_URL } from '../config';
77
import fallbackBannerImage from '../images/community_background_2x.png?url';
88
9-
const props = defineProps<{ open: boolean; bannerImageUrl?: string }>();
9+
const props = defineProps<{ open: boolean; bannerImageUrl?: string; autoOpened?: boolean }>();
1010
const bannerImage = computed(() => props.bannerImageUrl ?? fallbackBannerImage);
11-
const emit = defineEmits<{ close: [] }>();
11+
const emit = defineEmits<{ close: []; suppress: [] }>();
12+
13+
const dontShowAgain = ref(false);
14+
15+
function handleClose() {
16+
if (dontShowAgain.value) emit('suppress');
17+
emit('close');
18+
}
1219
1320
const { t } = useI18n();
1421
const modalRef = ref<HTMLElement | null>(null);
@@ -21,7 +28,7 @@ watch(
2128
await nextTick();
2229
if (modalRef.value) {
2330
trap = createFocusTrap(modalRef.value, {
24-
onDeactivate: () => emit('close'),
31+
onDeactivate: () => handleClose(),
2532
escapeDeactivates: true,
2633
allowOutsideClick: true,
2734
fallbackFocus: () => modalRef.value!,
@@ -31,6 +38,7 @@ watch(
3138
} else {
3239
trap?.deactivate();
3340
trap = null;
41+
dontShowAgain.value = false;
3442
}
3543
},
3644
);
@@ -45,7 +53,7 @@ onUnmounted(() => {
4553
<div
4654
v-if="open"
4755
class="info-modal-backdrop"
48-
@click.self="emit('close')"
56+
@click.self="handleClose()"
4957
>
5058
<div
5159
ref="modalRef"
@@ -57,7 +65,7 @@ onUnmounted(() => {
5765
<button
5866
class="info-modal-close"
5967
:aria-label="t('nav.info_modal_close')"
60-
@click="emit('close')"
68+
@click="handleClose()"
6169
>
6270
<Icon icon="bi:x-lg" width="1.125em" height="1.125em" aria-hidden="true" />
6371
</button>
@@ -81,6 +89,10 @@ onUnmounted(() => {
8189
{{ t('nav.info_modal_forum_btn') }}
8290
<Icon icon="bi:box-arrow-up-right" width="1em" height="1em" aria-hidden="true" style="margin-left: 0.5rem; vertical-align: -0.1em;" />
8391
</a>
92+
<label v-if="props.autoOpened" class="info-modal-suppress">
93+
<input type="checkbox" v-model="dontShowAgain" />
94+
{{ t('nav.info_modal_dont_show_again') }}
95+
</label>
8496
</div>
8597
</div>
8698
</div>
@@ -174,4 +186,23 @@ onUnmounted(() => {
174186
.info-modal-forum-btn:hover {
175187
opacity: 0.85;
176188
}
189+
190+
.info-modal-suppress {
191+
display: flex;
192+
align-items: center;
193+
gap: 0.5rem;
194+
margin-top: var(--spacing-md);
195+
font-size: 0.875rem;
196+
color: var(--color-text-muted);
197+
cursor: pointer;
198+
user-select: none;
199+
}
200+
201+
.info-modal-suppress input[type="checkbox"] {
202+
width: 1rem;
203+
height: 1rem;
204+
cursor: pointer;
205+
flex-shrink: 0;
206+
accent-color: var(--color-primary);
207+
}
177208
</style>

pcd-website/src/components/MapView.vue

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,19 @@ const { t } = useI18n();
2121
2222
const selectedNode = ref<Node | null>(null);
2323
const listOpen = ref(false);
24+
25+
const INFO_MODAL_SUPPRESS_KEY = 'pcd-info-modal-suppressed';
2426
const infoModalOpen = ref(false);
27+
const infoModalAutoOpened = ref(false);
28+
29+
function shouldAutoOpenInfoModal(): boolean {
30+
return localStorage.getItem(INFO_MODAL_SUPPRESS_KEY) !== 'true';
31+
}
32+
33+
function suppressInfoModal() {
34+
localStorage.setItem(INFO_MODAL_SUPPRESS_KEY, 'true');
35+
infoModalOpen.value = false;
36+
}
2537
2638
function preloadBannerImage() {
2739
const url = props.bannerImageUrl;
@@ -636,6 +648,12 @@ onMounted(async () => {
636648
document.addEventListener('keydown', handleKeydown);
637649
638650
651+
// Auto-open info modal on first visit
652+
if (shouldAutoOpenInfoModal()) {
653+
infoModalOpen.value = true;
654+
infoModalAutoOpened.value = true;
655+
}
656+
639657
// Update document-level text when locale changes
640658
watch(currentLocale, () => {
641659
document.title = i18n.global.t('page.title');
@@ -683,10 +701,10 @@ onUnmounted(() => {
683701
id="info-btn"
684702
:aria-label="t('nav.info_button_label')"
685703
@mouseenter="preloadBannerImage"
686-
@click="infoModalOpen = true"
704+
@click="infoModalOpen = true; infoModalAutoOpened = false"
687705
>i</button>
688706
</div>
689-
<InfoModal :open="infoModalOpen" :bannerImageUrl="props.bannerImageUrl" @close="infoModalOpen = false" />
707+
<InfoModal :open="infoModalOpen" :bannerImageUrl="props.bannerImageUrl" :autoOpened="infoModalAutoOpened" @close="infoModalOpen = false" @suppress="suppressInfoModal" />
690708
<div class="banner-controls-right">
691709
<button
692710
id="theme-toggle"

pcd-website/src/i18n/locales/de.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"info_modal_description": "Der Processing Community Day (PCD) ist eine weltweite Veranstaltungsreihe, die von lokalen Communities organisiert wird und Kunst, Code und kreative Open-Source-Tools feiert. Finde deine lokale Veranstaltung auf der Karte oder fang an, deine eigene zu organisieren!",
1515
"info_modal_forum_btn": "Mehr im Forum erfahren",
1616
"info_modal_forum_btn_new_tab": "Visit the forum thread (opens in new tab)",
17-
"info_modal_close": "Close"
17+
"info_modal_close": "Close",
18+
"info_modal_dont_show_again": "Nicht mehr anzeigen"
1819
},
1920
"node_list": {
2021
"dialog_label": "Veranstaltungsliste",

pcd-website/src/i18n/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"info_modal_description": "Processing Community Day (PCD) is a worldwide series of community-led events celebrating art, code, and open-source creative tools. Events are organized by local communities around the globe. Find your local event on the map, or start organizing your own!",
1515
"info_modal_forum_btn": "Learn more on the forum",
1616
"info_modal_forum_btn_new_tab": "Visit the forum thread (opens in new tab)",
17-
"info_modal_close": "Close"
17+
"info_modal_close": "Close",
18+
"info_modal_dont_show_again": "Don't show this again"
1819
},
1920
"node_list": {
2021
"dialog_label": "Node list",

pcd-website/src/i18n/locales/es.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"info_modal_description": "Processing Community Day (PCD) es una serie mundial de eventos organizados por comunidades locales que celebran el arte, el código y las herramientas creativas de código abierto. Encuentra tu evento local en el mapa, ¡o empieza a organizar el tuyo!",
1515
"info_modal_forum_btn": "Más información en el foro",
1616
"info_modal_forum_btn_new_tab": "Visit the forum thread (opens in new tab)",
17-
"info_modal_close": "Close"
17+
"info_modal_close": "Close",
18+
"info_modal_dont_show_again": "No volver a mostrar"
1819
},
1920
"node_list": {
2021
"dialog_label": "Lista de eventos",

pcd-website/src/i18n/locales/fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"info_modal_description": "Processing Community Day (PCD) est une série mondiale d'événements organisés par des communautés locales, célébrant l'art, le code et les outils créatifs open source. Trouvez votre événement local sur la carte, ou commencez à organiser le vôtre !",
1515
"info_modal_forum_btn": "En savoir plus sur le forum",
1616
"info_modal_forum_btn_new_tab": "Visit the forum thread (opens in new tab)",
17-
"info_modal_close": "Close"
17+
"info_modal_close": "Close",
18+
"info_modal_dont_show_again": "Ne plus afficher"
1819
},
1920
"node_list": {
2021
"dialog_label": "Liste des événements",

pcd-website/src/i18n/locales/ja.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"info_modal_description": "Processing Community Day(PCD)は、アート・コード・オープンソースのクリエイティブツールを祝う、世界各地のコミュニティが主催するイベントシリーズです。地図からお近くのイベントを見つけるか、自分でイベントを主催してみましょう!",
1515
"info_modal_forum_btn": "フォーラムで詳しく見る",
1616
"info_modal_forum_btn_new_tab": "Visit the forum thread (opens in new tab)",
17-
"info_modal_close": "Close"
17+
"info_modal_close": "Close",
18+
"info_modal_dont_show_again": "今後表示しない"
1819
},
1920
"node_list": {
2021
"dialog_label": "イベントリスト",

pcd-website/src/i18n/locales/ko.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"info_modal_description": "Processing Community Day(PCD)는 예술, 코드, 오픈소스 창작 도구를 기념하는 전 세계 커뮤니티 주도 이벤트 시리즈입니다. 지도에서 가까운 이벤트를 찾거나 직접 이벤트를 조직해 보세요!",
1515
"info_modal_forum_btn": "포럼에서 자세히 알아보기",
1616
"info_modal_forum_btn_new_tab": "Visit the forum thread (opens in new tab)",
17-
"info_modal_close": "Close"
17+
"info_modal_close": "Close",
18+
"info_modal_dont_show_again": "다시 표시하지 않기"
1819
},
1920
"node_list": {
2021
"dialog_label": "이벤트 목록",

pcd-website/src/i18n/locales/pt.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"info_modal_description": "O Processing Community Day (PCD) é uma série mundial de eventos organizados por comunidades locais que celebram a arte, o código e as ferramentas criativas de código aberto. Encontre o seu evento local no mapa ou comece a organizar o seu próprio!",
1515
"info_modal_forum_btn": "Saiba mais no fórum",
1616
"info_modal_forum_btn_new_tab": "Visit the forum thread (opens in new tab)",
17-
"info_modal_close": "Close"
17+
"info_modal_close": "Close",
18+
"info_modal_dont_show_again": "Não mostrar novamente"
1819
},
1920
"node_list": {
2021
"dialog_label": "Lista de eventos",

pcd-website/src/i18n/locales/zh-CN.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"info_modal_description": "Processing Community Day(PCD)是由全球各地社区主办的系列活动,旨在庆祝艺术、代码与开源创意工具。在地图上找到您附近的活动,或者开始组织您自己的活动!",
1515
"info_modal_forum_btn": "在论坛了解更多",
1616
"info_modal_forum_btn_new_tab": "Visit the forum thread (opens in new tab)",
17-
"info_modal_close": "Close"
17+
"info_modal_close": "Close",
18+
"info_modal_dont_show_again": "不再显示"
1819
},
1920
"node_list": {
2021
"dialog_label": "活动列表",

0 commit comments

Comments
 (0)