Skip to content

Commit

Permalink
nyc mta specific exception
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Nov 17, 2024
1 parent 77ce7eb commit 38057ef
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/components/serviceAlerts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
import { _ } from 'svelte-i18n';
import { cause_id_str, effect_id_str } from './alert_id_to_str_key';
export let alerts = {};
</script>
$: languagelist = Object.values(alerts).map((alert) => {
if (alert.header_text) {
return alert.header_text.translation.map((x) => x.language);
}
return [];
}).flat().filter((x, i, a) => a.indexOf(x) == i);
</script>
{#if Object.keys(alerts).length > 0}
<div class="border-[#F99C24] border-2 leading-snug mb-3 p-2 rounded-md">
<img src="/icons/service_alert.svg" alt="(i)" class="h-6 w-6 inline mr-1" />
Expand All @@ -13,23 +19,30 @@ export let alerts = {};
>
{#each Object.values(alerts) as alert}
<div class="pt-1">
<p class="text-sm">
<p class="text-sm font-semibold text-orange-500">
<span class="">{$_(cause_id_str(alert.cause))}</span>
<span> -> </span>
<span> </span>
<span>{$_(effect_id_str(alert.effect))}</span>

</p>
{#each alert.header_text.translation as each_header_translation_obj}
<p class="text-sm font-bold">{each_header_translation_obj.text}</p>
{#each alert.description_text.translation.filter((x) => x.language == each_header_translation_obj.language) as description_alert}
{#if alert.image}
<img src={alert.image} alt="Service Alert Image" class="max-w-fit" />

{/if}
{#if alert.url}
<a href={alert.url} class="text-blue-500" target="_blank">{alert.url}</a>
{/if}
{#each alert.header_text.translation.filter((x) => languagelist.includes("en-html") ? (x.language != "en") : true) as each_header_translation_obj}
<p class="text-sm font-bold">{each_header_translation_obj.text.replaceAll(/\<(\/)?p\>/g,"").replaceAll(/\<(\/)?b\>/g,"")}</p>
{#each alert.description_text.translation.filter((x) => languagelist.includes("en-html") ? (x.language != "en") : true).filter((x) => x.language == each_header_translation_obj.language) as description_alert}
<div class="leading-none">
{#each description_alert.text.split('\n') as each_desc_line}
<p class="text-sm">
<div class="text-sm">
{@html each_desc_line.replaceAll(
'<a ',
'<a target="_blank" class="text-sky-500 dark:text-sky-300 underline"'
)}
</p>
).replaceAll(/\<(\/)?p\>/g,"").replaceAll(/\<(\/)?b\>/g,"").replaceAll(/(\[)?accessibility icon(\])?/g, "<span class=\"bg-blue-200 dark:bg-gray-500 w-3 h-3 rounded-full inline\"><span class=\"text-sm material-symbols-outlined \">accessible</span></span>")}
</div>
{/each}
</div>
{/each}
Expand Down

0 comments on commit 38057ef

Please sign in to comment.