github.com/Theta-Dev/Talon@v0.0.0-20211018130634-ff179e19fa9a/ui/menu/src/components/InfoModal.svelte (about)

     1  <script lang="ts">
     2  	import {fly} from "svelte/transition"
     3  	import {closeModal} from "svelte-modals"
     4  	import Keydown from "svelte-keydown"
     5  
     6  	import type {TalonVersion} from "../util/types"
     7  	import PageIcon from "./PageIcon.svelte"
     8  	import Icon from "./Icon.svelte"
     9  	import {formatDate} from "../util/functions"
    10  	import InlineIcon from "./InlineIcon.svelte"
    11  	import Tag from "./Tag.svelte"
    12  	import {
    13  		currentPage,
    14  		currentVersion,
    15  		currentVersionId,
    16  		rootPath,
    17  		versions,
    18  	} from "../util/talonData"
    19  
    20  	export let isOpen: boolean
    21  
    22  	function getVersionName(versionId: string, version: TalonVersion): string {
    23  		return version.name ? version.name : "#" + versionId
    24  	}
    25  
    26  	function getVersionUrl(versionId: string, version: TalonVersion): string {
    27  		return (
    28  			rootPath +
    29  			(currentPage && version.name
    30  				? currentPage.path + "@" + version.name
    31  				: "&v/" + versionId)
    32  		)
    33  	}
    34  
    35  	let versionName: string
    36  	$: versionName = getVersionName(currentVersionId, currentVersion)
    37  
    38  	let versionUrl: string
    39  	$: versionUrl = getVersionUrl(currentVersionId, currentVersion)
    40  
    41  	let uploadDate: string
    42  	$: uploadDate = formatDate(currentVersion.date)
    43  
    44  	let pageTags: [string, string][]
    45  	$: pageTags = currentVersion.tags
    46  		? Object.entries(currentVersion.tags).map(([key, val]) => [
    47  				key.replace(/^\w/, (c) => c.toUpperCase()),
    48  				val,
    49  		  ])
    50  		: []
    51  
    52  	let history: [string, string, string][]
    53  	$: history = Object.entries(versions)
    54  		.filter((e) => e[0] !== currentVersionId)
    55  		.map(([key, version]) => [
    56  			formatDate(version.date),
    57  			getVersionName(key, version),
    58  			getVersionUrl(key, version),
    59  		])
    60  
    61  </script>
    62  
    63  <style lang="sass">
    64  	@use "../style/values"
    65  
    66  	.modal
    67  		position: fixed
    68  		top: 0
    69  		bottom: 0
    70  		right: 0
    71  		left: 0
    72  		display: flex
    73  		justify-content: center
    74  		align-items: center
    75  		pointer-events: none
    76  
    77  		> div
    78  			position: relative
    79  			overflow-y: auto
    80  			overflow-x: hidden
    81  
    82  			margin: 75px auto
    83  			padding: 20px
    84  			width: 600px
    85  			max-width: 90%
    86  			max-height: 90%
    87  
    88  			background: values.$color-base
    89  			border-radius: 15px
    90  			box-shadow: 0 0 50px rgba(0, 0, 0, 0.5)
    91  
    92  			pointer-events: auto
    93  
    94  	.tag
    95  		display: flex
    96  		align-items: center
    97  
    98  		span
    99  			font-size: 2em
   100  			margin-left: 0.25em
   101  
   102  	button
   103  		position: absolute
   104  		right: 5px
   105  		top: 5px
   106  		background: none
   107  		border: none
   108  
   109  		&:hover
   110  			filter: brightness(50%)
   111  
   112  	.dhead
   113  		width: 100%
   114  		font-size: 1.4em
   115  		border-style: solid
   116  		border-image-source: linear-gradient(to right, values.$color-base-1, values.$color-base-2, values.$color-base-1)
   117  		border-image-slice: 0 0 1 0
   118  		border-image-width: 2px
   119  
   120  	.smalltag
   121  		margin: 0.3em 0
   122  		display: flex
   123  
   124  		> *
   125  			display: flex
   126  
   127  		a
   128  			filter: none
   129  
   130  		a:hover
   131  			text-decoration: none
   132  			filter: brightness(130%)
   133  
   134  		span
   135  			padding: 0.4em
   136  			background-color: values.$color-base-1
   137  
   138  		span:first-child
   139  			font-weight: bold
   140  			background-color: var(--talon-color)
   141  
   142  </style>
   143  
   144  <Keydown paused={!isOpen} on:Escape={closeModal} />
   145  
   146  {#if isOpen}
   147  	<div class="modal" role="dialog" transition:fly={{y: 50}} on:introstart on:outroend>
   148  		<div>
   149  			<div class="tag">
   150  				<PageIcon page={currentPage} size={60} scale={0.8} />
   151  				<span>{currentPage ? currentPage.name : 'v' + currentVersionId}</span>
   152  			</div>
   153  
   154  			{#if !currentPage}
   155  				<p>
   156  					This is a dangling version, i.e. it does not belong to a page.
   157  					Assign it to a page or it will be purged within 24 hours.
   158  				</p>
   159  			{/if}
   160  
   161  			<p class="dhead">
   162  				<InlineIcon iconName="question" />
   163  				Current version
   164  			</p>
   165  
   166  			<Tag key="Version" value={versionName} href={versionUrl} />
   167  			<Tag key="Upload date" value={uploadDate} />
   168  			<Tag key="Uploaded by" value={currentVersion.user} />
   169  
   170  			{#each pageTags as [key, value]}
   171  				<Tag {key} {value} />
   172  			{/each}
   173  
   174  			{#if history.length}
   175  				<p class="dhead">
   176  					<InlineIcon iconName="history" />
   177  					History
   178  				</p>
   179  
   180  				{#each history as [date, name, url]}
   181  					<p class="smalltag">
   182  						<a href={url}> <span>{name}</span> <span>{date}</span> </a>
   183  					</p>
   184  				{/each}
   185  			{/if}
   186  
   187  			<p class="dhead" />
   188  
   189  			<div>
   190  				This site is powered by
   191  				<a
   192  					href="https://github.com/Theta-Dev/Talon/tree/__VERSION__"
   193  					target="_blank"
   194  					referrerpolicy="no-referrer">Talon __VERSION__</a>, a static site
   195  				management system created by
   196  				<a
   197  					href="https://thetadev.de"
   198  					target="_blank"
   199  					referrerpolicy="no-referrer">ThetaDev</a>
   200  			</div>
   201  			<p><a href={rootPath + '&credits'} target="_blank">View licenses</a></p>
   202  			<button on:click={closeModal}>
   203  				<Icon iconName="close" size={40} scale={0.6} transparent={true} />
   204  			</button>
   205  		</div>
   206  	</div>
   207  {/if}